- java.lang.Object
-
- java.security.AccessControlContext
-
public final class AccessControlContext extends Object
An 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 thecheckPermission
method in the AccessController class, with one difference: The AccessControlContextcheckPermission
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. ThegetContext
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)
- See Also:
AccessController
-
-
Constructor Summary
Constructors Constructor and Description AccessControlContext(AccessControlContext acc, DomainCombiner combiner)
Create a newAccessControlContext
with the givenAccessControlContext
andDomainCombiner
.AccessControlContext(ProtectionDomain[] context)
Create an AccessControlContext with the given array of ProtectionDomains.
-
Method Summary
Methods Modifier and Type Method and Description void
checkPermission(Permission perm)
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(Object obj)
Checks two AccessControlContext objects for equality.DomainCombiner
getDomainCombiner()
Get theDomainCombiner
associated with thisAccessControlContext
.int
hashCode()
Returns the hash code value for this context.
-
-
-
Constructor Detail
-
AccessControlContext
public AccessControlContext(ProtectionDomain[] context)
Create an AccessControlContext with the given array of ProtectionDomains. Context must not be null. Duplicate domains will be removed from the context.- Parameters:
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.- Throws:
NullPointerException
- ifcontext
isnull
-
AccessControlContext
public AccessControlContext(AccessControlContext acc, DomainCombiner combiner)
Create a newAccessControlContext
with the givenAccessControlContext
andDomainCombiner
. This constructor associates the providedDomainCombiner
with the providedAccessControlContext
.- Parameters:
acc
- theAccessControlContext
associated with the providedDomainCombiner
.combiner
- theDomainCombiner
to be associated with the providedAccessControlContext
.- Throws:
NullPointerException
- if the providedcontext
isnull
.SecurityException
- if a security manager is installed and the caller does not have the "createAccessControlContext"SecurityPermission
- Since:
- 1.3
-
-
Method Detail
-
getDomainCombiner
public DomainCombiner getDomainCombiner()
Get theDomainCombiner
associated with thisAccessControlContext
.- Returns:
- the
DomainCombiner
associated with thisAccessControlContext
, ornull
if there is none. - Throws:
SecurityException
- if a security manager is installed and the caller does not have the "getDomainCombiner"SecurityPermission
- Since:
- 1.3
-
checkPermission
public void checkPermission(Permission perm) throws AccessControlException
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. 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.
- Parameters:
perm
- the requested permission.- Throws:
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.
-
equals
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.- Overrides:
equals
in classObject
- Parameters:
obj
- the object we are testing for equality with this object.- Returns:
- true if obj is an AccessControlContext, and has the same set of ProtectionDomains as this context, false otherwise.
- See Also:
Object.hashCode()
,HashMap
-
hashCode
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.- Overrides:
hashCode
in classObject
- Returns:
- a hash code value for this context.
- See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
22/12/2024 10:31:23 Cette version de la page est en cache (à la date du 22/12/2024 10:31:23) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 31/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/security/AccessControlContext.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.