public final class AccessControlContext extends Object
More specifically, it encapsulates a context and
has a single method,
that is equivalent to the
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
getContext method takes a "snapshot"
of the current calling context, and places
it in an AccessControlContext object, which it returns. A sample call is
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
|Constructor and Description|
Create a new
Create an AccessControlContext with the given array of ProtectionDomains.
|Modifier and Type||Method and Description|
Determines 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.
Checks two AccessControlContext objects for equality.
Returns the hash code value for this context.
public AccessControlContext(ProtectionDomain context)
context- the ProtectionDomains associated with this context. The non-duplicate domains are copied from the array. Subsequent changes to the array will not affect this AccessControlContext.
public AccessControlContext(AccessControlContext acc, DomainCombiner combiner)
AccessControlContextwith the given
DomainCombiner. This constructor associates the provided
DomainCombinerwith the provided
AccessControlContextassociated with the provided
DomainCombinerto be associated with the provided
NullPointerException- if the provided
SecurityException- if a security manager is installed and the caller does not have the "createAccessControlContext"
public DomainCombiner getDomainCombiner()
DomainCombinerassociated with this
public void checkPermission(Permission perm) throws AccessControlException
This method quietly returns if the access request is permitted, or throws a suitable AccessControlException otherwise.
public boolean equals(Object obj)
public int hashCode()