ProtectionDomain class encapsulates the characteristics of a
 domain, which encloses a set of classes whose instances are granted a set
 of permissions when being executed on behalf of a given set of Principals.
 
 A static set of permissions can be bound to a ProtectionDomain
 when it is constructed; such permissions are granted to the domain
 regardless of the policy in force. However, to support dynamic security
 policies, a ProtectionDomain can also be constructed such that it
 is dynamically mapped to a set of permissions by the current policy whenever
 a permission is checked.
- Since:
- 1.2
- 
Constructor SummaryConstructorsConstructorDescriptionProtectionDomain(CodeSource codesource, PermissionCollection permissions) Creates a newProtectionDomainwith the givenCodeSourceand permissions.ProtectionDomain(CodeSource codesource, PermissionCollection permissions, ClassLoader classloader, Principal[] principals) Creates a newProtectionDomainqualified by the givenCodeSource, permissions,ClassLoaderand array of principals.
- 
Method SummaryModifier and TypeMethodDescriptionfinal ClassLoaderReturns theClassLoaderof this domain.final CodeSourceReturns theCodeSourceof this domain.final PermissionCollectionReturns the static permissions granted to this domain.final Principal[]Returns an array of principals for this domain.booleanimplies(Permission perm) Check and see if thisProtectionDomainimplies the permissions expressed in thePermissionobject.final booleanReturnstrueif this domain contains only static permissions and does not check the currentPolicyat the time of permission checking.toString()Convert aProtectionDomainto aString.
- 
Constructor Details- 
ProtectionDomainCreates a newProtectionDomainwith the givenCodeSourceand permissions. If permissions is notnull, thensetReadOnly()will be called on the passed in permissions.The permissions granted to this domain are static, i.e. invoking the staticPermissionsOnly()method returnstrue. They contain only the ones passed to this constructor and the current policy will not be consulted.- Parameters:
- codesource- the codesource associated with this domain
- permissions- the permissions granted to this domain
 
- 
ProtectionDomainpublic ProtectionDomain(CodeSource codesource, PermissionCollection permissions, ClassLoader classloader, Principal[] principals) Creates a newProtectionDomainqualified by the givenCodeSource, permissions,ClassLoaderand array of principals. If permissions is notnull, thensetReadOnly()will be called on the passed in permissions.The permissions granted to this domain are dynamic, i.e. invoking the staticPermissionsOnly()method returnsfalse. They include both the static permissions passed to this constructor, and any permissions granted to this domain by the current policy at the time a permission is checked.This constructor is typically used by ClassLoadersandDomainCombinerswhich delegate to thePolicyobject to actively associate the permissions granted to this domain. This constructor affords the policy provider the opportunity to augment the suppliedPermissionCollectionto reflect policy changes.- Parameters:
- codesource- the- CodeSourceassociated with this domain
- permissions- the permissions granted to this domain
- classloader- the- ClassLoaderassociated with this domain
- principals- the array of- Principalobjects associated with this domain. The contents of the array are copied to protect against subsequent modification.
- Since:
- 1.4
- See Also:
 
 
- 
- 
Method Details- 
getCodeSourceReturns theCodeSourceof this domain.- Returns:
- the CodeSourceof this domain which may benull.
- Since:
- 1.2
 
- 
getClassLoaderReturns theClassLoaderof this domain.- Returns:
- the ClassLoaderof this domain which may benull.
- Since:
- 1.4
 
- 
getPrincipalsReturns an array of principals for this domain.- Returns:
- a non-null array of principals for this domain. Returns a new array each time this method is called.
- Since:
- 1.4
 
- 
getPermissionsReturns the static permissions granted to this domain.- Returns:
- the static set of permissions for this domain which may be
 null.
- See Also:
 
- 
staticPermissionsOnlypublic final boolean staticPermissionsOnly()Returnstrueif this domain contains only static permissions and does not check the currentPolicyat the time of permission checking.- Returns:
- trueif this domain contains only static permissions.
- Since:
- 9
 
- 
impliesCheck and see if thisProtectionDomainimplies the permissions expressed in thePermissionobject.The set of permissions evaluated is a function of whether the ProtectionDomainwas constructed with a static set of permissions or it was bound to a dynamically mapped set of permissions.If the staticPermissionsOnly()method returnstrue, then the permission will only be checked against thePermissionCollectionsupplied at construction.Otherwise, the permission will be checked against the combination of the PermissionCollectionsupplied at construction and the current policy binding.- Parameters:
- perm- the {code Permission} object to check.
- Returns:
- trueif- permis implied by this- ProtectionDomain.
 
- 
toStringConvert aProtectionDomainto aString.
 
-