Class ProtectionDomain
ProtectionDomain class encapsulates the characteristics of a
domain, which encloses a set of classes whose instances are granted a set
of permissions.
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.
- API Note:
- Installing a system-wide
Policyobject is no longer supported. The current policy is always aPolicyobject that grants no permissions. - Since:
- 1.2
-
Constructor Summary
ConstructorsConstructorDescriptionProtectionDomain(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 Summary
Modifier 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 currentPolicy.toString()Convert aProtectionDomainto aString.
-
Constructor Details
-
ProtectionDomain
Creates 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.- API Note:
- Installing a system-wide
Policyobject is no longer supported. The current policy is always aPolicyobject that grants no permissions. - Parameters:
codesource- the codesource associated with this domainpermissions- the permissions granted to this domain
-
ProtectionDomain
public 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.- API Note:
- Installing a system-wide
Policyobject is no longer supported. The current policy is always aPolicyobject that grants no permissions. - Parameters:
codesource- theCodeSourceassociated with this domainpermissions- the permissions granted to this domainclassloader- theClassLoaderassociated with this domainprincipals- the array ofPrincipalobjects associated with this domain. The contents of the array are copied to protect against subsequent modification.- Since:
- 1.4
- See Also:
-
-
Method Details
-
getCodeSource
Returns theCodeSourceof this domain.- Returns:
- the
CodeSourceof this domain which may benull. - Since:
- 1.2
-
getClassLoader
Returns theClassLoaderof this domain.- Returns:
- the
ClassLoaderof this domain which may benull. - Since:
- 1.4
-
getPrincipals
Returns 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
-
getPermissions
Returns the static permissions granted to this domain.- Returns:
- the static set of permissions for this domain which may be
null. - See Also:
-
staticPermissionsOnly
public final boolean staticPermissionsOnly()Returnstrueif this domain contains only static permissions and does not check the currentPolicy.- API Note:
- Installing a system-wide
Policyobject is no longer supported. The current policy is always aPolicyobject that grants no permissions. - Returns:
trueif this domain contains only static permissions.- Since:
- 9
-
implies
Check 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.- API Note:
- Installing a system-wide
Policyobject is no longer supported. The current policy is always aPolicyobject that grants no permissions. - Parameters:
perm- the {code Permission} object to check.- Returns:
trueifpermis implied by thisProtectionDomain.
-
toString
-