Name
ProtectionDomain
Synopsis
This
class represents a “protection
domain”: the set of permissions associated with code
based on its source, and optionally, the identities of the users on
whose behalf the code is running. Use the
getProtectionDomain(
)
of a Class
object to obtain the
ProtectionDomain
that the class is part of.
Prior to Java 1.4, a ProtectionDomain
simply
associates a CodeSource
with the
PermissionCollection
granted to code from that
source by a Policy
. The set of permissions is
static, and the implies(
)
method checks to see whether the specified
Permission
is implied by any of the permissions
granted to this ProtectionDomain
.
In Java 1.4 and later, a ProtectionDomain
can also
be created with the four-argument constructor which associates a
PermissionCollection
with a
ClassLoader
and an array of
Principal
objects in addition to a
CodeSource
. A ProtectionDomain
of this sort represents permisssions granted to code loaded from a
specified source, through a specified class loader, and running under
the auspices of one or more specified principals. When a
ProtectionDomain
is instantiated with this
four-argument constructor, the
PermissionCollection
is not static, and the
implies( )
method calls the implies(
)
method of the current Policy
object
before checking the specified collection of permissions. This allows
security policies to be updated (for example to add new permissions
for specific users) without having to restart long-running programs
such as servers.
public ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.