Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.security.auth.Subject
Constructor Summary | |
| |
|
Method Summary | |
|
|
|
|
static Object |
|
static Object |
|
static Object |
|
static Object |
|
boolean | |
|
|
Set | |
Set | |
Set | |
static Subject |
|
int |
|
boolean |
|
void |
|
String |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
Constructor Details
Subject
public Subject()
The basic constructor. Object is special, because it has no
superclass, so there is no call to super().
Method Details
doAs
public static Object doAs(Subject subject,
PrivilegedAction<T> action)
Run a method as another subject. This method will obtain the current
AccessControlContext
for this thread, then creates another with
a 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 AuthPermission
.
doAs
public static Object doAs(Subject subject,
PrivilegedExceptionAction<T> action)
throws PrivilegedActionException
Run a method as another subject. This method will obtain the current
AccessControlContext
for this thread, then creates another with
a 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 AuthPermission
.PrivilegedActionException
- If the action throws an exception.
doAsPrivileged
public static Object doAsPrivileged(Subject subject,
PrivilegedAction<T> action,
AccessControlContext acc)
Run a method as another subject. This method will create a new
AccessControlContext
derived from the given one, with a
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 AuthPermission
.
doAsPrivileged
public static Object doAsPrivileged(Subject subject,
PrivilegedExceptionAction<T> action,
AccessControlContext acc)
throws PrivilegedActionException
Run a method as another subject. This method will create a new
AccessControlContext
derived from the given one, with a
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
AuthPermission
.PrivilegedActionException
- If the action throws an exception.
equals
public boolean equals(Object o)
Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this
method which subclasses must follow:
- It must be transitive. If
a.equals(b)
and
b.equals(c)
, then a.equals(c)
must be true as well. - It must be symmetric.
a.equals(b)
and
b.equals(a)
must have the same value. - It must be reflexive.
a.equals(a)
must
always be true. - It must be consistent. Whichever value a.equals(b)
returns on the first invocation must be the value
returned on all later invocations.
a.equals(null)
must be false.- It must be consistent with hashCode(). That is,
a.equals(b)
must imply
a.hashCode() == b.hashCode()
.
The reverse is not true; two objects that are not
equal may have the same hashcode, but that has
the potential to harm hashing performance.
This is typically overridden to throw a ClassCastException
if the argument is not comparable to the class performing
the comparison, but that is not a requirement. It is legal
for a.equals(b)
to be true even though
a.getClass() != b.getClass()
. Also, it
is typical to never cause a NullPointerException
.
In general, the Collections API (java.util
) use the
equals
method rather than the ==
operator to compare objects. However, IdentityHashMap
is an exception to this rule, for its own good reasons.
The default implementation returns this == o
.
- Parameters:
- Returns:
- whether this Object is semantically equal to another
- See Also:
Object.hashCode()
getPrivateCredentials
public Set