Class PolicyFileProvider

java.lang.Object
java.security.Policy
net.jini.security.policy.PolicyFileProvider

public class PolicyFileProvider extends Policy
Security policy provider that wraps the J2SE(TM) default "PolicyFile" security policy provider distributed as part of the Java(TM) 2 Platform, Standard Edition. This provider augments the J2SE default policy provider in two ways: it provides an additional constructor for creating a policy based on an explicitly named policy file, and supports the use of UmbrellaGrantPermissions as shorthand notation for GrantPermissions covering all permissions authorized to given protection domains.
Since:
2.0

com.sun.jini.impl - This implementation's no-argument constructor uses a default class name of "sun.security.provider.PolicyFile" to instantiate base policy objects, if the net.jini.security.policy.PolicyFileProvider.basePolicyClass security property is not set.

Author:
Sun Microsystems, Inc.
  • Constructor Details

    • PolicyFileProvider

      public PolicyFileProvider() throws PolicyInitializationException
      Creates a PolicyFileProvider whose starting set of permission mappings is the same as those that would result from constructing a new instance of the J2SE default security policy provider with the current java.security.policy system property setting (if any), except that UmbrellaGrantPermissions are expanded into GrantPermissions as described in the documentation for UmbrellaGrantPermission.

      The constructed PolicyFileProvider contains an instance of the J2SE default security policy provider, which is created as follows: if the net.jini.security.policy.PolicyFileProvider.basePolicyClass security property is set, then its value is interpreted as the class name of the base (underlying) J2SE default policy provider; otherwise, an implementation-specific default class name is used. The base policy is then instantiated using the no-arg public constructor of the named class. If the base policy class is not found or is not instantiable via a public no-arg constructor, or if invocation of its constructor fails, then a PolicyInitializationException is thrown.

      Note that this constructor requires the appropriate "getProperty" SecurityPermission to read the net.jini.security.policy.PolicyFileProvider.basePolicyClass security property, and may require "accessClassInPackage.*" RuntimePermissions, depending on the package of the base policy class.

      Throws:
      PolicyInitializationException - if unable to construct the base policy
      SecurityException - if there is a security manager and the calling context does not have adequate permissions to read the net.jini.security.policy.PolicyFileProvider.basePolicyClass security property, or if the calling context does not have adequate permissions to access the base policy class
    • PolicyFileProvider

      public PolicyFileProvider(String policyFile) throws PolicyInitializationException
      Creates a PolicyFileProvider whose starting set of permission mappings is the same as those that would result from constructing a new instance of the J2SE default security policy provider with the java.security.policy system property set to the value of policyFile, except that UmbrellaGrantPermissions are expanded into GrantPermissions as described in the documentation for UmbrellaGrantPermission.

      The constructed PolicyFileProvider contains an instance of the J2SE default security policy provider, which is created as described in the documentation for PolicyFileProvider(). Before instantiating the base (underlying) J2SE default policy provider, this constructor sets the java.security.policy system property to the value of policyFile; after instantiation of the base policy instance has completed (normally or otherwise), the java.security.policy system property is reset to its prior value. Internal synchronization ensures that concurrent calls to this constructor and/or the refresh() method of this class (which may also modify java.security.policy) will not interfere with the java.security.policy values set and restored by each. No synchronization is done with any other accesses or modifications to java.security.policy.

      Note that this constructor requires PropertyPermission to read and write the java.security.policy system property, SecurityPermission to read the net.jini.security.policy.PolicyFileProvider.basePolicyClass security property, and may require "accessClassInPackage.*" RuntimePermissions, depending on the package of the base policy class.

      Parameters:
      policyFile - URL string specifying location of the policy file to use
      Throws:
      PolicyInitializationException - if unable to construct the base policy
      SecurityException - if there is a security manager and the calling context does not have adequate permissions to read and write the java.security.policy system property, to read the net.jini.security.policy.PolicyFileProvider.basePolicyClass security property, or to access the base policy class
      NullPointerException - if policyFile is null
  • Method Details