Deprecated
for removal since 17.
This class is only useful in conjunction with the Security Manager, which is deprecated and subject to removal in a future release. Consequently, this class is also deprecated and subject to removal. There is no replacement for the Security Manager or this class.
Policy
object is responsible for determining whether code executing
in the Java runtime environment has permission to perform a
security-sensitive operation.
There is only one Policy
object installed in the runtime at any
given time. A Policy
object can be installed by calling the
setPolicy
method. The installed Policy
object can be
obtained by calling the getPolicy
method.
If no Policy
object has been installed in the runtime, a call to
getPolicy
installs an instance of the default Policy
implementation (a default subclass implementation of this abstract class).
The default Policy
implementation can be changed by setting the value
of the policy.provider
security property to the fully qualified
name of the desired Policy
subclass implementation. The system
class loader is used to load this class.
Application code can directly subclass Policy
to provide a custom
implementation. In addition, an instance of a Policy
object can be
constructed by invoking one of the getInstance
factory methods
with a standard type. The default policy type is "JavaPolicy".
Once a Policy
instance has been installed (either by default,
or by calling setPolicy
), the Java runtime invokes its
implies
method when it needs to
determine whether executing code (encapsulated in a ProtectionDomain)
can perform SecurityManager-protected operations. How a Policy
object retrieves its policy data is up to the Policy
implementation
itself. The policy data may be stored, for example, in a flat ASCII file,
in a serialized binary file of the Policy
class, or in a database.
The refresh
method causes the policy object to
refresh/reload its data. This operation is implementation-dependent.
For example, if the policy object stores its data in configuration files,
calling refresh
will cause it to re-read the configuration
policy files. If a refresh operation is not supported, this method does
nothing. Note that refreshed policy may not have an effect on classes
in a particular ProtectionDomain. This is dependent on the policy
provider's implementation of the implies
method and its PermissionCollection caching strategy.
java.security.Provider
, java.security.ProtectionDomain
, java.security.Permission
, security properties
Modifier and Type | Class and Description |
---|---|
public static interface | Policy.
Deprecated
for removal since 17. This class is only useful in conjunction with
the Security Manager, which is
deprecated and subject to removal in a future release.
This represents a marker interface for Policy parameters.
|
private static class | Policy.
References Deprecated
This subclass is returned by the getInstance calls.
Policy is deprecated or references (maybe indirectly) at least one deprecated element.
|
private static class | |
private static class | Policy.
This class represents a read-only empty PermissionCollection object that
is returned from the |
Modifier and Type | Field and Description |
---|---|
private static final Debug | |
private static final String | |
private WeakHashMap | |
private static volatile Policy. | |
public static final PermissionCollection | UNSUPPORTED_EMPTY_COLLECTION
A read-only empty PermissionCollection instance. |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
private void | addStaticPerms(PermissionCollection perms, PermissionCollection statics)
add static permissions to provided permission collection |
private static void | |
public static Policy | Returns: the newPolicy objectthe specified Policy type. See the Policy section in the
Java Security Standard Algorithm Names Specification
for a list of standard Policy types. type, Policy.parameters for the paramsPolicy , which may be
null .
References Deprecated
Policy.Parameters and Policy are deprecated or reference (maybe indirectly) at least one deprecated element.
Returns a Policy object of the specified type. |
public static Policy | Returns: the newPolicy objectthe specified Policy type. See the Policy section in the
Java Security Standard Algorithm Names Specification
for a list of standard Policy types. type, Policy.parameters for the params,Policy , which may be
null .the provider. provider)
References Deprecated
Policy.Parameters and Policy are deprecated or reference (maybe indirectly) at least one deprecated element.
Returns a |
public static Policy | Returns: the newPolicy objectthe specified Policy type. See the Policy section in the
Java Security Standard Algorithm Names Specification
for a list of standard Policy types. type, Policy.parameters for the params,Policy , which may be
null .the provider)Provider .
References Deprecated
Policy.Parameters and Policy are deprecated or reference (maybe indirectly) at least one deprecated element.
Returns a |
public Policy. | Returns: Policy parameters, or null .
References Deprecated
Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.
Return |
public PermissionCollection | Returns: a set of permissions granted to the specified CodeSource. If this operation is supported, the returned set of permissions must be a new mutable instance and it must support heterogeneous Permission types. If this operation is not supported, Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.the CodeSource to which the returned
PermissionCollection has been granted. codesource)Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource. |
public PermissionCollection | Returns: a set of permissions granted to the specified ProtectionDomain. If this operation is supported, the returned set of permissions must be a new mutable instance and it must support heterogeneous Permission types. If this operation is not supported, Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.the ProtectionDomain to which the returned
PermissionCollection has been granted. domain)Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain. |
public static Policy | |
pack-priv static Policy | Returns: the installedPolicy .
References Deprecated
Policy is deprecated or references (maybe indirectly) at least one deprecated element.
Returns the installed |
public Provider | |
public String | |
private static Policy | handleException(NoSuchAlgorithmException nsae)
References Deprecated
Policy is deprecated or references (maybe indirectly) at least one deprecated element.
|
public boolean | Returns: true if "permission" is a proper subset of a permission
granted to this ProtectionDomain.the ProtectionDomain to test domain, Permission the Permission object to be tested for implication. permission)Evaluates the global policy for the permissions granted to the ProtectionDomain and tests whether the permission is granted. |
private static void | initPolicy(final Policy p)
References Deprecated
Policy is deprecated or references (maybe indirectly) at least one deprecated element.
Initialize superclass state such that a legacy provider can handle queries for itself. |
pack-priv static boolean | |
private static Policy | loadPolicyProvider()
References Deprecated
Policy is deprecated or references (maybe indirectly) at least one deprecated element.
Loads and instantiates a Policy implementation specified by the policy.provider security property. |
public void | |
public static void |
debug | back to summary |
---|---|
private static final Debug debug |
DEFAULT_POLICY | back to summary |
---|---|
private static final String DEFAULT_POLICY |
pdMapping | back to summary |
---|---|
private WeakHashMap<ProtectionDomain. |
policyInfo | back to summary |
---|---|
private static volatile Policy. |
UNSUPPORTED_EMPTY_COLLECTION | back to summary |
---|---|
public static final PermissionCollection UNSUPPORTED_EMPTY_COLLECTION A read-only empty PermissionCollection instance.
|
Policy | back to summary |
---|---|
public Policy() Constructor for subclasses to call. |
addStaticPerms | back to summary |
---|---|
private void addStaticPerms(PermissionCollection perms, PermissionCollection statics) add static permissions to provided permission collection |
checkPermission | back to summary |
---|---|
private static void checkPermission(String type) |
getInstance | back to summary |
---|---|
public static Policy getInstance(String type, Policy. References Deprecated
See corresponding docs for further information. Returns a Policy object of the specified type. This method traverses the list of registered security providers,
starting with the most preferred provider.
A new Note that the list of registered providers may be retrieved via
the Implementation Note The JDK Reference Implementation additionally uses the
|
getInstance | back to summary |
---|---|
public static Policy getInstance(String type, Policy. References Deprecated
See corresponding docs for further information. Returns a A new Note that the list of registered providers may be retrieved via
the
|
getInstance | back to summary |
---|---|
public static Policy getInstance(String type, Policy. References Deprecated
See corresponding docs for further information. Returns a A new
|
getParameters | back to summary |
---|---|
public Policy. References Deprecated
See corresponding docs for further information. Return This
|
getPermissions | back to summary |
---|---|
public PermissionCollection getPermissions(CodeSource codesource) Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource. Applications are discouraged from calling this method
since this operation may not be supported by all policy implementations.
Applications should solely rely on the The default implementation of this method returns Policy.UNSUPPORTED_EMPTY_COLLECTION. This method can be overridden if the policy implementation can return a set of permissions granted to a CodeSource.
|
getPermissions | back to summary |
---|---|
public PermissionCollection getPermissions(ProtectionDomain domain) Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain. Applications are discouraged from calling this method
since this operation may not be supported by all policy implementations.
Applications should rely on the The default implementation of this method first retrieves
the permissions returned via This method can be overridden if the policy implementation supports returning a set of permissions granted to a ProtectionDomain.
|
getPolicy | back to summary |
---|---|
public static Policy getPolicy()
References Deprecated
See corresponding docs for further information. Returns the installed
|
getPolicyNoCheck | back to summary |
---|---|
pack-priv static Policy getPolicyNoCheck()
References Deprecated
See corresponding docs for further information. Returns the installed
|
getProvider | back to summary |
---|---|
public Provider getProvider() Return the This
|
getType | back to summary |
---|---|
public String getType() Return the type of this This
|
handleException | back to summary |
---|---|
private static Policy handleException(NoSuchAlgorithmException nsae) throws NoSuchAlgorithmException
References Deprecated
See corresponding docs for further information. |
implies | back to summary |
---|---|
public boolean implies(ProtectionDomain domain, Permission permission) Evaluates the global policy for the permissions granted to the ProtectionDomain and tests whether the permission is granted.
|
initPolicy | back to summary |
---|---|
private static void initPolicy(final Policy p)
References Deprecated
See corresponding docs for further information. Initialize superclass state such that a legacy provider can handle queries for itself.
|
isSet | back to summary |
---|---|
pack-priv static boolean isSet() package private for AccessControlContext and ProtectionDomain |
loadPolicyProvider | back to summary |
---|---|
private static Policy loadPolicyProvider()
References Deprecated
See corresponding docs for further information. Loads and instantiates a Policy implementation specified by the policy.provider security property. Note that this method should only be called by getPolicyNoCheck and from within a synchronized block with an intrinsic lock on the Policy.class. |
refresh | back to summary |
---|---|
public void refresh() Refreshes/reloads the policy configuration. The behavior of this method
depends on the implementation. For example, calling The default implementation of this method does nothing. This method should be overridden if a refresh operation is supported by the policy implementation. |
setPolicy | back to summary |
---|---|
public static void setPolicy(Policy p)
References Deprecated
See corresponding docs for further information. Sets the system-wide
|
Deprecated
for removal since 17.
This class is only useful in conjunction with the Security Manager, which is deprecated and subject to removal in a future release. Consequently, this class is also deprecated and subject to removal. There is no replacement for the Security Manager or this class.
References Deprecated
Policy
is deprecated or references (maybe indirectly) at least one deprecated element.
See corresponding docs for further information.
Policy
calls are delegated to the underlying PolicySpi
.
Modifier and Type | Field and Description |
---|---|
private Provider | |
private Policy. | params
References Deprecated
Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.
|
private PolicySpi | |
private String |
Access | Constructor and Description |
---|---|
private | PolicyDelegate(PolicySpi spi, Provider p, String type, Policy.
References Deprecated
PolicySpi and Policy.Parameters are deprecated or reference (maybe indirectly) at least one deprecated element.
|
Modifier and Type | Method and Description |
---|---|
public Policy. | getParameters()
Overrides java.
References Deprecated
Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.
Return |
public PermissionCollection | getPermissions(CodeSource
the CodeSource to which the returned
PermissionCollection has been granted. codesource)Overrides java. Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource. |
public PermissionCollection | getPermissions(ProtectionDomain
the ProtectionDomain to which the returned
PermissionCollection has been granted. domain)Overrides java. Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain. |
public Provider | |
public String | |
public boolean | implies(ProtectionDomain
the ProtectionDomain to test domain, Permission the Permission object to be tested for implication. perm)Overrides java. Evaluates the global policy for the permissions granted to the ProtectionDomain and tests whether the permission is granted. |
public void |
p | back to summary |
---|---|
private Provider p |
params | back to summary |
---|---|
private Policy. References Deprecated
See corresponding docs for further information. |
spi | back to summary |
---|---|
private PolicySpi spi
References Deprecated
See corresponding docs for further information.
|
type | back to summary |
---|---|
private String type |
PolicyDelegate | back to summary |
---|---|
private PolicyDelegate(PolicySpi spi, Provider p, String type, Policy. References Deprecated
See corresponding docs for further information. |
getParameters | back to summary |
---|---|
public Policy. Overrides java. Doc from java. References Deprecated
See corresponding docs for further information. Return This
|
getPermissions | back to summary |
---|---|
public PermissionCollection getPermissions(CodeSource codesource) Overrides java. Doc from java. Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource. Applications are discouraged from calling this method
since this operation may not be supported by all policy implementations.
Applications should solely rely on the The default implementation of this method returns Policy.UNSUPPORTED_EMPTY_COLLECTION. This method can be overridden if the policy implementation can return a set of permissions granted to a CodeSource.
|
getPermissions | back to summary |
---|---|
public PermissionCollection getPermissions(ProtectionDomain domain) Overrides java. Doc from java. Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain. Applications are discouraged from calling this method
since this operation may not be supported by all policy implementations.
Applications should rely on the The default implementation of this method first retrieves
the permissions returned via This method can be overridden if the policy implementation supports returning a set of permissions granted to a ProtectionDomain.
|
getProvider | back to summary |
---|---|
public Provider getProvider() Overrides java. Doc from java. Return the This |
getType | back to summary |
---|---|
public String getType() Overrides java. Doc from java. Return the type of this This |
implies | back to summary |
---|---|
public boolean implies(ProtectionDomain domain, Permission perm) Overrides java. Doc from java. Evaluates the global policy for the permissions granted to the ProtectionDomain and tests whether the permission is granted.
|
refresh | back to summary |
---|---|
public void refresh() Overrides java. Doc from java. Refreshes/reloads the policy configuration. The behavior of this method
depends on the implementation. For example, calling The default implementation of this method does nothing. This method should be overridden if a refresh operation is supported by the policy implementation.
|
Modifier and Type | Field and Description |
---|---|
pack-priv final boolean | |
pack-priv final Policy |
Access | Constructor and Description |
---|---|
pack-priv | PolicyInfo(Policy policy, boolean initialized)
References Deprecated
Policy is deprecated or references (maybe indirectly) at least one deprecated element.
|
initialized | back to summary |
---|---|
pack-priv final boolean initialized |
policy | back to summary |
---|---|
pack-priv final Policy policy
References Deprecated
See corresponding docs for further information. |
PolicyInfo | back to summary |
---|---|
pack-priv PolicyInfo(Policy policy, boolean initialized)
References Deprecated
See corresponding docs for further information. |
getPermissions(CodeSource)
and
getPermissions(ProtectionDomain)
methods in the Policy
class when those operations are not
supported by the Policy implementation.
Modifier and Type | Field and Description |
---|---|
private Permissions | |
private static final long |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public void | add(Permission
the Permission object to add. permission)Implements abstract java. Adds a permission object to the current collection of permission objects. |
public Enumeration | Returns: an enumeration of all the Permissions.Implements abstract java. Returns an enumeration of all the Permission objects in the collection. |
public boolean | Returns: true if "permission" is implied by the permissions in
the collection, false if not.the Permission object to compare. permission)Implements abstract java. Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection. |
perms | back to summary |
---|---|
private Permissions perms |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Hides java. |
UnsupportedEmptyCollection | back to summary |
---|---|
public UnsupportedEmptyCollection() Create a read-only empty PermissionCollection object. |
add | back to summary |
---|---|
public void add(Permission permission) Implements abstract java. Adds a permission object to the current collection of permission objects.
|
elements | back to summary |
---|---|
public Enumeration Implements abstract java. Returns an enumeration of all the Permission objects in the collection.
|
implies | back to summary |
---|---|
public boolean implies(Permission permission) Implements abstract java. Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.
|