Module java.base
Package java.security

Class AccessControlContext


  • public final class AccessControlContext
    extends Object
    An AccessControlContext encapsulates the information which is needed by class AccessController to detect if a Permission would be granted at a particular point in a programs execution.
    • Constructor Detail

      • AccessControlContext

        public AccessControlContext​(ProtectionDomain[] fromContext)
        Constructs a new instance of this class given an array of protection domains.
        Parameters:
        fromContext - the array of ProtectionDomain
        Throws:
        NullPointerException - if fromContext is null
      • AccessControlContext

        public AccessControlContext​(AccessControlContext acc,
                                    DomainCombiner combiner)
        Constructs a new instance of this class given a context and a DomainCombiner
        Parameters:
        acc - the AccessControlContext
        combiner - the DomainCombiner
        Throws:
        AccessControlException - thrown when the caller doesn't have the "createAccessControlContext" SecurityPermission
        NullPointerException - if the provided context is null.
    • Method Detail

      • checkPermission

        public void checkPermission​(Permission perm)
                             throws AccessControlException
        Checks if the permission perm is allowed in this context. All ProtectionDomains must grant the permission for it to be granted.
        Parameters:
        perm - java.security.Permission the permission to check
        Throws:
        AccessControlException - thrown when perm is not granted.
        NullPointerException - if perm is null
      • equals

        public boolean equals​(Object o)
        Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison. In this case, they must both be AccessControlContexts and contain the same protection domains.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare with this object
        Returns:
        true if the object is the same as this object false if it is different from this object
        See Also:
        hashCode()
      • hashCode

        public int hashCode()
        Answers an integer hash code for the receiver. Any two objects which answer true when passed to equals must answer the same value for this method.
        Overrides:
        hashCode in class Object
        Returns:
        the receiver's hash
        See Also:
        equals(java.lang.Object)
      • getDomainCombiner

        public DomainCombiner getDomainCombiner()
        Answers the DomainCombiner for the receiver.
        Returns:
        the DomainCombiner or null
        Throws:
        AccessControlException - thrown when the caller doesn't have the "getDomainCombiner" SecurityPermission