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
Policy
object is no longer supported. The current policy is always aPolicy
object that grants no permissions. - Since:
- 1.2
-
Constructor Summary
ConstructorDescriptionProtectionDomain
(CodeSource codesource, PermissionCollection permissions) Creates a newProtectionDomain
with the givenCodeSource
and permissions.ProtectionDomain
(CodeSource codesource, PermissionCollection permissions, ClassLoader classloader, Principal[] principals) Creates a newProtectionDomain
qualified by the givenCodeSource
, permissions,ClassLoader
and array of principals. -
Method Summary
Modifier and TypeMethodDescriptionfinal ClassLoader
Returns theClassLoader
of this domain.final CodeSource
Returns theCodeSource
of this domain.final PermissionCollection
Returns the static permissions granted to this domain.final Principal[]
Returns an array of principals for this domain.boolean
implies
(Permission perm) Check and see if thisProtectionDomain
implies the permissions expressed in thePermission
object.final boolean
Returnstrue
if this domain contains only static permissions and does not check the currentPolicy
.toString()
Convert aProtectionDomain
to aString
.
-
Constructor Details
-
ProtectionDomain
Creates a newProtectionDomain
with the givenCodeSource
and 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
Policy
object is no longer supported. The current policy is always aPolicy
object 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 newProtectionDomain
qualified by the givenCodeSource
, permissions,ClassLoader
and 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
Policy
object is no longer supported. The current policy is always aPolicy
object that grants no permissions. - Parameters:
codesource
- theCodeSource
associated with this domainpermissions
- the permissions granted to this domainclassloader
- theClassLoader
associated with this domainprincipals
- the array ofPrincipal
objects 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 theCodeSource
of this domain.- Returns:
- the
CodeSource
of this domain which may benull
. - Since:
- 1.2
-
getClassLoader
Returns theClassLoader
of this domain.- Returns:
- the
ClassLoader
of 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()Returnstrue
if this domain contains only static permissions and does not check the currentPolicy
.- API Note:
- Installing a system-wide
Policy
object is no longer supported. The current policy is always aPolicy
object that grants no permissions. - Returns:
true
if this domain contains only static permissions.- Since:
- 9
-
implies
Check and see if thisProtectionDomain
implies the permissions expressed in thePermission
object.The set of permissions evaluated is a function of whether the
ProtectionDomain
was 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 thePermissionCollection
supplied at construction.Otherwise, the permission will be checked against the combination of the
PermissionCollection
supplied at construction and the current policy.- API Note:
- Installing a system-wide
Policy
object is no longer supported. The current policy is always aPolicy
object that grants no permissions. - Parameters:
perm
- the {code Permission} object to check.- Returns:
true
ifperm
is implied by thisProtectionDomain
.
-
toString
-