SPCL Architecture
----------------------------------------------------------------------

1. Invocation:

  1.1 simple form 
  
      A. polc (run policy compiler)

      B. pole (run policy engine)

      A.1 polc [filename].spcl

          which translates to:

          java -classpath $CLASSPATH spcl.PolicyCompiler $1
          javac -d $OUTPUT_DIR [filename]Installer.java

      B.1 pole [filename]Installer.class

          which translates to:

          java -classpath $CLASSPATH spcl.PolicyEngine $1


  1.2 complex form (nyi)

     The complex form of the invocation allows multiple policy
     files to be loaded over the network and compiled within
     the PolicyEngine at once.

2. Runtime Environment:

  2.1 Application Architecture

      - The 'spcl' package
      - compile and run scripts
         (Makefile,polc.sh,polc.bat,pole.sh,pole.bat)
      - class hierarchy (Section 3)
      - data flow

  2.2 System Architecture

      For the simple case, we assume a PolicyEngine running on a
      port that accepts SPCL PolicyRequests on that port and
      returns appropriate PolicyResponses.

  2.3 Intermediate Format
    
      2.3.1 Overview

      Our intermediate format is a .java file for a class that
      extends spcl.data.PolicyInstaller. The main hook in this class
      is the 'public void doInstall(){;}'. Our PolicyCompiler
      will have (besides the Lexer, Parser, and Walker) a
      two-part Generator. The first part of the Generator is a
      collection of 'public String generateXXX()' methods that the
      second part of the Generator parameterizes and calls. The
      second half of the Generator then appends the output to the
      .java file under consideration. Most of the action will take
      place in the 'doInstall()' method.

      2.3.2 Body of the doInstall() method.

	The body of the doInstall() method has three primary parts:
		-declaration headers
		-parameterization calls
		-activation code generation

	For example, if we compile the file 'Foo.spcl', then a file
	like the following is created:
	
	FooInstaller.java:
////////////////////////////////////////////////////////
/**
 * Header comments. Date, version, etc
 *
*/

package currentdir;

import spcl.data.*;
import java.util.*;
import java.io.*;

/** 
 * place comments from source file here?
 *
*/
public class FooInstaller extends PolicyInstaller{

  public FooInstaller(){ }

  public void doInstall() throws PolicyException{

    Zone zone = new Zone( "zone:blah" );
    Policy policy = new Policy( "policy:blah.foo" );
    Principal p1 = new Principal( "principal:blah.foo.Michael.Michael" );
    Principal p2 = new Principal( "principal:blah.foo.John.John" );
    Rule rule1 = new Rule("rule:blah.foo.Michael.Michael.1");
    Rule rule2 = new Rule("rule:blah.foo.John.John.1");
    Rule rule3 = new Rule("rule:blah.foo.John.John.2");
    Group default = new Group( "group:blah.foo.default" );
    Group g1 = new Group( "group:blah.foo.parents" );
    SystemObject so1 = new SystemObject( "object:blah.foo.webserver" );

    rule1.setPrincipal( p1 );
    rule1.setAction( spcl.data.Rule.ALLOW, "GET /index.html HTTP/1.1", webserver );
    rule1.setActive( true );

    rule2.setPrincipal( p2 );
    rule2.setAction( spcl.data.Rule.DENY, "open()", socket );
    rule2.setActive( false );

    rule3.setPrincipal( p2 );
    rule3.setAction( spcl.data.Rule.ALLOW, "close()" );
    rule3.setActive( true );

    rule1.addFiring(
       new Firing(){
         public void doFire(){
           rule2.setActive( true );
         }
       }
    );

    rule2.addFiring( null );

    rule3.addFiring( 
       new Firing(){
         public void doFire(){
            //insert java code here
         }
       }
    );

    p1.addRule( rule1 );
    p2.addRule( rule2 );
    p2.addRule( rule3 );

    policy.attach( p1 );
    policy.attach( p2 );
    zone.attach( policy );
    policyLoader.load( zone );
	//alternatively,
	//no zone.attach()
	//policyLoader.load( zone );
	//policyLoader.load( policy, zone.getName() );
  }
}
////////////////////////////////////////////////////////////////////
  policyEngine.load() may throw a PolicyException of indicating
  something was wrong with the policy. We can enumerate these as
  static final ints in the PolicyException class.

3. Class Hierarchy:

class Policy
   has a name

class Zone
   has a name
   has a list of Policys
   has a set of Principals
   has a set of SystemObjects
   has a set of Groups

class PolicyEngine
   has a name
   has a list of Zones
   is a PolicyLoader
   has a ServerSocket
   has a client Socket
   has a stop flag
   is a Runnable

class PolicyLoader
   does load( Policy policy )

class Principal
   has a name
   has a ContactInfo
   has set of Rules {active and inactive}

class Group
   has a name
   has a set of Rules {active and inactive}

class SystemObject
   has a name
   has a url
   has a set of Actions

class Action
   has a String inputform

class Rule
   has a boolean flag {active/inactive}

class Firing
   does public void doFire(){;} //must override

-----------------------------------------

class PolicyLexer

class PolicyParser

class PolicyInstaller
   has a PolicyLoader ref
   does
     protected void doInstall(){;}

-----------------------------------------

class PolicyException

class PolicyRequest

class PolicyResponse



class MyObject
  has
    x;
    y;
    z;
  is
    foo;
    bar;
  does
    scale();
    open();
