Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.jini.security.policy
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 `UmbrellaGrantPermission`s as shorthand notation for `GrantPermission`s covering all permissions authorized to given protection domains.

Since:
  2.0
Implementation Specifics:
  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.

Constructor Summary
`PolicyFileProvider()` 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 `UmbrellaGrantPermission`s are expanded into `GrantPermission`s as described in the documentation for `UmbrellaGrantPermission`.
`PolicyFileProvider(String policyFile)` 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 `UmbrellaGrantPermission`s are expanded into `GrantPermission`s as described in the documentation for `UmbrellaGrantPermission`.

Method Summary
`PermissionCollection` | `getPermissions(CodeSource source)`
`PermissionCollection` | `getPermissions(ProtectionDomain domain)`
`boolean` | `implies(ProtectionDomain domain, Permission permission)`
`void` | `refresh()` Refreshes the policy configuration by calling `refresh` on the base policy.

Methods inherited from class java.security.Policy
`getPolicy, setPolicy`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### 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 `UmbrellaGrantPermission`s are expanded into `GrantPermission`s 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.*"` `RuntimePermission`s, 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 `UmbrellaGrantPermission`s are expanded into `GrantPermission`s 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.

  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.*"` `RuntimePermission`s, depending on the package of the base policy class.

Parameters:
  `policyFile` - URL string specifying location of the policy file to use
Throws:
  `NullPointerException` - if `policyFile` is `null`
  `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

Method Detail

### getPermissions

    public PermissionCollection getPermissions(CodeSource source)

### getPermissions

    public PermissionCollection getPermissions(ProtectionDomain domain)

### implies

    public boolean implies(ProtectionDomain domain,
                           Permission permission)

### refresh

    public void refresh()

  Refreshes the policy configuration by calling `refresh` on the base policy. If this `PolicyFileProvider` instance was constructed with an explicit policy file value, then the `java.security.policy` system property is set to that value prior to invoking `refresh` on the base policy; once the base policy `refresh` call has completed, the `java.security.policy` system property is reset to its prior value. Internal synchronization ensures that concurrent invocations of this method and/or the `PolicyFileProvider(String)` constructor (which also modifies `java.security.policy`) will not interfere with the `java.security.policy` values set and restored by each.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 Sun Microsystems, Inc. All rights reserved