Modified: incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties?rev=1038020&r1=1038019&r2=1038020&view=diff ============================================================================== --- incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties (original) +++ incubator/river/jtsk/skunk/surrogate/nbproject/genfiles.properties Tue Nov 23 09:10:40 2010 @@ -1,8 +1,8 @@ -build.xml.data.CRC32=8d037bdc -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=1eabb020 -nbproject/build-impl.xml.script.CRC32=1087b099 -nbproject/[email protected] +build.xml.data.CRC32=8d037bdc +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=c1294c37 +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=1038020&r1=1038019&r2=1038020&view=diff ============================================================================== --- incubator/river/jtsk/skunk/surrogate/nbproject/project.properties (original) +++ incubator/river/jtsk/skunk/surrogate/nbproject/project.properties Tue Nov 23 09:10:40 2010 @@ -1,83 +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 -src.generated-src.dir=build\\generated-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}:\ + ${libs.JavaCC.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 Modified: incubator/river/jtsk/skunk/surrogate/nbproject/project.xml URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/nbproject/project.xml?rev=1038020&r1=1038019&r2=1038020&view=diff ============================================================================== --- incubator/river/jtsk/skunk/surrogate/nbproject/project.xml (original) +++ incubator/river/jtsk/skunk/surrogate/nbproject/project.xml Tue Nov 23 09:10:40 2010 @@ -1,16 +1,15 @@ -<?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> +<?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> Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java?rev=1038020&view=auto ============================================================================== --- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java (added) +++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/ASTNode.java Tue Nov 23 09:10:40 2010 @@ -0,0 +1,77 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.apache.river.container.security; + +/** + * + * @author trasukg + */ +public class ASTNode extends SimpleNode { + + private Object value=null; + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + + public ASTNode(int i) { + super(i); + } + + public ASTNode(PermissionFileParser p, int i) { + super(p, i); + } + + public String getName() { + return PermissionFileParserTreeConstants.jjtNodeName[id]; + } + + public String toString() { + if (id==PermissionFileParserTreeConstants.JJTSYMBOL) { + return getValue().toString(); + } + if (id==PermissionFileParserTreeConstants.JJTLITERAL) { + Object o=getValue(); + if (o instanceof String) { + return "\"" + o.toString() + "\""; + } + return o.toString(); + } + String childList = childList(); + if (!Strings.EMPTY.equals(childList)) { + return getName() + " " + childList; + } else { + return getName(); + } + } + + public String childList() { + StringBuffer sb = new StringBuffer(); + if (jjtGetNumChildren() != 0) { + boolean first = true; + for (int i = 0; i < jjtGetNumChildren(); i++) { + if (!first) { + sb.append(" "); + } else { + first = false; + } + String childStr = jjtGetChild(i).toString(); + if (childStr.indexOf(Strings.SPACE) != -1) { + sb.append(Strings.LPAREN); + sb.append(childStr); + sb.append(Strings.RPAREN); + } else { + sb.append(jjtGetChild(i).toString()); + } + } + } + return sb.toString(); + } +} Modified: 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=1038020&r1=1038019&r2=1038020&view=diff ============================================================================== --- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt (original) +++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/PermissionFileParser.jjt Tue Nov 23 09:10:40 2010 @@ -20,6 +20,7 @@ options { MULTI = true; NODE_DEFAULT_VOID = true; VISITOR = true; + NODE_CLASS= "ASTNode"; } PARSER_BEGIN(PermissionFileParser) @@ -38,12 +39,12 @@ public class PermissionFileParser { private static final Logger log= Logger.getLogger(PermissionFileParser.class.getName()); - public static SimpleNode parseGrants(InputStream in) + public static ASTgrants parseGrants(InputStream in) throws ParseException { Reader r=new InputStreamReader(in); PermissionFileParser parser=new PermissionFileParser(r); parser.grants(); - return (SimpleNode) parser.jjtree.popNode(); + return (ASTgrants) parser.jjtree.popNode(); } } @@ -58,7 +59,8 @@ SKIP : | "\n" | "\r" | "\f" -} +| <"//" (~["\n","\r"])* ("\n" | "\r" | "\r\n")> +| <"/*" (~["*"])* "*" ("*" | ~["*","/"] (~["*"])* "*")* "/">} TOKEN : { @@ -72,6 +74,12 @@ TOKEN : > | < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ > | < LONG_LITERAL: ["0"-"9"] (["0"-"9"])* (["l", "L"]) > +| < GRANT: "grant" > +| < AND: "and" > +| < OR: "or" > +| < NOT: "not" > +| < TRUE: "true" > +| < FALSE: "false" > | < SYMBOL: ["A"-"Z", "a"-"z", "_"] (["0"-"9", "A"-"Z", "a"-"z", ".", "_"])*> | < STRING_LITERAL: @@ -114,15 +122,10 @@ TOKEN : | < GTE: ">=" > | < NEQ: "<>" > | < COMMA: "," > -| < GRANT: "grant" > -| < AND: "and" > -| < OR: "or" > -| < NOT: "not" > -| < TRUE: "true" > -| < FALSE: "false" > + } -void grants() : +void grants() #grants: { log.fine("grants()"); } @@ -130,7 +133,7 @@ void grants() : (grant())* } -void grant() : +void grant() #grant: { log.fine("grant()"); } @@ -143,7 +146,7 @@ void permission() : log.fine("permission()"); } { - symbol() ";" + symbol() [literal()]";" } void primary() : @@ -164,31 +167,40 @@ void literal() #literal: { t=<INTEGER_LITERAL> { log.fine("integer literal " + t.image); + jjtThis.setValue(new Integer(t.image)); } | t=<FLOATING_POINT_LITERAL> { log.fine("floating-point literal " + t.image); + jjtThis.setValue(Float.parseFloat(t.image)); } | t=<LONG_LITERAL> { log.fine("long literal " + t.image); + jjtThis.setValue(Long.parseLong(t.image)); } | - t=<STRING_LITERAL> { } + t=<STRING_LITERAL> { + jjtThis.setValue(t.image); + } | - t=<TRUE> { } + t=<TRUE> { + jjtThis.setValue(true); + } | - t=<FALSE> { } + t=<FALSE> { + jjtThis.setValue(false); + } } -String symbol(): +void symbol() #symbol: { log.fine("symbol()"); Token t=null; } { t=<SYMBOL> { - return t.image; + jjtThis.setValue(t.image); } } Added: incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java?rev=1038020&view=auto ============================================================================== --- incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java (added) +++ incubator/river/jtsk/skunk/surrogate/src/org/apache/river/container/security/Strings.java Tue Nov 23 09:10:40 2010 @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package org.apache.river.container.security; + +/** + * + * @author trasukg + */ +public class Strings { + public static final String + EMPTY="", + LPAREN="(", + RPAREN=")", + SPACE=" "; +} Modified: 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=1038020&r1=1038019&r2=1038020&view=diff ============================================================================== --- incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java (original) +++ incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/PermissionFileParserTest.java Tue Nov 23 09:10:40 2010 @@ -47,6 +47,7 @@ public class PermissionFileParserTest { InputStream in= PermissionFileParserTest.class.getResourceAsStream("sample.policy"); assertTrue("No sample.policy file found!", in!=null); - Object parser=PermissionFileParser.parseGrants(in); + ASTgrants grants=PermissionFileParser.parseGrants(in); + assertEquals("grants (grant java.security.AllPermission)", grants.toString()); } } \ No newline at end of file Modified: 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=1038020&r1=1038019&r2=1038020&view=diff ============================================================================== --- incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy (original) +++ incubator/river/jtsk/skunk/surrogate/test/org/apache/river/container/security/sample.policy Tue Nov 23 09:10:40 2010 @@ -1,5 +1,5 @@ -# Sample file that our policy file parser should be able to process. +// Sample file that our policy file parser should be able to process. grant { - java.security.AllPermission + java.security.AllPermission; } \ No newline at end of file
