@InterfaceAudience.Private public final class SubjectUtil extends Object
In JDK 17, the Security Manager and APIs related to it have been deprecated and are subject to removal in a future release. There is no replacement for the Security Manager. See JEP 411 for discussion and alternatives.
In JDK 24, the Security Manager has been permanently disabled. See JEP 486 for more information.
This is derived from Apache Calcite Avatica, which is derived from the Jetty implementation.
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
callAs(Subject subject,
Callable<T> action)
Map to Subject.callAs() if available, otherwise maps to Subject.doAs().
|
static Subject |
current()
Maps to Subject.current() if available, otherwise maps to Subject.getSubject().
|
static <T> T |
doAs(Subject subject,
PrivilegedAction<T> action)
Map action to a Callable on Java 18 onwards, and delegates to callAs().
|
static <T> T |
doAs(Subject subject,
PrivilegedExceptionAction<T> action)
Maps action to a Callable on Java 18 onwards, and delegates to callAs().
|
public static <T> T callAs(Subject subject, Callable<T> action) throws CompletionException
T - the type of the resultsubject - the subject this action runs asaction - the action to runNullPointerException - if action is nullCompletionException - if action.call() throws an exception.
The cause of the CompletionException is set to the exception
thrown by action.call().public static <T> T doAs(Subject subject, PrivilegedAction<T> action)
Note: Exception propagation behavior is different since Java 12, it always throw the original exception thrown by action; for lower Java versions, throw a PrivilegedActionException that wraps the original exception when action throw a checked exception.
T - the type of the resultsubject - the subject this action runs asaction - the action to runNullPointerException - if action is nullpublic static <T> T doAs(Subject subject, PrivilegedExceptionAction<T> action) throws PrivilegedActionException
T - the type of the resultsubject - the subject this action runs asaction - the action to runNullPointerException - if action is nullPrivilegedActionException - if action.run() throws an checked exception.
The cause of the PrivilegedActionException is set to the exception thrown
by action.run().public static Subject current()
Copyright © 2008–2026 Apache Software Foundation. All rights reserved.