APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.security

public abstract Class Policy

extends Object
Class Inheritance
Known Direct Subclasses
java.security.Policy.PolicyDelegate
Annotations
@Deprecated
since:17
forRemoval:true
Imports
java.util.Enumeration, .Objects, sun.security.jca.GetInstance

Deprecated

for removal since 17.

This class was only useful in conjunction with the Security Manager, which is no longer supported. Installing a system-wide Policy object is no longer supported. The setPolicy method has been changed to always throw UnsupportedOperationException. The getPolicy method has been changed to always return a Policy object that grants no permissions. There is no replacement for the Security Manager or this class.

A 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.
Authors
Roland Schemers, Gary Ellison
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Policy.Parameters

Deprecated for removal since 17. This class was only useful in conjunction with the Security Manager, which is no longer supported. There is no replacement for the Security Manager or this class.
This represents a marker interface for Policy parameters.
private static class
Policy.PolicyDelegate

References Deprecated Policy is deprecated or references (maybe indirectly) at least one deprecated element.
This subclass is returned by the getInstance calls.
private static class
Policy.UnsupportedEmptyCollection

This class represents a read-only empty PermissionCollection object that is returned from the getPermissions(CodeSource) and getPermissions(ProtectionDomain) methods in the Policy class when those operations are not supported by the Policy implementation.

Field Summary

Modifier and TypeField and Description
private static Policy
NO_PERMISSIONS_POLICY

References Deprecated Policy is deprecated or references (maybe indirectly) at least one deprecated element.
public static final PermissionCollection
UNSUPPORTED_EMPTY_COLLECTION

A read-only empty PermissionCollection instance.

Constructor Summary

AccessConstructor and Description
public
Policy()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public static Policy

Returns:

the new Policy object
getInstance
(String
the specified Policy type
type
,
Policy.Parameters
parameters for the Policy, which may be null.
params
)
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 new Policy object
getInstance
(String
the specified Policy type
type
,
Policy.Parameters
parameters for the Policy, which may be null.
params
,
String
the provider.
provider
)
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 new Policy object
getInstance
(String
the specified Policy type
type
,
Policy.Parameters
parameters for the Policy, which may be null.
params
,
Provider
the Provider.
provider
)
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 Policy.Parameters

Returns:

Policy parameters, or null.
getParameters
()
References Deprecated Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.

Return Policy parameters.

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.
getPermissions
(CodeSource
ignored
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.
getPermissions
(ProtectionDomain
ignored
domain
)

Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain.

public static Policy

Returns:

a Policy object that grants no permissions
getPolicy
()
References Deprecated Policy is deprecated or references (maybe indirectly) at least one deprecated element.

Returns a Policy object that grants no permissions.

public Provider

Returns:

the Provider of this policy, or null.
getProvider
()

Return the Provider of this policy.

public String

Returns:

the type of this Policy, or null.
getType
()

Return the type of this Policy.

private static Policy
handleException(NoSuchAlgorithmException nsae)
References Deprecated Policy is deprecated or references (maybe indirectly) at least one deprecated element.

public boolean

Returns:

false always
implies
(ProtectionDomain
ignored
domain
,
Permission
ignored
permission
)

Evaluates the permissions granted to the ProtectionDomain and tests whether the permission is granted.

public void
refresh()

Refreshes/reloads the policy configuration.

public static void
setPolicy(Policy
ignored
p
)
References Deprecated Policy is deprecated or references (maybe indirectly) at least one deprecated element.

Throws UnsupportedOperationException.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NO_PERMISSIONS_POLICYback to summary
private static Policy NO_PERMISSIONS_POLICY

References Deprecated

Policy is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

UNSUPPORTED_EMPTY_COLLECTIONback to summary
public static final PermissionCollection UNSUPPORTED_EMPTY_COLLECTION

A read-only empty PermissionCollection instance.

Since
1.6

Constructor Detail

Policyback to summary
public Policy()

Constructor for subclasses to call.

Method Detail

getInstanceback to summary
public static Policy getInstance(String type, Policy.Parameters params) throws NoSuchAlgorithmException

References Deprecated

Policy.Parameters and Policy are deprecated or reference (maybe indirectly) at least one deprecated element.

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

Implementation Note

The JDK Reference Implementation additionally uses the 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().

Parameters
type:String

the specified Policy type

params:Policy.Parameters

parameters for the Policy, which may be null.

Returns:Policy

the new Policy object

Annotations
@SuppressWarnings:removal
Exceptions
NoSuchAlgorithmException:
if no Provider supports a PolicySpi implementation for the specified type
IllegalArgumentException:
if the specified parameters are not understood by the PolicySpi implementation from the selected Provider
NullPointerException:
if type is null
Since
1.6
See Also
Provider
getInstanceback to summary
public static Policy getInstance(String type, Policy.Parameters params, String provider) throws NoSuchProviderException, NoSuchAlgorithmException

References Deprecated

Policy.Parameters and Policy are deprecated or reference (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

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 Security.getProviders() method.

Parameters
type:String

the specified Policy type

params:Policy.Parameters

parameters for the Policy, which may be null.

provider:String

the provider.

Returns:Policy

the new Policy object

Annotations
@SuppressWarnings:removal
Exceptions
NoSuchProviderException:
if the specified provider is not registered in the security provider list
NoSuchAlgorithmException:
if the specified provider does not support a PolicySpi implementation for the specified type
IllegalArgumentException:
if the specified provider is null or empty, or if the specified parameters are not understood by the PolicySpi implementation from the specified provider
NullPointerException:
if type is null
Since
1.6
See Also
Provider
getInstanceback to summary
public static Policy getInstance(String type, Policy.Parameters params, Provider provider) throws NoSuchAlgorithmException

References Deprecated

Policy.Parameters and Policy are deprecated or reference (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns a 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.

Parameters
type:String

the specified Policy type

params:Policy.Parameters

parameters for the Policy, which may be null.

provider:Provider

the Provider.

Returns:Policy

the new Policy object

Annotations
@SuppressWarnings:removal
Exceptions
NoSuchAlgorithmException:
if the specified Provider does not support a PolicySpi implementation for the specified type
IllegalArgumentException:
if the specified Provider is null, or if the specified parameters are not understood by the PolicySpi implementation from the specified Provider
NullPointerException:
if type is null
Since
1.6
See Also
Provider
getParametersback to summary
public Policy.Parameters getParameters()

References Deprecated

Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Return Policy parameters.

This Policy instance will only have parameters if it was obtained via a call to Policy.getInstance. Otherwise this method returns null.

Returns:Policy.Parameters

Policy parameters, or null.

Since
1.6
getPermissionsback to summary
public PermissionCollection getPermissions(CodeSource codesource)

Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource.

The default implementation of this method ignores the CodeSource and returns Policy.UNSUPPORTED_EMPTY_COLLECTION.

Parameters
codesource:CodeSource

ignored

Returns:PermissionCollection

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.

getPermissionsback to summary
public PermissionCollection getPermissions(ProtectionDomain domain)

Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain.

The default implementation of this method ignores the ProtectionDomain and returns Policy.UNSUPPORTED_EMPTY_COLLECTION.

Parameters
domain:ProtectionDomain

ignored

Returns:PermissionCollection

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.

Since
1.4
getPolicyback to summary
public static Policy getPolicy()

References Deprecated

Policy is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns a Policy object that grants no permissions. Specifically:

  • The getParameters method returns null.
  • The getPermissions(CodeSource) and getPermissions(ProtectionDomain) methods return a read-only empty PermissionCollection.
  • The implies method always returns false.

API Note

This method originally returned the installed 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.

Returns:Policy

a Policy object that grants no permissions

See Also
setPolicy(java.security.Policy)
getProviderback to summary
public Provider getProvider()

Return the 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.

Returns:Provider

the Provider of this policy, or null.

Since
1.6
getTypeback to summary
public String getType()

Return the type of this Policy.

This Policy instance will only have a type if it was obtained via a call to Policy.getInstance. Otherwise this method returns null.

Returns:String

the type of this Policy, or null.

Since
1.6
handleExceptionback to summary
private static Policy handleException(NoSuchAlgorithmException nsae) throws NoSuchAlgorithmException

References Deprecated

Policy is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

impliesback to summary
public boolean implies(ProtectionDomain domain, Permission permission)

Evaluates the permissions granted to the ProtectionDomain and tests whether the permission is granted.

The default implementation of this method ignores the ProtectionDomain and Permission parameters and always returns false.

Parameters
domain:ProtectionDomain

ignored

permission:Permission

ignored

Returns:boolean

false always

Since
1.4
See Also
java.security.ProtectionDomain
refreshback to summary
public void refresh()

Refreshes/reloads the policy configuration.

The default implementation of this method does nothing.

setPolicyback to summary
public static void setPolicy(Policy p)

References Deprecated

Policy is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Throws UnsupportedOperationException. Setting a system-wide Policy object is not supported.

API Note

This method originally installed the system-wide 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.

Parameters
p:Policy

ignored

Exceptions
UnsupportedOperationException:
always
See Also
getPolicy()
java.security back to summary

public Interface Policy.Parameters

Known Direct Implementers
java.security.URIParameter
Annotations
@Deprecated
since:17
forRemoval:true

Deprecated

for removal since 17.

This class was only useful in conjunction with the Security Manager, which is no longer supported. There is no replacement for the Security Manager or this class.

This represents a marker interface for Policy parameters.
Since
1.6
java.security back to summary

private Class Policy.PolicyDelegate

extends Policy
Class Inheritance

References Deprecated

Policy is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

This subclass is returned by the getInstance calls. All Policy calls are delegated to the underlying PolicySpi.

Field Summary

Modifier and TypeField and Description
private Provider
p

private Policy.Parameters
params

References Deprecated Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.
private PolicySpi
spi

References Deprecated PolicySpi is deprecated or references (maybe indirectly) at least one deprecated element.
private String
Inherited from java.security.Policy:
UNSUPPORTED_EMPTY_COLLECTION

Constructor Summary

AccessConstructor and Description
private
PolicyDelegate(PolicySpi spi, Provider p, String type, Policy.Parameters params)
References Deprecated PolicySpi and Policy.Parameters are deprecated or reference (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
public Policy.Parameters
getParameters()

Overrides java.security.Policy.getParameters.

References Deprecated Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.

Return Policy parameters.

public PermissionCollection
getPermissions(CodeSource codesource)

Overrides java.security.Policy.getPermissions.

Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource.

public PermissionCollection
getPermissions(ProtectionDomain domain)

Overrides java.security.Policy.getPermissions.

Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain.

public Provider
getProvider()

Overrides java.security.Policy.getProvider.

Return the Provider of this policy.

public String
getType()

Overrides java.security.Policy.getType.

Return the type of this Policy.

public boolean
implies(ProtectionDomain domain, Permission perm)

Overrides java.security.Policy.implies.

Evaluates the permissions granted to the ProtectionDomain and tests whether the permission is granted.

public void
refresh()

Overrides java.security.Policy.refresh.

Refreshes/reloads the policy configuration.

Inherited from java.security.Policy:
getInstancegetInstancegetInstancegetPolicysetPolicy

Field Detail

pback to summary
private Provider p
paramsback to summary
private Policy.Parameters params

References Deprecated

Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

spiback to summary
private PolicySpi spi

References Deprecated

PolicySpi is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@SuppressWarnings:removal
typeback to summary
private String type

Constructor Detail

PolicyDelegateback to summary
private PolicyDelegate(PolicySpi spi, Provider p, String type, Policy.Parameters params)

References Deprecated

PolicySpi and Policy.Parameters are deprecated or reference (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Method Detail

getParametersback to summary
public Policy.Parameters getParameters()

Overrides java.security.Policy.getParameters.

Doc from java.security.Policy.getParameters.

References Deprecated

Policy.Parameters is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Return Policy parameters.

This Policy instance will only have parameters if it was obtained via a call to Policy.getInstance. Otherwise this method returns null.

Annotations
@Override
getPermissionsback to summary
public PermissionCollection getPermissions(CodeSource codesource)

Overrides java.security.Policy.getPermissions.

Doc from java.security.Policy.getPermissions.

Return a PermissionCollection object containing the set of permissions granted to the specified CodeSource.

The default implementation of this method ignores the CodeSource and returns Policy.UNSUPPORTED_EMPTY_COLLECTION.

Annotations
@Override
getPermissionsback to summary
public PermissionCollection getPermissions(ProtectionDomain domain)

Overrides java.security.Policy.getPermissions.

Doc from java.security.Policy.getPermissions.

Return a PermissionCollection object containing the set of permissions granted to the specified ProtectionDomain.

The default implementation of this method ignores the ProtectionDomain and returns Policy.UNSUPPORTED_EMPTY_COLLECTION.

Annotations
@Override
getProviderback to summary
public Provider getProvider()

Overrides java.security.Policy.getProvider.

Doc from java.security.Policy.getProvider.

Return the 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.

Annotations
@Override
getTypeback to summary
public String getType()

Overrides java.security.Policy.getType.

Doc from java.security.Policy.getType.

Return the type of this Policy.

This Policy instance will only have a type if it was obtained via a call to Policy.getInstance. Otherwise this method returns null.

Annotations
@Override
impliesback to summary
public boolean implies(ProtectionDomain domain, Permission perm)

Overrides java.security.Policy.implies.

Doc from java.security.Policy.implies.

Evaluates the permissions granted to the ProtectionDomain and tests whether the permission is granted.

The default implementation of this method ignores the ProtectionDomain and Permission parameters and always returns false.

Annotations
@Override
refreshback to summary
public void refresh()

Overrides java.security.Policy.refresh.

Doc from java.security.Policy.refresh.

Refreshes/reloads the policy configuration.

The default implementation of this method does nothing.

Annotations
@Override
java.security back to summary

private Class Policy.UnsupportedEmptyCollection

extends PermissionCollection
Class Inheritance

This class represents a read-only empty PermissionCollection object that is returned from the getPermissions(CodeSource) and getPermissions(ProtectionDomain) methods in the Policy class when those operations are not supported by the Policy implementation.

Field Summary

Modifier and TypeField and Description
private Permissions
private static final long

Constructor Summary

AccessConstructor and Description
public
UnsupportedEmptyCollection()

Create a read-only empty PermissionCollection object.

Method Summary

Modifier and TypeMethod and Description
public void
add(Permission
the Permission object to add.
permission
)

Implements abstract java.security.PermissionCollection.add.

Adds a permission object to the current collection of permission objects.

public Enumeration<Permission>

Returns:

an enumeration of all the Permissions.
elements
()

Implements abstract java.security.PermissionCollection.elements.

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.
implies
(Permission
the Permission object to compare.
permission
)

Implements abstract java.security.PermissionCollection.implies.

Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.

public boolean

Returns:

true if this object is marked as readonly, false otherwise.
isReadOnly
()

Overrides java.security.PermissionCollection.isReadOnly.

If this object is readonly, no new objects can be added to it using add.

Inherited from java.security.PermissionCollection:
elementsAsStreamsetReadOnlytoString

Field Detail

permsback to summary
private Permissions perms
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.PermissionCollection.serialVersionUID.

Annotations
@Serial

Constructor Detail

UnsupportedEmptyCollectionback to summary
public UnsupportedEmptyCollection()

Create a read-only empty PermissionCollection object.

Method Detail

addback to summary
public void add(Permission permission)

Implements abstract java.security.PermissionCollection.add.

Adds a permission object to the current collection of permission objects.

Parameters
permission:Permission

the Permission object to add.

Annotations
@Override
Exceptions
SecurityException:
if this PermissionCollection object has been marked readonly
elementsback to summary
public Enumeration<Permission> elements()

Implements abstract java.security.PermissionCollection.elements.

Returns an enumeration of all the Permission objects in the collection.

Returns:Enumeration<Permission>

an enumeration of all the Permissions.

Annotations
@Override
impliesback to summary
public boolean implies(Permission permission)

Implements abstract java.security.PermissionCollection.implies.

Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.

Parameters
permission:Permission

the Permission object to compare.

Returns:boolean

true if "permission" is implied by the permissions in the collection, false if not.

Annotations
@Override
isReadOnlyback to summary
public boolean isReadOnly()

Overrides java.security.PermissionCollection.isReadOnly.

If this object is readonly, no new objects can be added to it using add.

Returns:boolean

true if this object is marked as readonly, false otherwise.

Annotations
@Override