Class Policy

java.lang.Object
java.security.Policy

@Deprecated(since="17",forRemoval=true)public abstract classPolicyextendsObject
Deprecated, for removal: This API element is subject to removal in a future version.
This class was only useful in conjunction withthe Security Manager, which is no longer supported. Installing a system-widePolicy object is no longer supported. ThesetPolicy method has been changed to always throwUnsupportedOperationException. ThegetPolicy method has been changed to always return aPolicy object that grants no permissions. There is no replacement for the Security Manager or this class.
APolicy 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.
Since:
1.2
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Deprecated, for removal: This API element is subject to removal in a future version.
    This class was only useful in conjunction withthe Security Manager, which is no longer supported.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    A read-only empty PermissionCollection instance.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Constructor for subclasses to call.
  • Method Summary

    Modifier and Type
    Method
    Description
    staticPolicy
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns a Policy object of the specified type.
    staticPolicy
    getInstance(String type,Policy.Parameters params,String provider)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns aPolicy object of the specified type.
    staticPolicy
    getInstance(String type,Policy.Parameters params,Provider provider)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns aPolicy object of the specified type.
    Deprecated, for removal: This API element is subject to removal in a future version.
    ReturnPolicy parameters.
    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.
    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.
    staticPolicy
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns aPolicy object that grants no permissions.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return theProvider of this policy.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the type of thisPolicy.
    boolean
    implies(ProtectionDomain domain,Permission permission)
    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
    Deprecated, for removal: This API element is subject to removal in a future version.
    Refreshes/reloads the policy configuration.
    static void
    Deprecated, for removal: This API element is subject to removal in a future version.
    ThrowsUnsupportedOperationException.
  • Field Details

    • UNSUPPORTED_EMPTY_COLLECTION

      public 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.
      Since:
      1.6
  • Constructor Details

    • Policy

      public Policy()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructor for subclasses to call.
  • Method Details

    • getPolicy

      public static Policy getPolicy()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns aPolicy object that grants no permissions. Specifically:
      • ThegetParameters method returnsnull.
      • ThegetPermissions(CodeSource) andgetPermissions(ProtectionDomain) methods return a read-only emptyPermissionCollection.
      • Theimplies method always returnsfalse.
      API Note:
      This method originally returned the installedPolicy object, or if noPolicy object had been installed, a defaultPolicy implementation. Installing a system-widePolicy object is no longer supported. This method always returns a defaultPolicy object that grants no permissions. APolicy object was only useful in conjunction withthe Security Manager, which is no longer supported. There is no replacement for this method.
      Returns:
      aPolicy object that grants no permissions
      See Also:
    • setPolicy

      public static void setPolicy(Policy p)
      Deprecated, for removal: This API element is subject to removal in a future version.
      ThrowsUnsupportedOperationException. Setting a system-widePolicy object is not supported.
      API Note:
      This method originally installed the system-widePolicy object. Installing a system-widePolicy object is no longer supported. APolicy object was only useful in conjunction withthe Security Manager, which is no longer supported. There is no replacement for this method.
      Parameters:
      p - ignored
      Throws:
      UnsupportedOperationException - always
      See Also:
    • getInstance

      public static Policy getInstance(String type,Policy.Parameters params) throwsNoSuchAlgorithmException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a Policy object of the specified type.

      This method traverses the list of registered security providers, starting with the most preferred provider. A newPolicy object encapsulating thePolicySpi implementation from the first provider that supports the specified type is returned.

      Note that the list of registered providers may be retrieved via theSecurity.getProviders() method.

      Implementation Note:
      The JDK Reference Implementation additionally uses thejdk.security.provider.preferredSecurity property to determine the preferred provider order for the specified algorithm. This may be different than the order of providers returned bySecurity.getProviders().
      Parameters:
      type - the specified Policy type
      params - parameters for thePolicy, which may benull.
      Returns:
      the newPolicy object
      Throws:
      IllegalArgumentException - if the specified parameters are not understood by thePolicySpi implementation from the selectedProvider
      NoSuchAlgorithmException - if noProvider supports aPolicySpi implementation for the specified type
      NullPointerException - iftype isnull
      Since:
      1.6
      See Also:
    • getInstance

      public static Policy getInstance(String type,Policy.Parameters params,String provider) throwsNoSuchProviderException,NoSuchAlgorithmException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns aPolicy object of the specified type.

      A newPolicy object encapsulating thePolicySpi 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 theSecurity.getProviders() method.

      Parameters:
      type - the specified Policy type
      params - parameters for thePolicy, which may benull.
      provider - the provider.
      Returns:
      the newPolicy object
      Throws:
      IllegalArgumentException - if the specified provider isnull or empty, or if the specified parameters are not understood by thePolicySpi implementation from the specified provider
      NoSuchAlgorithmException - if the specified provider does not support aPolicySpi implementation for the specified type
      NoSuchProviderException - if the specified provider is not registered in the security provider list
      NullPointerException - iftype isnull
      Since:
      1.6
      See Also:
    • getInstance

      public static Policy getInstance(String type,Policy.Parameters params,Provider provider) throwsNoSuchAlgorithmException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns aPolicy object of the specified type.

      A newPolicy object encapsulating thePolicySpi implementation from the specified provider is returned. Note that the specified provider does not have to be registered in the provider list.

      Parameters:
      type - the specified Policy type
      params - parameters for thePolicy, which may benull.
      provider - theProvider.
      Returns:
      the newPolicy object
      Throws:
      IllegalArgumentException - if the specifiedProvider isnull, or if the specified parameters are not understood by thePolicySpi implementation from the specifiedProvider
      NoSuchAlgorithmException - if the specifiedProvider does not support aPolicySpi implementation for the specified type
      NullPointerException - iftype isnull
      Since:
      1.6
      See Also:
    • getProvider

      public Provider getProvider()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return theProvider of this policy.

      ThisPolicy instance will only have a provider if it was obtained via a call toPolicy.getInstance. Otherwise this method returnsnull.

      Returns:
      theProvider of this policy, ornull.
      Since:
      1.6
    • getType

      public String getType()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the type of thisPolicy.

      ThisPolicy instance will only have a type if it was obtained via a call toPolicy.getInstance. Otherwise this method returnsnull.

      Returns:
      the type of thisPolicy, ornull.
      Since:
      1.6
    • getParameters

      public Policy.Parameters getParameters()
      Deprecated, for removal: This API element is subject to removal in a future version.
      ReturnPolicy parameters.

      ThisPolicy instance will only have parameters if it was obtained via a call toPolicy.getInstance. Otherwise this method returnsnull.

      Returns:
      Policy parameters, ornull.
      Since:
      1.6
    • getPermissions

      public PermissionCollection getPermissions(CodeSource codesource)
      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.

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

      Parameters:
      codesource - ignored
      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

      public PermissionCollection getPermissions(ProtectionDomain domain)
      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.

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

      Parameters:
      domain - ignored
      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.
      Since:
      1.4
    • implies

      public boolean implies(ProtectionDomain domain,Permission permission)
      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.

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

      Parameters:
      domain - ignored
      permission - ignored
      Returns:
      false always
      Since:
      1.4
      See Also:
    • refresh

      public void refresh()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Refreshes/reloads the policy configuration.

      The default implementation of this method does nothing.