@Deprecated(since="17", forRemoval=true) public final class AccessControlContext extends Object
AccessControlContext
is used to make system resource access decisions based on the context it encapsulates. 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 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)
Constructor | Description |
---|---|
AccessControlContext |
Deprecated, for removal: This API element is subject to removal in a future version. Create a new AccessControlContext with the given AccessControlContext and DomainCombiner . |
AccessControlContext |
Deprecated, for removal: This API element is subject to removal in a future version. Create an AccessControlContext with the given array of ProtectionDomain objects. |
Modifier and Type | Method | Description |
---|---|---|
void |
checkPermission |
Deprecated, for removal: This API element is subject to removal in a future version. 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. |
boolean |
equals |
Deprecated, for removal: This API element is subject to removal in a future version. Checks two AccessControlContext objects for equality. |
DomainCombiner |
getDomainCombiner() |
Deprecated, for removal: This API element is subject to removal in a future version. Get the DomainCombiner associated with this AccessControlContext . |
int |
hashCode() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns the hash code value for this context. |
public AccessControlContext(ProtectionDomain[] context)
AccessControlContext
with the given array of ProtectionDomain
objects. Context must not be null
. Duplicate domains will be removed from the context.context
- the ProtectionDomain
objects associated with this context. The non-duplicate domains are copied from the array. Subsequent changes to the array will not affect this AccessControlContext
.NullPointerException
- if context
is null
public AccessControlContext(AccessControlContext acc, DomainCombiner combiner)
AccessControlContext
with the given AccessControlContext
and DomainCombiner
. This constructor associates the provided DomainCombiner
with the provided AccessControlContext
.acc
- the AccessControlContext
associated with the provided DomainCombiner
.combiner
- the DomainCombiner
to be associated with the provided AccessControlContext
.NullPointerException
- if the provided context
is null
.SecurityException
- if a security manager is installed and the caller does not have the "createAccessControlContext" SecurityPermission
public DomainCombiner getDomainCombiner()
DomainCombiner
associated with this AccessControlContext
.DomainCombiner
associated with this AccessControlContext
, or null
if there is none.SecurityException
- if a security manager is installed and the caller does not have the "getDomainCombiner" SecurityPermission
public void checkPermission(Permission perm) throws AccessControlException
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.
perm
- the requested permission.AccessControlException
- if the specified permission is not permitted, based on the current security policy and the context encapsulated by this object.NullPointerException
- if the permission to check for is null
.public boolean equals(Object obj)
AccessControlContext
objects for equality. Checks that obj
is an AccessControlContext
and has the same set of ProtectionDomain
objects as this context.public int hashCode()
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/AccessControlContext.html