Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.security
Class PolicyFile  view PolicyFile download PolicyFile.java

java.lang.Object
  extended byjava.security.Policy
      extended bygnu.java.security.PolicyFile

public final class PolicyFile
extends java.security.Policy

An implementation of a java.security.Policy object whose permissions are specified by a policy file.

The approximate syntax of policy files is:

 policyFile ::= keystoreOrGrantEntries ;

 keystoreOrGrantEntries ::= keystoreOrGrantEntry |
                            keystoreOrGrantEntries keystoreOrGrantEntry |
                            EMPTY ;

 keystoreOrGrantEntry ::= keystoreEntry | grantEntry ;

 keystoreEntry ::= "keystore" keystoreUrl ';' |
                   "keystore" keystoreUrl ',' keystoreAlgorithm ';' ;

 keystoreUrl ::= URL ;
 keystoreAlgorithm ::= STRING ;

 grantEntry ::= "grant" domainParameters '{' permissions '}' ';'

 domainParameters ::= domainParameter |
                      domainParameter ',' domainParameters ;

 domainParameter ::= "signedBy" signerNames |
                     "codeBase" codeBaseUrl |
                     "principal" principalClassName principalName |
                     "principal" principalName ;

 signerNames ::= quotedString ;
 codeBaseUrl ::= URL ;
 principalClassName ::= STRING ;
 principalName ::= quotedString ;

 quotedString ::= quoteChar STRING quoteChar ;
 quoteChar ::= '"' | '\'';

 permissions ::= permission | permissions permission ;

 permission ::= "permission" permissionClassName permissionTarget permissionAction |
                "permission" permissionClassName permissionTarget |
                "permission" permissionClassName;
 

Comments are either form of Java comments. Keystore entries only affect subsequent grant entries, so if a grant entry preceeds a keystore entry, that grant entry is not affected by that keystore entry. Certian instances of ${property-name} will be replaced with System.getProperty("property-name") in quoted strings.

This class will load the following files when created or refreshed, in order:

  1. The file ${java.home}/lib/security/java.policy.
  2. All URLs specified by security properties "policy.file.n", for increasing n starting from 1. The sequence stops at the first undefined property, so you must set "policy.file.1" if you also set "policy.file.2", and so on.
  3. The URL specified by the property "java.security.policy".


Field Summary
private  java.util.Map cs2pc
           
private static java.lang.String DEFAULT_POLICY
           
private static java.lang.String DEFAULT_USER_POLICY
           
private static java.util.logging.Logger logger
           
private static int STATE_BEGIN
           
private static int STATE_GRANT
           
private static int STATE_PERMS
           
 
Fields inherited from class java.security.Policy
 
Constructor Summary
PolicyFile()
           
 
Method Summary
private static void error(java.net.URL base, java.io.StreamTokenizer in, java.lang.String msg)
          I miss macros.
private static java.lang.String expand(java.lang.String s)
          Expand all instances of "${property-name}" into System.getProperty("property-name").
 java.security.PermissionCollection getPermissions(java.security.CodeSource codeSource)
          Returns the set of Permissions allowed for a given java.security.CodeSource.
private  void parse(java.net.URL url)
          Parse a policy file, incorporating the permission definitions described therein.
 void refresh()
          Causes this Policy instance to refresh / reload its configuration.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.security.Policy
getPermissions, getPolicy, implies, setPolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

DEFAULT_POLICY

private static final java.lang.String DEFAULT_POLICY

DEFAULT_USER_POLICY

private static final java.lang.String DEFAULT_USER_POLICY

cs2pc

private final java.util.Map cs2pc

STATE_BEGIN

private static final int STATE_BEGIN
See Also:
Constant Field Values

STATE_GRANT

private static final int STATE_GRANT
See Also:
Constant Field Values

STATE_PERMS

private static final int STATE_PERMS
See Also:
Constant Field Values
Constructor Detail

PolicyFile

public PolicyFile()
Method Detail

getPermissions

public java.security.PermissionCollection getPermissions(java.security.CodeSource codeSource)
Description copied from class: java.security.Policy
Returns the set of Permissions allowed for a given java.security.CodeSource.


refresh

public void refresh()
Description copied from class: java.security.Policy
Causes this Policy instance to refresh / reload its configuration. The method used to refresh depends on the concrete implementation.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


parse

private void parse(java.net.URL url)
            throws java.io.IOException
Parse a policy file, incorporating the permission definitions described therein.


expand

private static java.lang.String expand(java.lang.String s)
Expand all instances of "${property-name}" into System.getProperty("property-name").


error

private static void error(java.net.URL base,
                          java.io.StreamTokenizer in,
                          java.lang.String msg)
                   throws java.io.IOException
I miss macros.