java.security
Class ProtectionDomain

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.ProtectionDomain

public class ProtectionDomain
extends Object sample code for java.lang.Object definition code for java.lang.Object

This 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.


Constructor Summary
ProtectionDomain sample code for java.security.ProtectionDomain.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection) definition code for java.security.ProtectionDomain.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection) (CodeSource sample code for java.security.CodeSource definition code for java.security.CodeSource  codesource, PermissionCollection sample code for java.security.PermissionCollection definition code for java.security.PermissionCollection  permissions)
          Creates a new ProtectionDomain with the given CodeSource and Permissions.
ProtectionDomain sample code for java.security.ProtectionDomain.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection, java.lang.ClassLoader, java.security.Principal[]) definition code for java.security.ProtectionDomain.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection, java.lang.ClassLoader, java.security.Principal[]) (CodeSource sample code for java.security.CodeSource definition code for java.security.CodeSource  codesource, PermissionCollection sample code for java.security.PermissionCollection definition code for java.security.PermissionCollection  permissions, ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  classloader, Principal sample code for java.security.Principal definition code for java.security.Principal [] principals)
          Creates a new ProtectionDomain qualified by the given CodeSource, Permissions, ClassLoader and array of Principals.
 
Method Summary
 ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader getClassLoader sample code for java.security.ProtectionDomain.getClassLoader() definition code for java.security.ProtectionDomain.getClassLoader() ()
          Returns the ClassLoader of this domain.
 CodeSource sample code for java.security.CodeSource definition code for java.security.CodeSource getCodeSource sample code for java.security.ProtectionDomain.getCodeSource() definition code for java.security.ProtectionDomain.getCodeSource() ()
          Returns the CodeSource of this domain.
 PermissionCollection sample code for java.security.PermissionCollection definition code for java.security.PermissionCollection getPermissions sample code for java.security.ProtectionDomain.getPermissions() definition code for java.security.ProtectionDomain.getPermissions() ()
          Returns the static permissions granted to this domain.
 Principal sample code for java.security.Principal definition code for java.security.Principal [] getPrincipals sample code for java.security.ProtectionDomain.getPrincipals() definition code for java.security.ProtectionDomain.getPrincipals() ()
          Returns an array of principals for this domain.
 boolean implies sample code for java.security.ProtectionDomain.implies(java.security.Permission) definition code for java.security.ProtectionDomain.implies(java.security.Permission) (Permission sample code for java.security.Permission definition code for java.security.Permission  permission)
          Check and see if this ProtectionDomain implies the permissions expressed in the Permission object.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.security.ProtectionDomain.toString() definition code for java.security.ProtectionDomain.toString() ()
          Convert a ProtectionDomain to a String.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

ProtectionDomain sample code for java.security.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection) definition code for java.security.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection)

public ProtectionDomain(CodeSource sample code for java.security.CodeSource definition code for java.security.CodeSource  codesource,
                        PermissionCollection sample code for java.security.PermissionCollection definition code for java.security.PermissionCollection  permissions)
Creates a new ProtectionDomain with the given CodeSource and Permissions. If the permissions object is not null, then setReadOnly()) will be called on the passed in Permissions object. The only permissions granted to this domain are the ones specified; the current Policy will not be consulted.

Parameters:
codesource - the codesource associated with this domain
permissions - the permissions granted to this domain

ProtectionDomain sample code for java.security.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection, java.lang.ClassLoader, java.security.Principal[]) definition code for java.security.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection, java.lang.ClassLoader, java.security.Principal[])

public ProtectionDomain(CodeSource sample code for java.security.CodeSource definition code for java.security.CodeSource  codesource,
                        PermissionCollection sample code for java.security.PermissionCollection definition code for java.security.PermissionCollection  permissions,
                        ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  classloader,
                        Principal sample code for java.security.Principal definition code for java.security.Principal [] principals)
Creates a new ProtectionDomain qualified by the given CodeSource, Permissions, ClassLoader and array of Principals. If the permissions object is not null, then setReadOnly() will be called on the passed in Permissions object. The permissions granted to this domain are dynamic; 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 ClassLoaders sample code for java.security.SecureClassLoader definition code for java.security.SecureClassLoader and DomainCombiners sample code for java.security.DomainCombiner definition code for java.security.DomainCombiner which delegate to Policy to actively associate the permissions granted to this domain. This constructor affords the Policy provider the opportunity to augment the supplied PermissionCollection to reflect policy changes.

Parameters:
codesource - the CodeSource associated with this domain
permissions - the permissions granted to this domain
classloader - the ClassLoader associated with this domain
principals - the array of Principals associated with this domain. The contents of the array are copied to protect against subsequent modification.
Since:
1.4
See Also:
Policy.refresh() sample code for java.security.Policy.refresh() definition code for java.security.Policy.refresh() , Policy.getPermissions(ProtectionDomain) sample code for java.security.Policy.getPermissions(java.security.ProtectionDomain) definition code for java.security.Policy.getPermissions(java.security.ProtectionDomain)
Method Detail

getCodeSource sample code for java.security.ProtectionDomain.getCodeSource() definition code for java.security.ProtectionDomain.getCodeSource()

public final CodeSource sample code for java.security.CodeSource definition code for java.security.CodeSource  getCodeSource()
Returns the CodeSource of this domain.

Returns:
the CodeSource of this domain which may be null.
Since:
1.2

getClassLoader sample code for java.security.ProtectionDomain.getClassLoader() definition code for java.security.ProtectionDomain.getClassLoader()

public final ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  getClassLoader()
Returns the ClassLoader of this domain.

Returns:
the ClassLoader of this domain which may be null.
Since:
1.4

getPrincipals sample code for java.security.ProtectionDomain.getPrincipals() definition code for java.security.ProtectionDomain.getPrincipals()

public final Principal sample code for java.security.Principal definition code for java.security.Principal [] 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 sample code for java.security.ProtectionDomain.getPermissions() definition code for java.security.ProtectionDomain.getPermissions()

public final PermissionCollection sample code for java.security.PermissionCollection definition code for java.security.PermissionCollection  getPermissions()
Returns the static permissions granted to this domain.

Returns:
the static set of permissions for this domain which may be null.
See Also:
Policy.refresh() sample code for java.security.Policy.refresh() definition code for java.security.Policy.refresh() , Policy.getPermissions(ProtectionDomain) sample code for java.security.Policy.getPermissions(java.security.ProtectionDomain) definition code for java.security.Policy.getPermissions(java.security.ProtectionDomain)

implies sample code for java.security.ProtectionDomain.implies(java.security.Permission) definition code for java.security.ProtectionDomain.implies(java.security.Permission)

public boolean implies(Permission sample code for java.security.Permission definition code for java.security.Permission  permission)
Check and see if this ProtectionDomain implies the permissions expressed in the Permission 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 ProtectionDomain was constructed to a statically bound sample code for java.security.ProtectionDomain.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection) definition code for java.security.ProtectionDomain.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection) PermissionCollection then the permission will only be checked against the PermissionCollection supplied at construction.

However, if the ProtectionDomain was constructed with the constructor variant which supports dynamically binding sample code for java.security.ProtectionDomain.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection, java.lang.ClassLoader, java.security.Principal[]) definition code for java.security.ProtectionDomain.ProtectionDomain(java.security.CodeSource, java.security.PermissionCollection, java.lang.ClassLoader, java.security.Principal[]) permissions, then the permission will be checked against the combination of the PermissionCollection supplied at construction and the current Policy binding.

Parameters:
permission - the Permission object to check.
Returns:
true if "permission" is implicit to this ProtectionDomain.

toString sample code for java.security.ProtectionDomain.toString() definition code for java.security.ProtectionDomain.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Convert a ProtectionDomain to a String.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of the object.