@Deprecated(since="17", forRemoval=true) public abstract class Policy extends Object
Policy object was responsible for determining whether code executing in the Java runtime environment had permission to perform a security-sensitive operation. This feature no longer exists.| Modifier and Type | Class | Description |
|---|---|---|
static interface |
Policy.Parameters |
Deprecated, for removal: This API element is subject to removal in a future version. This class was only useful in conjunction with the Security Manager, which is no longer supported. |
| Modifier and Type | Field | Description |
|---|---|---|
static final PermissionCollection |
UNSUPPORTED_EMPTY_COLLECTION |
Deprecated, for removal: This API element is subject to removal in a future version. A read-only empty PermissionCollection instance. |
| Constructor | Description |
|---|---|
Policy() |
Deprecated, for removal: This API element is subject to removal in a future version. Constructor for subclasses to call. |
| Modifier and Type | Method | Description |
|---|---|---|
static Policy |
getInstance |
Deprecated, for removal: This API element is subject to removal in a future version. Returns a Policy object of the specified type. |
static Policy |
getInstance |
Deprecated, for removal: This API element is subject to removal in a future version. Returns a Policy object of the specified type. |
static Policy |
getInstance |
Deprecated, for removal: This API element is subject to removal in a future version. Returns a Policy object of the specified type. |
Policy.Parameters |
getParameters() |
Deprecated, for removal: This API element is subject to removal in a future version. Return Policy parameters. |
PermissionCollection |
getPermissions |
Deprecated, for removal: This API element is subject to removal in a future version. Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource. |
PermissionCollection |
getPermissions |
Deprecated, for removal: This API element is subject to removal in a future version. Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain. |
static Policy |
getPolicy() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns a Policy object that grants no permissions. |
Provider |
getProvider() |
Deprecated, for removal: This API element is subject to removal in a future version. Return the Provider of this policy. |
String |
getType() |
Deprecated, for removal: This API element is subject to removal in a future version. Return the type of this Policy. |
boolean |
implies |
Deprecated, for removal: This API element is subject to removal in a future version. Evaluates the permissions granted to the ProtectionDomain and tests whether the permission is granted. |
void |
refresh() |
Deprecated, for removal: This API element is subject to removal in a future version. Refreshes/reloads the policy configuration. |
static void |
setPolicy |
Deprecated, for removal: This API element is subject to removal in a future version. Throws UnsupportedOperationException. |
public static final PermissionCollection UNSUPPORTED_EMPTY_COLLECTION
public Policy()
public static Policy getPolicy()
Policy object that grants no permissions. Specifically: getParameters method returns null. getPermissions(CodeSource) and getPermissions(ProtectionDomain) methods return a read-only empty PermissionCollection. implies method always returns false. Policy object, or if no Policy object had been installed, a default Policy implementation. Installing a system-wide Policy object is no longer supported. This method always returns a default Policy object that grants no permissions. A Policy object was only useful in conjunction with the Security Manager, which is no longer supported. There is no replacement for this method.Policy object that grants no permissionspublic static void setPolicy(Policy p)
UnsupportedOperationException. Setting a system-wide Policy object is not supported.Policy object. Installing a system-wide Policy object is no longer supported. A Policy object was only useful in conjunction with the Security Manager, which is no longer supported. There is no replacement for this method.p - ignoredUnsupportedOperationException - alwayspublic static Policy getInstance(String type, Policy.Parameters params) throws NoSuchAlgorithmException
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 Security.getProviders() method.
jdk.security.provider.preferred Security property to determine the preferred provider order for the specified algorithm. This may be different than the order of providers returned by Security.getProviders().type - the specified Policy typeparams - parameters for the Policy, which may be null.Policy objectIllegalArgumentException - if the specified parameters are not understood by the PolicySpi implementation from the selected Provider
NoSuchAlgorithmException - if no Provider supports a PolicySpi implementation for the specified typeNullPointerException - if type is null
public static Policy getInstance(String type, Policy.Parameters params, String provider) throws NoSuchProviderException, NoSuchAlgorithmException
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 Security.getProviders() method.
type - the specified Policy typeparams - parameters for the Policy, which may be null.provider - the provider.Policy objectIllegalArgumentException - if the specified provider is null or empty, or if the specified parameters are not understood by the PolicySpi implementation from the specified providerNoSuchAlgorithmException - if the specified provider does not support a PolicySpi implementation for the specified typeNoSuchProviderException - if the specified provider is not registered in the security provider listNullPointerException - if type is null
public static Policy getInstance(String type, Policy.Parameters params, Provider provider) throws NoSuchAlgorithmException
Policy object of the specified type. A new Policy object encapsulating the PolicySpi implementation from the specified provider is returned. Note that the specified provider does not have to be registered in the provider list.
type - the specified Policy typeparams - parameters for the Policy, which may be null.provider - the Provider.Policy objectIllegalArgumentException - if the specified Provider is null, or if the specified parameters are not understood by the PolicySpi implementation from the specified Provider
NoSuchAlgorithmException - if the specified Provider does not support a PolicySpi implementation for the specified typeNullPointerException - if type is null
public Provider getProvider()
Provider of this policy. This Policy instance will only have a provider if it was obtained via a call to Policy.getInstance. Otherwise this method returns null.
Provider of this policy, or null.public String getType()
Policy. This Policy instance will only have a type if it was obtained via a call to Policy.getInstance. Otherwise this method returns null.
Policy, or null.public Policy.Parameters getParameters()
Policy parameters. This Policy instance will only have parameters if it was obtained via a call to Policy.getInstance. Otherwise this method returns null.
Policy parameters, or null.public PermissionCollection getPermissions(CodeSource codesource)
The default implementation of this method ignores the CodeSource and returns Policy.UNSUPPORTED_EMPTY_COLLECTION.
codesource - ignoredpublic PermissionCollection getPermissions(ProtectionDomain domain)
The default implementation of this method ignores the ProtectionDomain and returns Policy.UNSUPPORTED_EMPTY_COLLECTION.
domain - ignoredpublic boolean implies(ProtectionDomain domain, Permission permission)
The default implementation of this method ignores the ProtectionDomain and Permission parameters and always returns false.
domain - ignoredpermission - ignoredfalse alwayspublic void refresh()
The default implementation of this method does nothing.
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/security/Policy.html
Policyobject is no longer supported. The setPolicy method has been changed to always throwUnsupportedOperationException. The getPolicy method has been changed to always return aPolicyobject that grants no permissions. There is no replacement for the Security Manager or this class.