Class: java.security.AccessControlContext
- public final class AccessControlContext
More specifically, it encapsulates a context and
has a single method, checkPermission,
that is equivalent to the checkPermission method
in the AccessController class, with one difference: The AccessControlContext
checkPermission method makes access decisions based on the
context it encapsulates,
rather than that of the current execution thread.
Thus, the purpose of AccessControlContext is for those situations where a security check that should be made within a given context actually needs to be done from within a different context (for example, from within a worker thread).
An AccessControlContext is created by calling the
AccessController.getContext method.
The getContext method takes a "snapshot"
of the current calling context, and places
it in an AccessControlContext object, which it returns. A sample call is
the following:
AccessControlContext acc = AccessController.getContext()
Code within a different context can subsequently call the
checkPermission method on the
previously-saved AccessControlContext object. A sample call is the
following:
acc.checkPermission(permission)
Methods
-
AccessControlContexttop
public AccessControlContext(AccessControlContext acc, DomainCombiner combiner)Create a newAccessControlContextwith the givenAccessControlContextandDomainCombiner. This constructor associates the providedDomainCombinerwith the providedAccessControlContext. -
AccessControlContexttop
public AccessControlContext(ProtectionDomain[] context)Create an AccessControlContext with the given set of ProtectionDomains. Context must not be null. Duplicate domains will be removed from the context. -
AccessControlContexttop
AccessControlContext(ProtectionDomain[] context, DomainCombiner combiner)package private for AccessController -
AccessControlContexttop
AccessControlContext(ProtectionDomain[] context, boolean isPrivileged)package private constructor for AccessController.getContext() -
checkPermissiontop
public void checkPermission(Permission perm) throws AccessControlExceptionDetermines whether the access request indicated by the specified permission should be allowed or denied, based on the security policy currently in effect, and the context in this object. The request is allowed only if every ProtectionDomain in the context implies the permission. Otherwise the request is denied.This method quietly returns if the access request is permitted, or throws a suitable AccessControlException otherwise.
-
containsAllPDstop
private boolean containsAllPDs(AccessControlContext that) -
equalstop
public boolean equals(Object obj)Checks two AccessControlContext objects for equality. Checks that obj is an AccessControlContext and has the same set of ProtectionDomains as this context. -
getAssignedCombinertop
DomainCombiner getAssignedCombiner()get the assigned combiner from the privileged or inherited context -
getDebugtop
static Debug getDebug() -
getDomainCombinertop
public DomainCombiner getDomainCombiner()Get theDomainCombinerassociated with thisAccessControlContext. -
goCombinertop
-
hashCodetop
public int hashCode()Returns the hash code value for this context. The hash code is computed by exclusive or-ing the hash code of all the protection domains in the context together. -
isPrivilegedtop
boolean isPrivileged()Returns true if this context is privileged. -
optimizetop
AccessControlContext optimize()Take the stack-based context (this) and combine it with the privileged or inherited context, if need be.
Fields
-
combiner
private DomainCombiner combiner -
context
private ProtectionDomain[] context -
debug
static private Debug debug -
debugInit
static private boolean debugInit -
isPrivileged
private boolean isPrivileged -
privilegedContext
private AccessControlContext privilegedContext
