Author: gtrasuk
Date: Mon Nov 22 15:32:35 2010
New Revision: 1037754

URL: http://svn.apache.org/viewvc?rev=1037754&view=rev
Log:
Work in progress.  Beginning to implement the security subsystem for the 
container.

Added:
    
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/
    
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt
    
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/
    
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java
    
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy
Modified:
    incubator/river/jtsk/skunk/surrogate/build.xml
    incubator/river/jtsk/skunk/surrogate/docs/Security.txt
    incubator/river/jtsk/skunk/surrogate/nbproject/build-impl.xml
    incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties
    incubator/river/jtsk/skunk/surrogate/nbproject/project.properties
    incubator/river/jtsk/skunk/surrogate/nbproject/project.xml

Modified: incubator/river/jtsk/skunk/surrogate/build.xml
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/build.xml?rev=1037754&r1=1037753&r2=1037754&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/build.xml (original)
+++ incubator/river/jtsk/skunk/surrogate/build.xml Mon Nov 22 15:32:35 2010
@@ -93,4 +93,20 @@
         <jar basedir="${build.test.sample-surrogate.dir}"
         jarfile="${basedir}/build/test/files/sample-surrogate.jar"/>
     </target>
+
+    <!-- Pre-compiler target to run javacc against our parser sources. -->
+    <target name="-pre-compile">
+        <property name="javacc.home" value="C:/java_libs/javacc-5.0"/>
+        <mkdir 
dir="${basedir}/build/generated-src/org/apache/river/container/security"/>
+        <jjtree
+            
target="${basedir}/src/org/apache/river/container/security/PermissionFileParser.jjt"
+            
outputdirectory="${basedir}/build/generated-src/org/apache/river/container/security"
+            javacchome="${javacc.home}"
+        />
+        <javacc
+            
target="${basedir}/build/generated-src/org/apache/river/container/security/PermissionFileParser.jj"
+            
outputdirectory="${basedir}/build/generated-src/org/apache/river/container/security"
+            javacchome="${javacc.home}"
+        />
+    </target>
 </project>

Modified: incubator/river/jtsk/skunk/surrogate/docs/Security.txt
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/docs/Security.txt?rev=1037754&r1=1037753&r2=1037754&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/docs/Security.txt (original)
+++ incubator/river/jtsk/skunk/surrogate/docs/Security.txt Mon Nov 22 15:32:35 
2010
@@ -25,6 +25,13 @@ Security in the Container
     a particular application.
     - Since we are creating the classloader as an instance of our own
     classloader, we can provide a customized protection domain as well.
+    - Applications and surrogates may come and go.  In order to prevent
+    memory leaks, the policy provider will need to be informed of the
+    ProtectionDomain shutdown (assuming that it needs to keep track of the
+    protection domain) so it can clear out its references and allow the
+    protection domain or classloader to be garbage-collected.
+        - Perhaps we could store data in the protection domain, but what about
+        the RMIClassLoader etc?  Can we make it use our custom domain?
 
 - Tentative plan:
     - Create a parser that reads a limited version of the permissions file

Modified: incubator/river/jtsk/skunk/surrogate/nbproject/build-impl.xml
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/build-impl.xml?rev=1037754&r1=1037753&r2=1037754&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/nbproject/build-impl.xml (original)
+++ incubator/river/jtsk/skunk/surrogate/nbproject/build-impl.xml Mon Nov 22 
15:32:35 2010
@@ -127,6 +127,7 @@ is divided into following sections:
         <condition property="have.sources">
             <or>
                 <available file="${src.dir}"/>
+                <available file="${src.generated-src.dir}"/>
             </or>
         </condition>
         <condition property="netbeans.home+have.tests">
@@ -183,6 +184,7 @@ is divided into following sections:
     </target>
     <target 
depends="-pre-init,-init-private,-init-user,-init-project,-do-init" 
name="-init-check">
         <fail unless="src.dir">Must set src.dir</fail>
+        <fail unless="src.generated-src.dir">Must set 
src.generated-src.dir</fail>
         <fail unless="test.src.dir">Must set test.src.dir</fail>
         <fail unless="build.dir">Must set build.dir</fail>
         <fail unless="dist.dir">Must set dist.dir</fail>
@@ -204,7 +206,7 @@ is divided into following sections:
     </target>
     <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" 
name="-init-macrodef-javac-with-processors">
         <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3";>
-            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${src.dir}:${src.generated-src.dir}" 
name="srcdir"/>
             <attribute default="${build.classes.dir}" name="destdir"/>
             <attribute default="${javac.classpath}" name="classpath"/>
             <attribute default="${javac.processorpath}" name="processorpath"/>
@@ -244,7 +246,7 @@ is divided into following sections:
     </target>
     <target depends="-init-ap-cmdline-properties" 
name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
         <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3";>
-            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${src.dir}:${src.generated-src.dir}" 
name="srcdir"/>
             <attribute default="${build.classes.dir}" name="destdir"/>
             <attribute default="${javac.classpath}" name="classpath"/>
             <attribute default="${javac.processorpath}" name="processorpath"/>
@@ -276,7 +278,7 @@ is divided into following sections:
     </target>
     <target 
depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors"
 name="-init-macrodef-javac">
         <macrodef name="depend" 
uri="http://www.netbeans.org/ns/j2se-project/3";>
-            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${src.dir}:${src.generated-src.dir}" 
name="srcdir"/>
             <attribute default="${build.classes.dir}" name="destdir"/>
             <attribute default="${javac.classpath}" name="classpath"/>
             <sequential>
@@ -525,12 +527,13 @@ is divided into following sections:
                 <include name="*"/>
             </dirset>
         </pathconvert>
-        <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
+        <j2seproject3:depend 
srcdir="${src.dir}:${src.generated-src.dir}:${build.generated.subdirs}"/>
     </target>
     <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, 
-copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
         <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
         <copy todir="${build.classes.dir}">
             <fileset dir="${src.dir}" 
excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+            <fileset dir="${src.generated-src.dir}" 
excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
         </copy>
     </target>
     <target if="has.persistence.xml" name="-copy-persistence-xml">
@@ -551,7 +554,7 @@ is divided into following sections:
     <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
         <fail unless="javac.includes">Must select some files in the IDE or set 
javac.includes</fail>
         <j2seproject3:force-recompile/>
-        <j2seproject3:javac excludes="" 
gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" 
sourcepath="${src.dir}"/>
+        <j2seproject3:javac excludes="" 
gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" 
sourcepath="${src.dir}:${src.generated-src.dir}"/>
     </target>
     <target name="-post-compile-single">
         <!-- Empty placeholder for easier customization. -->
@@ -699,6 +702,9 @@ is divided into following sections:
             <fileset dir="${src.dir}" excludes="${excludes}" 
includes="${includes}">
                 <filename name="**/*.java"/>
             </fileset>
+            <fileset dir="${src.generated-src.dir}" excludes="${excludes}" 
includes="${includes}">
+                <filename name="**/*.java"/>
+            </fileset>
             <fileset dir="${build.generated.sources.dir}" 
erroronmissingdir="false">
                 <include name="**/*.java"/>
             </fileset>
@@ -707,6 +713,9 @@ is divided into following sections:
             <fileset dir="${src.dir}" excludes="${excludes}" 
includes="${includes}">
                 <filename name="**/doc-files/**"/>
             </fileset>
+            <fileset dir="${src.generated-src.dir}" excludes="${excludes}" 
includes="${includes}">
+                <filename name="**/doc-files/**"/>
+            </fileset>
             <fileset dir="${build.generated.sources.dir}" 
erroronmissingdir="false">
                 <include name="**/doc-files/**"/>
             </fileset>

Modified: incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties?rev=1037754&r1=1037753&r2=1037754&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties 
(original)
+++ incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties Mon Nov 
22 15:32:35 2010
@@ -3,6 +3,6 @@ build.xml.script.CRC32=8dea2037
 [email protected]
 # This file is used by a NetBeans-based IDE to track changes in generated 
files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never 
regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=8d037bdc
-nbproject/build-impl.xml.script.CRC32=b9aa5753
+nbproject/build-impl.xml.data.CRC32=1eabb020
+nbproject/build-impl.xml.script.CRC32=1087b099
 nbproject/[email protected]

Modified: incubator/river/jtsk/skunk/surrogate/nbproject/project.properties
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/project.properties?rev=1037754&r1=1037753&r2=1037754&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/nbproject/project.properties (original)
+++ incubator/river/jtsk/skunk/surrogate/nbproject/project.properties Mon Nov 
22 15:32:35 2010
@@ -1,82 +1,83 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=surrogate
-application.vendor=trasukg
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
-    ${run.classpath}
-debug.test.classpath=\
-    ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/RiverSurrogate.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-excludes=
-includes=**
-jar.archive.disabled=${jnlp.enabled}
-jar.compress=false
-jar.index=${jnlp.enabled}
-javac.classpath=\
-    ${libs.ApacheRiverPlatform.classpath}:\
-    ${libs.ApacheRiverLib.classpath}
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
-    ${javac.classpath}
-javac.source=1.5
-javac.target=1.5
-javac.test.classpath=\
-    ${javac.classpath}:\
-    ${build.classes.dir}:\
-    ${libs.junit_4.classpath}
-javac.test.processorpath=\
-    ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-jnlp.codebase.type=no.codebase
-jnlp.descriptor=application
-jnlp.enabled=false
-jnlp.mixed.code=defaut
-jnlp.offline-allowed=false
-jnlp.signed=false
-main.class=
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
-run.classpath=\
-    ${javac.classpath}:\
-    ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value 
instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
-    ${javac.test.classpath}:\
-    ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=surrogate
+application.vendor=trasukg
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+    ${run.classpath}
+debug.test.classpath=\
+    ${run.test.classpath}
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/RiverSurrogate.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+includes=**
+jar.archive.disabled=${jnlp.enabled}
+jar.compress=false
+jar.index=${jnlp.enabled}
+javac.classpath=\
+    ${libs.ApacheRiverPlatform.classpath}:\
+    ${libs.ApacheRiverLib.classpath}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+    ${javac.classpath}
+javac.source=1.5
+javac.target=1.5
+javac.test.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}:\
+    ${libs.junit_4.classpath}
+javac.test.processorpath=\
+    ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+jnlp.codebase.type=no.codebase
+jnlp.descriptor=application
+jnlp.enabled=false
+jnlp.mixed.code=defaut
+jnlp.offline-allowed=false
+jnlp.signed=false
+main.class=
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+platform.active=default_platform
+run.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project
+# (you may also define separate properties like run-sys-prop.name=value 
instead of -Dname=value
+# or test-sys-prop.name=value to set system properties for unit tests):
+run.jvmargs=
+run.test.classpath=\
+    ${javac.test.classpath}:\
+    ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+src.generated-src.dir=build\\generated-src
+test.src.dir=test

Modified: incubator/river/jtsk/skunk/surrogate/nbproject/project.xml
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/project.xml?rev=1037754&r1=1037753&r2=1037754&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/surrogate/nbproject/project.xml (original)
+++ incubator/river/jtsk/skunk/surrogate/nbproject/project.xml Mon Nov 22 
15:32:35 2010
@@ -1,15 +1,16 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.netbeans.org/ns/project/1";>
-    <type>org.netbeans.modules.java.j2seproject</type>
-    <configuration>
-        <data xmlns="http://www.netbeans.org/ns/j2se-project/3";>
-            <name>RiverSurrogate</name>
-            <source-roots>
-                <root id="src.dir"/>
-            </source-roots>
-            <test-roots>
-                <root id="test.src.dir"/>
-            </test-roots>
-        </data>
-    </configuration>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1";>
+    <type>org.netbeans.modules.java.j2seproject</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/j2se-project/3";>
+            <name>RiverSurrogate</name>
+            <source-roots>
+                <root id="src.dir"/>
+                <root id="src.generated-src.dir"/>
+            </source-roots>
+            <test-roots>
+                <root id="test.src.dir"/>
+            </test-roots>
+        </data>
+    </configuration>
+</project>

Added: 
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt?rev=1037754&view=auto
==============================================================================
--- 
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt
 (added)
+++ 
incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt
 Mon Nov 22 15:32:35 2010
@@ -0,0 +1,310 @@
+options {
+  LOOKAHEAD = 1;
+  CHOICE_AMBIGUITY_CHECK = 2;
+  OTHER_AMBIGUITY_CHECK = 1;
+  STATIC = false;
+  DEBUG_PARSER = false;
+  DEBUG_LOOKAHEAD = false;
+  DEBUG_TOKEN_MANAGER = false;
+  ERROR_REPORTING = true;
+  JAVA_UNICODE_ESCAPE = false;
+  UNICODE_INPUT = false;
+  IGNORE_CASE = false;
+  USER_TOKEN_MANAGER = false;
+  USER_CHAR_STREAM = false;
+  BUILD_PARSER = true;
+  BUILD_TOKEN_MANAGER = true;
+  SANITY_CHECK = true;
+  BUILD_NODE_FILES = true;
+  FORCE_LA_CHECK = false;
+  MULTI = true;
+  NODE_DEFAULT_VOID = true;
+  VISITOR = true;
+}
+
+PARSER_BEGIN(PermissionFileParser)
+
+package org.apache.river.container.security;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import java.util.logging.Logger;
+
+public class PermissionFileParser {
+       private static final Logger log=
+               Logger.getLogger(PermissionFileParser.class.getName());
+
+    public static SimpleNode parseGrants(InputStream in)
+       throws ParseException {
+               Reader r=new InputStreamReader(in);
+               PermissionFileParser parser=new PermissionFileParser(r);
+                parser.grants();
+                return (SimpleNode) parser.jjtree.popNode();
+    }
+
+}
+PARSER_END(PermissionFileParser)
+
+/* WHITE SPACE */
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+TOKEN :
+{
+  < INTEGER_LITERAL: ["0"-"9"] (["0"-"9"])* >
+|  < FLOATING_POINT_LITERAL:
+        (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
+      | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
+      | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
+      | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
+         | ["0"-"9"] (["0"-"9"])*
+  >
+|  < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+|  < LONG_LITERAL: ["0"-"9"] (["0"-"9"])* (["l", "L"]) >
+|      < SYMBOL:
+               ["A"-"Z", "a"-"z", "_"] (["0"-"9", "A"-"Z", "a"-"z", ".", 
"_"])*>
+|      < STRING_LITERAL:
+       ("\""
+    (   (~["\"","\\","\n","\r"])
+        | ("\\"
+            ( ["n","t","b","r","f","\\","'","\""]
+            | ["0"-"7"] ( ["0"-"7"] )?
+            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+            )
+          )
+      )*
+      "\"" )
+       | ("\'"
+       (   (~["'","\\","\n","\r"])
+        | ("\\"
+            ( ["n","t","b","r","f","\\","'","\""]
+            | ["0"-"7"] ( ["0"-"7"] )?
+            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+            )
+          )
+      )*
+      "\'") >
+               {
+                       /* Remove the leading and trailing quotes. */
+                       image.deleteCharAt(image.length() -1);
+                       image.deleteCharAt(0);
+                       matchedToken.image=image.toString();
+               }
+|      < PLUS: "+" >
+|      < MINUS: "-" >
+|      < STAR: "*" >
+|      < OVER: "/" >
+|      < HOOK: "?" >
+|      < COLON: ":" >
+|      < EQUALS: "=" >
+|      < GT: ">" >
+|      < LT: "<" >
+|      < LTE: "<=" >
+|      < GTE: ">=" >
+|      < NEQ: "<>" >
+|      < COMMA: "," >
+|      < GRANT: "grant" >
+|      < AND: "and" >
+|      < OR: "or" >
+|      < NOT: "not" >
+|      < TRUE: "true" >
+|      < FALSE: "false" >
+}
+
+void grants() :
+{
+    log.fine("grants()");
+}
+{
+    (grant())*
+}
+
+void grant() :
+{
+    log.fine("grant()");
+}
+{
+    <GRANT> "{" (permission())* "}"
+}
+
+void permission() :
+{
+    log.fine("permission()");
+}
+{
+    symbol() ";"
+}
+
+void primary() :
+{
+       log.fine("primary()");
+       String t=null;
+}
+{
+       literal()
+       | "(" expression() ")"
+}
+
+void literal() #literal:
+{
+       Token t=null;
+       log.fine("literal");
+}
+{
+       t=<INTEGER_LITERAL> {
+                log.fine("integer literal " + t.image);
+       }
+        |
+       t=<FLOATING_POINT_LITERAL> {
+                log.fine("floating-point literal " + t.image);
+       }
+       |
+       t=<LONG_LITERAL> {
+                log.fine("long literal " + t.image);
+       }
+       |
+       t=<STRING_LITERAL>  { }
+       |
+       t=<TRUE>   {  }
+       |
+       t=<FALSE>  {  }
+}
+
+String symbol():
+{
+        log.fine("symbol()");
+        Token t=null;
+}
+{
+        t=<SYMBOL> {
+            return t.image;
+        }
+}
+
+
+void expression() :
+{
+       log.fine("expression()");
+}
+{
+       booleanExpression() choiceTerm()
+}
+
+void additiveExpression() :
+{
+       log.fine("additiveExpression()");
+}
+{
+       additiveTerm() additiveList()
+}
+
+void booleanExpression():
+{
+       log.fine("booleanExpression()");
+}
+{
+       booleanTerm() booleanList()
+}
+
+void booleanTerm():
+{
+       log.fine("booleanTerm()");
+}
+{
+       <NOT> conditionalExpression() #booleanNot(1)
+       | conditionalExpression()
+}
+
+void booleanList():
+{
+       log.fine("booleanList()");
+}
+{
+       (
+               <AND> booleanTerm() #booleanAnd(2)
+               | <OR> booleanTerm() #booleanOr(2)
+       ) *
+}
+
+void conditionalExpression():
+{
+       log.fine("conditionalExpression()");
+}
+{
+       additiveExpression() conditionalList()
+}
+
+void conditionalList() :
+{
+       log.fine("conditionalList()");
+}
+{
+       (
+               <EQUALS> additiveExpression() #equals(2)
+               | <LT> additiveExpression() #lessThan(2)
+               | <GT> additiveExpression() #greaterThan(2)
+               | <LTE> additiveExpression() #lessThanOrEqual(2)
+               | <GTE> additiveExpression() #greaterThanOrEqual(2)
+               | <NEQ> additiveExpression() #notEqual(2)
+       ) ?
+}
+
+void choiceTerm() :
+{
+}
+{
+       ( <HOOK> expression() <COLON> expression() #choice(3)
+        )?
+}
+
+void additiveList() :
+{
+       log.fine("additiveList()");
+}
+{
+       (
+               <PLUS> additiveTerm() #plus(2)
+               | <MINUS> additiveTerm() #minus(2)
+       ) *
+}
+
+void additiveTerm():
+{
+       log.fine("additiveTerm()");
+}
+{
+       multiplicativeTerm() multiplicativeList()
+}
+
+void multiplicativeTerm():
+{
+       log.fine("multiplicativeTerm()");
+}
+{
+       primary()
+}
+
+void multiplicativeList() :
+{
+       log.fine("multiplicativeList()");
+}
+{
+       (
+               <STAR> multiplicativeTerm() #multiply(2)
+               | <OVER> multiplicativeTerm() #divide(2)
+       ) *
+}
+
+
+

Added: 
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java?rev=1037754&view=auto
==============================================================================
--- 
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java
 (added)
+++ 
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java
 Mon Nov 22 15:32:35 2010
@@ -0,0 +1,52 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.river.container.security;
+
+import java.io.InputStream;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author trasukg
+ */
+public class PermissionFileParserTest {
+
+    public PermissionFileParserTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    /**
+     Ensure that the parsing basically happens; we can create the stream and
+     run it through the parser without errors.
+     */
+    public void testBasicParsing() throws ParseException {
+        InputStream in=
+                
PermissionFileParserTest.class.getResourceAsStream("sample.policy");
+        assertTrue("No sample.policy file found!", in!=null);
+        Object parser=PermissionFileParser.parseGrants(in);
+    }
+}
\ No newline at end of file

Added: 
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy
URL: 
http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy?rev=1037754&view=auto
==============================================================================
--- 
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy
 (added)
+++ 
incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy
 Mon Nov 22 15:32:35 2010
@@ -0,0 +1,5 @@
+# Sample file that our policy file parser should be able to process.
+
+grant {
+    java.security.AllPermission
+}
\ No newline at end of file


Reply via email to