javax.security.auth
public final class Subject extends Object implements Serializable
| Constructor Summary | |
|---|---|
| Subject() | |
| Subject(boolean readOnly, Set<? extends Principal> principals, Set<?> pubCred, Set<?> privCred) | |
| Method Summary | |
|---|---|
| static Object | doAs(Subject subject, PrivilegedAction action) Run a method as another subject. |
| static Object | doAs(Subject subject, PrivilegedExceptionAction action) Run a method as another subject. |
| static Object | doAsPrivileged(Subject subject, PrivilegedAction action, AccessControlContext acc) Run a method as another subject. |
| static Object | doAsPrivileged(Subject subject, PrivilegedExceptionAction action, AccessControlContext acc) Run a method as another subject. |
| boolean | equals(Object o) |
| Set<Principal> | getPrincipals() |
| <T extends Principal> Set<T> | getPrincipals(Class<T> clazz) |
| Set<Object> | getPrivateCredentials() |
| <T> Set<T> | getPrivateCredentials(Class<T> clazz) |
| Set<Object> | getPublicCredentials() |
| <T> Set<T> | getPublicCredentials(Class<T> clazz) |
| static Subject | getSubject(AccessControlContext context) Returns the subject associated with the given {@link AccessControlContext}. All this method does is retrieve the Subject object from the supplied context's {@link DomainCombiner}, if any, and if it is an instance of a {@link SubjectDomainCombiner}. |
| int | hashCode() |
| boolean | isReadOnly() Returns whether or not this subject is read-only. |
| void | setReadOnly() Marks this subject as read-only. |
| String | toString() |
Run a method as another subject. This method will obtain the current {@link AccessControlContext} for this thread, then creates another with a {@link SubjectDomainCombiner} with the given subject. The supplied action will then be run with the modified context.
Parameters: subject The subject to run as. action The action to run.
Returns: The value returned by the privileged action.
Throws: SecurityException If the caller is not allowed to run under a
different identity ("doAs" target of {@link AuthPermission}.
Run a method as another subject. This method will obtain the current {@link AccessControlContext} for this thread, then creates another with a {@link SubjectDomainCombiner} with the given subject. The supplied action will then be run with the modified context.
Parameters: subject The subject to run as. action The action to run.
Returns: The value returned by the privileged action.
Throws: SecurityException If the caller is not allowed to run under a
different identity ("doAs" target of {@link AuthPermission}. PrivilegedActionException If the action throws an exception.
Run a method as another subject. This method will create a new {@link AccessControlContext} derived from the given one, with a {@link SubjectDomainCombiner} with the given subject. The supplied action will then be run with the modified context.
Parameters: subject The subject to run as. action The action to run. acc The context to use.
Returns: The value returned by the privileged action.
Throws: SecurityException If the caller is not allowed to run under a
different identity ("doAsPrivileged" target of {@link
AuthPermission}.
Run a method as another subject. This method will create a new {@link AccessControlContext} derived from the given one, with a {@link SubjectDomainCombiner} with the given subject. The supplied action will then be run with the modified context.
Parameters: subject The subject to run as. action The action to run. acc The context to use.
Returns: The value returned by the privileged action.
Throws: SecurityException If the caller is not allowed to run under a
different identity ("doAsPrivileged" target of
{@link AuthPermission}. PrivilegedActionException If the action throws an exception.
Returns the subject associated with the given {@link AccessControlContext}.
All this method does is retrieve the Subject object from the supplied context's {@link DomainCombiner}, if any, and if it is an instance of a {@link SubjectDomainCombiner}.
Parameters: context The context to retrieve the subject from.
Returns: The subject assoctiated with the context, or null
if there is none.
Throws: NullPointerException If subject is null. SecurityException If the caller does not have permission to get
the subject ("getSubject" target of {@link AuthPermission}.
Returns whether or not this subject is read-only.
Returns: True is this subject is read-only.
Marks this subject as read-only.
Throws: SecurityException If the caller does not have permission to
set this subject as read-only ("setReadOnly" target of
{@link AuthPermission}.