| public abstract class java.security Policy
|
Java SE 6 |
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 (in the Java security properties
file) to the fully qualified name of the desired Policy subclass
implementation. The Java security properties file is located in the
file named <JAVA_HOME>/lib/security/java.security.
<JAVA_HOME> refers to the value of the java.home system property,
and specifies the directory where the JRE is installed.
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".
See Appendix A in the
Java Cryptography Architecture API Specification & Reference
for a list of standard Policy types.
Once a Policy instance has been installed (either by default, or by
calling setPolicy),
the Java runtime invokes its implies 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.
| version | 1.102, 04/21/06 |
| See also | java.security.Provider, java.security.ProtectionDomain, java.security.Permission |
| Fields | |||
|---|---|---|---|
| final public static PermissionCollection | UNSUPPORTED_EMPTY_COLLECTION Details
A read-only empty PermissionCollection instance.
| ||
| Constructors | |
|---|---|
| public | Policy() |
| Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| public boolean | implies(ProtectionDomain domain, Permission permission) Details
Evaluates the global policy for the permissions granted to
the ProtectionDomain and tests whether the permission is
granted.
| ||||||||||
| public void | refresh() Refreshes/reloads the policy configuration. The behavior of this method depends on the implementation. For example, calling refresh
on a file-based policy will cause the file to be re-read.
The default implementation of this method does nothing. This method should be overridden if a refresh operation is supported by the policy implementation. | ||||||||||
| Properties | |||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public static Policy | getInstance(String type, Policy.Parameters params) throws NoSuchAlgorithmException Details
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 Policy object encapsulating the PolicySpi implementation from the first Provider that supports the specified type is returned. Note that the list of registered providers may be retrieved via
the
| ||||||||||||||||||||||
| public static Policy | getInstance(String type, Policy.Parameters params, String provider) throws NoSuchProviderException, NoSuchAlgorithmException Details
Returns a Policy object of the specified type.
A new Policy object encapsulating the PolicySpi implementation from the specified provider is returned. The specified provider must be registered in the provider list. Note that the list of registered providers may be retrieved via
the
| ||||||||||||||||||||||
| public static Policy | getInstance(String type, Policy.Parameters params, Provider provider) throws NoSuchAlgorithmException Details
Returns a Policy object of the specified type.
A new Policy object encapsulating the PolicySpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.
| ||||||||||||||||||||||
| public Policy.Parameters | getParameters() Details
Return Policy parameters.
This Policy instance will only have parameters if it
was obtained via a call to
| ||||||||||||||||||||||
| public PermissionCollection | getPermissions(CodeSource codesource) Details
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.
| ||||||||||||||||||||||
| public PermissionCollection | getPermissions(ProtectionDomain domain) Details
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.
| ||||||||||||||||||||||
| public static void | setPolicy(Policy p) Details
Sets the system-wide Policy object. This method first calls
SecurityManager.checkPermission with a
SecurityPermission("setPolicy")
permission to ensure it's ok to set the Policy.
| ||||||||||||||||||||||
| public static Policy | getPolicy() Details
Returns the installed Policy object. This value should not be cached,
as it may be changed by a call to setPolicy.
This method first calls
SecurityManager.checkPermission with a
SecurityPermission("getPolicy") permission
to ensure it's ok to get the Policy object..
| ||||||||||||||||||||||
| public Provider | getProvider() Details
Return the Provider of this Policy.
This Policy instance will only have a Provider if it
was obtained via a call to
| ||||||||||||||||||||||
| public String | getType() Details
Return the type of this Policy.
This Policy instance will only have a type if it
was obtained via a call to
| ||||||||||||||||||||||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2009 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|