@@ -757,6 +757,35 @@ public static void requirePrivilege(String privilege) throws ContextAuthenticati
757757 }
758758 }
759759
760+ /**
761+ * Adds one or more privileges to the list of privileges that that {@link #hasPrivilege(String)} will
762+ * regard as available regardless of whether the user would otherwise have the privilege.
763+ * <p/>
764+ * This is useful for situations where a system process may need access to some piece of data that the
765+ * user would not otherwise have access to, like a GlobalProperty. <strong>This facility should not be
766+ * used to return data to the user that they otherwise would be unable to see.</strong>
767+ * <p/>
768+ * The expected usage is:
769+ * <p/>
770+ * <pre>{@code
771+ * try {
772+ * Context.addProxyPrivilege("AAA");
773+ * Context.get*Service().methodRequiringAAAPrivilege();
774+ * }
775+ * finally {
776+ * Context.removeProxyPrivilege("AAA");
777+ * }}
778+ * </pre>
779+ * <p/>
780+ *
781+ * @param privilege privileges to add in string form
782+ * @see #hasPrivilege(String)
783+ * @see #removeProxyPrivilege(String)
784+ */
785+ public static void addProxyPrivilege (String privilege ) {
786+ getUserContext ().addProxyPrivilege (privilege );
787+ }
788+
760789 /**
761790 * Adds one or more privileges to the list of privileges that that {@link #hasPrivilege(String)} will
762791 * regard as available regardless of whether the user would otherwise have the privilege.
@@ -781,13 +810,29 @@ public static void requirePrivilege(String privilege) throws ContextAuthenticati
781810 * @param privileges privileges to add in string form
782811 * @see #hasPrivilege(String)
783812 * @see #removeProxyPrivilege(String...)
813+ * @since 3.0.0, 2.8.2, 2.7.8
784814 */
785815 public static void addProxyPrivilege (String ... privileges ) {
786816 getUserContext ().addProxyPrivilege (privileges );
787817 }
788-
818+
819+ /**
820+ * Removes one or more privileges from the list of privileges that that {@link #hasPrivilege(String)} will
821+ * regard as available regardless of whether the user would otherwise have the privilege.
822+ * <p/>
823+ * This is the compliment for {@link #addProxyPrivilege(String...)} to clean-up the context.
824+ * <p/>
825+ *
826+ * @param privilege privileges to remove in string form
827+ * @see #hasPrivilege(String)
828+ * @see #addProxyPrivilege(String)
829+ */
830+ public static void removeProxyPrivilege (String privilege ) {
831+ getUserContext ().removeProxyPrivilege (privilege );
832+ }
833+
789834 /**
790- * Removes one or more privileges to the list of privileges that that {@link #hasPrivilege(String)} will
835+ * Removes a privilege from the list of privileges that that {@link #hasPrivilege(String)} will
791836 * regard as available regardless of whether the user would otherwise have the privilege.
792837 * <p/>
793838 * This is the compliment for {@link #addProxyPrivilege(String...)} to clean-up the context.
@@ -796,6 +841,7 @@ public static void addProxyPrivilege(String... privileges) {
796841 * @param privileges privileges to remove in string form
797842 * @see #hasPrivilege(String)
798843 * @see #addProxyPrivilege(String...)
844+ * * @since 3.0.0, 2.8.2, 2.7.8
799845 */
800846 public static void removeProxyPrivilege (String ... privileges ) {
801847 getUserContext ().removeProxyPrivilege (privileges );
0 commit comments