public class AccessUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <E extends Exception> |
doConditionallyPrivileged(boolean condition,
ThrowingRunnable<E> action)
Performs the specified action with privileges enabled if the specified condition is
true
. |
static <T,E extends Exception> |
doConditionallyPrivileged(boolean condition,
ThrowingSupplier<T,E> action)
Performs the specified action with privileges enabled if the specified condition is
true
. |
static <E extends Exception> |
doPrivileged(ThrowingRunnable<E> action)
Performs the specified action with privileges enabled.
|
static <T,E extends Exception> |
doPrivileged(ThrowingSupplier<T,E> action)
Performs the specified action with privileges enabled.
|
public static <T,E extends Exception> T doPrivileged(ThrowingSupplier<T,E> action) throws E extends Exception
If the action's ThrowingSupplier.get() method throws an unchecked exception, it
will propagate through this method.
Note: Any DomainCombiner associated with the current AccessControlContext will be ignored while the action is performed.
T - the type of the value returned by the actionE - the type of exceptions thrown by the actionaction - the action to be performedrun methodE - if the specified action's threw the exceptionIllegalArgumentException - if action is nullE extends Exceptionpublic static <T,E extends Exception> T doConditionallyPrivileged(boolean condition, ThrowingSupplier<T,E> action) throws E extends Exception
true
. The action is performed with all of the permissions possessed by this class'
(or by the migration framework's) protection domain. Otherwise performs the specified action
using the caller's permissions.
If the action's ThrowingSupplier.get() method throws an unchecked exception, it
will propagate through this method.
Note: Any DomainCombiner associated with the current AccessControlContext will be ignored while the action is performed.
T - the type of the value returned by the actionE - the type of exceptions thrown by the actioncondition - true to perform the action with the permissions possessed by this
class; false to use the caller's permissionsaction - the action to be performedrun methodE - if the specified action's threw the exceptionIllegalArgumentException - if action is nullE extends Exceptionpublic static <E extends Exception> void doPrivileged(ThrowingRunnable<E> action) throws E extends Exception
If the action's ThrowingSupplier.get() method throws an unchecked exception, it
will propagate through this method.
Note: Any DomainCombiner associated with the current AccessControlContext will be ignored while the action is performed.
E - the type of exceptions thrown by the actionaction - the action to be performedE - if the specified action's threw the exceptionIllegalArgumentException - if action is nullE extends Exceptionpublic static <E extends Exception> void doConditionallyPrivileged(boolean condition, ThrowingRunnable<E> action) throws E extends Exception
true
. The action is performed with all of the permissions possessed by this class'
(or by the migration framework's) protection domain. Otherwise performs the specified action
using the caller's permissions.
If the action's ThrowingSupplier.get() method throws an unchecked exception, it
will propagate through this method.
Note: Any DomainCombiner associated with the current AccessControlContext will be ignored while the action is performed.
E - the type of exceptions thrown by the actioncondition - true to perform the action with the permissions possessed by this
class; false to use the caller's permissionsaction - the action to be performedE - if the specified action's threw the exceptionIllegalArgumentException - if action is nullE extends ExceptionThis work is licensed under a Creative Commons Attribution 4.0 International License.