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