sysModel
Class PolicyFile

java.lang.Object
  extended by java.security.Policy
      extended by sysModel.PolicyFile

public final class PolicyFile
extends java.security.Policy

An implementation of a 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".

Author:
Casey Marshall (rsdio@metastatic.org)
See Also:
Policy

Field Summary
private  java.util.Map<java.security.CodeSource,java.security.Permissions> cs2pc
           
private static boolean DEBUG
           
private static java.lang.String DEFAULT_POLICY
           
private static int STATE_BEGIN
           
private static int STATE_GRANT
           
private static int STATE_PERMS
           
 
Constructor Summary
PolicyFile()
           
 
Method Summary
private static void debug(java.lang.String msg)
           
private static void debug(java.lang.Throwable t)
           
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)
           
private  void parse(java.net.URL url)
          Parse a policy file, incorporating the permission definitions described therein.
 void refresh()
           
 java.lang.String toString()
           
 
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

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

DEFAULT_POLICY

private static final java.lang.String DEFAULT_POLICY

cs2pc

private final java.util.Map<java.security.CodeSource,java.security.Permissions> 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

debug

private static void debug(java.lang.String msg)

debug

private static void debug(java.lang.Throwable t)

getPermissions

public java.security.PermissionCollection getPermissions(java.security.CodeSource codeSource)
Specified by:
getPermissions in class java.security.Policy

refresh

public void refresh()
Specified by:
refresh in class java.security.Policy

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

parse

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

Parameters:
url - The URL of the policy file to read.
Throws:
java.io.IOException - if an I/O error occurs, or if the policy file cannot be parsed.

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.

Throws:
java.io.IOException