public final class

AccessControlContext

extends Object
java.lang.Object
   ↳ java.security.AccessControlContext

Class Overview

AccessControlContext encapsulates the ProtectionDomains on which access control decisions are based.

Summary

Public Constructors
AccessControlContext(AccessControlContext acc, DomainCombiner combiner)
Constructs a new instance of AccessControlContext with the specified AccessControlContext and DomainCombiner.
AccessControlContext(ProtectionDomain[] context)
Constructs a new instance of AccessControlContext with the specified array of ProtectionDomains.
Public Methods
void checkPermission(Permission perm)
Checks the specified permission against the vm's current security policy.
boolean equals(Object obj)
Compares the specified object with this AccessControlContext for equality.
DomainCombiner getDomainCombiner()
Returns the DomainCombiner associated with this AccessControlContext.
int hashCode()
Returns the hash code value for this AccessControlContext.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AccessControlContext (AccessControlContext acc, DomainCombiner combiner)

Since: API Level 1

Constructs a new instance of AccessControlContext with the specified AccessControlContext and DomainCombiner.

If a SecurityManager is installed, code calling this constructor need the SecurityPermission createAccessControlContext to be granted, otherwise a SecurityException will be thrown.

Parameters
acc the AccessControlContext related to the given DomainCombiner
combiner the DomainCombiner related to the given AccessControlContext
Throws
SecurityException if a SecurityManager is installed and the caller does not have permission to invoke this constructor
NullPointerException if acc is null

public AccessControlContext (ProtectionDomain[] context)

Since: API Level 1

Constructs a new instance of AccessControlContext with the specified array of ProtectionDomains.

Parameters
context the ProtectionDomains that are used to perform access checks in the context of this AccessControlContext
Throws
NullPointerException if context is null

Public Methods

public void checkPermission (Permission perm)

Since: API Level 1

Checks the specified permission against the vm's current security policy. The check is based on this AccessControlContext as opposed to the checkPermission(Permission) method which performs access checks based on the context of the current thread. This method returns silently if the permission is granted, otherwise an AccessControlException is thrown.

A permission is considered granted if every ProtectionDomain in this context has been granted the specified permission.

If privileged operations are on the call stack, only the ProtectionDomains from the last privileged operation are taken into account.

If inherited methods are on the call stack, the protection domains of the declaring classes are checked, not the protection domains of the classes on which the method is invoked.

Parameters
perm the permission to check against the policy
Throws
AccessControlException if the specified permission is not granted
NullPointerException if the specified permission is null

public boolean equals (Object obj)

Since: API Level 1

Compares the specified object with this AccessControlContext for equality. Returns true if the specified object is also an instance of AccessControlContext, and the two contexts encapsulate the same ProtectionDomains. The order of the ProtectionDomains is ignored by this method.

Parameters
obj object to be compared for equality with this AccessControlContext
Returns
  • true if the specified object is equal to this AccessControlContext, otherwise false

public DomainCombiner getDomainCombiner ()

Since: API Level 1

Returns the DomainCombiner associated with this AccessControlContext.

If a SecurityManager is installed, code calling this method needs the SecurityPermission getDomainCombiner to be granted, otherwise a SecurityException will be thrown.

Returns
  • the DomainCombiner associated with this AccessControlContext
Throws
SecurityException if a SecurityManager is installed and the caller does not have permission to invoke this method

public int hashCode ()

Since: API Level 1

Returns the hash code value for this AccessControlContext. Returns the same hash code for AccessControlContexts that are equal to each other as required by the general contract of hashCode().

Returns
  • the hash code value for this AccessControlContext