svn commit: r719102 [1/2] - in /lenya/sandbox/access_control_redesign/src/modules-core/ac/java: src/ src/org/apache/lenya/ac/attr/ src/org/apache/lenya/ac/attr/antlr/ src/org/apache/lenya/ac/attr/impl/ src/org/apache/lenya/ac/file/ src/org/apache/lenya...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Wed Nov 19 14:37:20 2008
New Revision: 719102

URL: http://svn.apache.org/viewvc?rev=719102&view=rev
Log:
Committing changes to ac module.

Added:
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions.tokens
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions__.g
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluator.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluatorFactory.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.tokens
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsLexer.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsParser.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions__.g
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ParseException.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeImpl.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeManagerImpl.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeRuleImpl.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeSetImpl.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/EmptyAttributeSet.java
Modified:
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileAccreditableManager.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileGroup.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileIPRange.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileItemManager.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FilePolicyManager.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUser.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUserManager.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroup.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroupable.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractUser.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AnonymousAuthenticator.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/DefaultAccessController.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/DefaultPolicy.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/PolicyBuilder.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/URLPolicy.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/UserAuthenticator.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/cms/ac/SitemapPolicyManager.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/cms/cocoon/components/modules/input/AccessControlModule.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/test/org/apache/lenya/ac/impl/IdentityTest.java
    lenya/sandbox/access_control_redesign/src/modules-core/ac/java/test/org/apache/lenya/ac/impl/PolicyTest.java

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions.tokens
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions.tokens?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions.tokens (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions.tokens Wed Nov 19 14:37:20 2008
@@ -0,0 +1,9 @@
+RIGHTPAR=8
+EQUALS=6
+AND=5
+LITERAL=10
+LEFTPAR=7
+WS=12
+QUOT=11
+OR=4
+ID=9

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions__.g
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions__.g?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions__.g (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/Expressions__.g Wed Nov 19 14:37:20 2008
@@ -0,0 +1,36 @@
+lexer grammar Expressions;
+@members {
+
+    private ErrorHandler errorHandler;
+    
+    public void setErrorHandler(ErrorHandler handler) {
+    	this.errorHandler = handler;
+    }
+
+    public void emitErrorMessage(String msg) {
+    	this.errorHandler.error(msg);
+    }
+}
+@header {
+package org.apache.lenya.ac.attr.antlr;
+import org.apache.lenya.ac.ErrorHandler;
+}
+
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 106
+LITERAL: '"' ('a'..'z'|'A'..'Z'|'_'|' '|'.')* '"';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 107
+ID: ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9')*;
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 108
+EQUALS: '==';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 109
+QUOT: '"';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 110
+OR: '||';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 111
+AND: '&&';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 112
+LEFTPAR: '(';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 113
+RIGHTPAR: ')';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 114
+WS: (' '|'\t')+ {skip();} ;

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluator.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluator.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluator.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluator.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.ac.attr.antlr;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.lenya.ac.attr.AttributeSet;
+import org.apache.lenya.ac.attr.AttributeOwner;
+import org.apache.lenya.ac.attr.AttributeRuleEvaluator;
+import org.apache.lenya.ac.attr.ErrorHandler;
+import org.apache.lenya.ac.attr.Message;
+import org.apache.lenya.ac.attr.SimpleErrorHandler;
+import org.apache.lenya.ac.attr.ValidationResult;
+import org.apache.lenya.util.Assert;
+
+/**
+ * ANTLR-based attribute rule evaluator.
+ */
+public class AntlrEvaluator extends AbstractLogEnabled implements AttributeRuleEvaluator {
+    
+    /**
+     * @param logger The logger.
+     */
+    public AntlrEvaluator(Logger logger) {
+        enableLogging(logger);
+    }
+
+    protected static final String UNDEFINED_VALUE = "undefined";
+
+    public boolean isComplied(AttributeOwner user, String rule) {
+        ErrorHandler handler = new SimpleErrorHandler();
+        ExpressionsParser parser = getParser(rule, handler);
+        try {
+            String[] names = user.getAttributeNames();
+            for (int i = 0; i < names.length; i++) {
+                String[] values = user.getAttributeValues(names[i]);
+                if (values == null) {
+                    parser.memory.put(names[i], UNDEFINED_VALUE);
+                }
+                else {
+                    if (values.length == 1) {
+                        parser.memory.put(names[i], values[0]);
+                    } else {
+                        parser.memory.put(names[i], values);
+                    }
+                }
+            }
+            boolean result = parser.prog();
+            Message[] errors = handler.getErrors();
+            if (errors.length == 0) {
+                return result;
+            }
+            else {
+                getLogger().error("Invalid rule: " + rule);
+                for (int i = 0; i < errors.length; i++) {
+                    getLogger().error(errors[i].getText());
+                }
+                return false;
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public ValidationResult validate(String rule, AttributeSet attrs) {
+        ErrorHandler handler = new SimpleErrorHandler();
+        ExpressionsParser parser = getParser(rule, handler);
+        ValidationResult result;
+        try {
+            String[] names = attrs.getAttributeNames();
+            for (int i = 0; i < names.length; i++) {
+                parser.memory.put(attrs.getAttribute(names[i]).getAlias(), UNDEFINED_VALUE);
+            }
+            parser.prog();
+            result = new ValidationResult(handler.getErrors());
+        } catch (RecognitionException e) {
+            throw new RuntimeException(e);
+        }
+        return result;
+    }
+
+    protected ExpressionsParser getParser(String rule, ErrorHandler handler) {
+        Assert.notNull("rule", rule);
+        CharStream stream = new ANTLRStringStream(rule);
+        ExpressionsLexer lexer = new ExpressionsLexer(stream);
+        lexer.setErrorHandler(handler);
+        CommonTokenStream tokens = new CommonTokenStream(lexer);
+        ExpressionsParser parser = new ExpressionsParser(tokens);
+        parser.setErrorHandler(handler);
+        return parser;
+    }
+
+}

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluatorFactory.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluatorFactory.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/AntlrEvaluatorFactory.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.ac.attr.antlr;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.lenya.ac.attr.AttributeRuleEvaluator;
+import org.apache.lenya.ac.attr.AttributeRuleEvaluatorFactory;
+
+/**
+ * Factory for ANTLR-based attribute rule evaluators.
+ */
+public class AntlrEvaluatorFactory extends AbstractLogEnabled implements AttributeRuleEvaluatorFactory {
+
+    public AttributeRuleEvaluator getEvaluator() {
+        return new AntlrEvaluator(getLogger());
+    }
+
+}

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g Wed Nov 19 14:37:20 2008
@@ -0,0 +1,114 @@
+grammar Expressions;
+
+@header {
+package org.apache.lenya.ac.attr.antlr;
+import java.util.HashMap;
+import org.apache.lenya.ac.attr.ErrorHandler;
+}
+
+@lexer::header {
+package org.apache.lenya.ac.attr.antlr;
+import org.apache.lenya.ac.attr.ErrorHandler;
+}
+
+@members {
+/** Map variable name to object holding value */
+    HashMap memory = new HashMap();
+    private ErrorHandler errorHandler;
+    
+    public void setErrorHandler(ErrorHandler handler) {
+    	this.errorHandler = handler;
+    }
+    
+    public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
+        String hdr = getErrorHeader(e);
+        String msg;
+    	if (e instanceof FailedPredicateException) {
+  	        msg = ((FailedPredicateException) e).predicateText;
+    	}
+  	    else {
+            msg = getErrorMessage(e, tokenNames);
+  	    }
+        emitErrorMessage(hdr+" "+msg);
+    }
+
+    public void emitErrorMessage(String msg) {
+    	this.errorHandler.error(msg);
+    }
+}
+
+@lexer::members {
+
+    private ErrorHandler errorHandler;
+    
+    public void setErrorHandler(ErrorHandler handler) {
+    	this.errorHandler = handler;
+    }
+
+    public void emitErrorMessage(String msg) {
+    	this.errorHandler.error(msg);
+    }
+}
+
+prog returns [boolean value]
+    : e=orExpression {$value = $e.value; }
+    ;
+
+orExpression returns [boolean value]
+    :   e=andExpression {$value = $e.value; }
+    ( OR e=andExpression {$value = $value || $e.value; } )*
+    ;
+    
+andExpression returns [boolean value]
+    :   e=comparison {$value = $e.value;}
+    ( AND e=comparison {$value = $value && $e.value;} )*
+    ;
+    
+comparison returns [boolean value]
+    :   a=atom EQUALS b=atom {
+            if ($a.value instanceof String && $b.value instanceof String) {
+                $value = $a.value.equals($b.value);
+            }
+            else if ($a.value instanceof String && $b.value.getClass().isArray()) {
+                $value = java.util.Arrays.asList((String[]) $b.value).contains($a.value);
+            }
+            else if ($a.value.getClass().isArray() && $b.value instanceof String) {
+                $value = java.util.Arrays.asList((String[]) $a.value).contains($b.value);
+            }
+            else {
+                throw new FailedPredicateException(input, $a.text + " == " + $b.text,
+                    "Incompatible arguments for comparison: " + $a.value + ", " + $b.value);
+            }
+        }
+    |   LEFTPAR e=orExpression RIGHTPAR {$value = $e.value;}
+    ;
+
+atom returns [Object value]
+    :   quotedString {$value = $quotedString.value;}
+    |   ID
+        {
+            Object v = memory.get($ID.text);
+            if ( v != null ) {
+                $value = v;
+            }
+            else {
+            	$value = "undefined";
+                throw new FailedPredicateException(input, $ID.text,
+                    "Undefined variable \"" + $ID.text + "\"");
+            }
+        }
+    ;
+
+quotedString returns [String value]
+      : LITERAL {$value = $LITERAL.text.substring(1, $LITERAL.text.length() - 1);}
+      ;
+      
+LITERAL: '"' ('a'..'z'|'A'..'Z'|'_'|' '|'.')* '"';
+ID: ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9')*;
+EQUALS: '==';
+QUOT: '"';
+OR: '||';
+AND: '&&';
+LEFTPAR: '(';
+RIGHTPAR: ')';
+WS: (' '|'\t')+ {skip();} ;

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.tokens
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.tokens?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.tokens (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.tokens Wed Nov 19 14:37:20 2008
@@ -0,0 +1,9 @@
+RIGHTPAR=8
+EQUALS=6
+AND=5
+LITERAL=10
+LEFTPAR=7
+WS=12
+QUOT=11
+OR=4
+ID=9

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsLexer.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsLexer.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsLexer.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsLexer.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,505 @@
+// $ANTLR 3.0.1 /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g 2008-11-19 22:26:32
+
+package org.apache.lenya.ac.attr.antlr;
+import org.apache.lenya.ac.attr.ErrorHandler;
+
+
+import org.antlr.runtime.*;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+
+public class ExpressionsLexer extends Lexer {
+    public static final int RIGHTPAR=8;
+    public static final int EQUALS=6;
+    public static final int AND=5;
+    public static final int LITERAL=10;
+    public static final int LEFTPAR=7;
+    public static final int WS=12;
+    public static final int EOF=-1;
+    public static final int Tokens=13;
+    public static final int QUOT=11;
+    public static final int OR=4;
+    public static final int ID=9;
+
+
+        private ErrorHandler errorHandler;
+        
+        public void setErrorHandler(ErrorHandler handler) {
+        	this.errorHandler = handler;
+        }
+
+        public void emitErrorMessage(String msg) {
+        	this.errorHandler.error(msg);
+        }
+
+    public ExpressionsLexer() {;} 
+    public ExpressionsLexer(CharStream input) {
+        super(input);
+    }
+    public String getGrammarFileName() { return "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g"; }
+
+    // $ANTLR start LITERAL
+    public final void mLITERAL() throws RecognitionException {
+        try {
+            int _type = LITERAL;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:106:8: ( '\"' ( 'a' .. 'z' | 'A' .. 'Z' | '_' | ' ' | '.' )* '\"' )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:106:10: '\"' ( 'a' .. 'z' | 'A' .. 'Z' | '_' | ' ' | '.' )* '\"'
+            {
+            match('\"'); 
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:106:14: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | ' ' | '.' )*
+            loop1:
+            do {
+                int alt1=2;
+                int LA1_0 = input.LA(1);
+
+                if ( (LA1_0==' '||LA1_0=='.'||(LA1_0>='A' && LA1_0<='Z')||LA1_0=='_'||(LA1_0>='a' && LA1_0<='z')) ) {
+                    alt1=1;
+                }
+
+
+                switch (alt1) {
+            	case 1 :
+            	    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:
+            	    {
+            	    if ( input.LA(1)==' '||input.LA(1)=='.'||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) {
+            	        input.consume();
+
+            	    }
+            	    else {
+            	        MismatchedSetException mse =
+            	            new MismatchedSetException(null,input);
+            	        recover(mse);    throw mse;
+            	    }
+
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop1;
+                }
+            } while (true);
+
+            match('\"'); 
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end LITERAL
+
+    // $ANTLR start ID
+    public final void mID() throws RecognitionException {
+        try {
+            int _type = ID;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:107:3: ( ( 'a' .. 'z' | 'A' .. 'Z' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )* )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:107:5: ( 'a' .. 'z' | 'A' .. 'Z' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )*
+            {
+            if ( (input.LA(1)>='A' && input.LA(1)<='Z')||(input.LA(1)>='a' && input.LA(1)<='z') ) {
+                input.consume();
+
+            }
+            else {
+                MismatchedSetException mse =
+                    new MismatchedSetException(null,input);
+                recover(mse);    throw mse;
+            }
+
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:107:25: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' )*
+            loop2:
+            do {
+                int alt2=2;
+                int LA2_0 = input.LA(1);
+
+                if ( ((LA2_0>='0' && LA2_0<='9')||(LA2_0>='A' && LA2_0<='Z')||(LA2_0>='a' && LA2_0<='z')) ) {
+                    alt2=1;
+                }
+
+
+                switch (alt2) {
+            	case 1 :
+            	    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:
+            	    {
+            	    if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||(input.LA(1)>='a' && input.LA(1)<='z') ) {
+            	        input.consume();
+
+            	    }
+            	    else {
+            	        MismatchedSetException mse =
+            	            new MismatchedSetException(null,input);
+            	        recover(mse);    throw mse;
+            	    }
+
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop2;
+                }
+            } while (true);
+
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end ID
+
+    // $ANTLR start EQUALS
+    public final void mEQUALS() throws RecognitionException {
+        try {
+            int _type = EQUALS;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:108:7: ( '==' )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:108:9: '=='
+            {
+            match("=="); 
+
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end EQUALS
+
+    // $ANTLR start QUOT
+    public final void mQUOT() throws RecognitionException {
+        try {
+            int _type = QUOT;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:109:5: ( '\"' )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:109:7: '\"'
+            {
+            match('\"'); 
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end QUOT
+
+    // $ANTLR start OR
+    public final void mOR() throws RecognitionException {
+        try {
+            int _type = OR;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:110:3: ( '||' )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:110:5: '||'
+            {
+            match("||"); 
+
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end OR
+
+    // $ANTLR start AND
+    public final void mAND() throws RecognitionException {
+        try {
+            int _type = AND;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:111:4: ( '&&' )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:111:6: '&&'
+            {
+            match("&&"); 
+
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end AND
+
+    // $ANTLR start LEFTPAR
+    public final void mLEFTPAR() throws RecognitionException {
+        try {
+            int _type = LEFTPAR;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:112:8: ( '(' )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:112:10: '('
+            {
+            match('('); 
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end LEFTPAR
+
+    // $ANTLR start RIGHTPAR
+    public final void mRIGHTPAR() throws RecognitionException {
+        try {
+            int _type = RIGHTPAR;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:113:9: ( ')' )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:113:11: ')'
+            {
+            match(')'); 
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end RIGHTPAR
+
+    // $ANTLR start WS
+    public final void mWS() throws RecognitionException {
+        try {
+            int _type = WS;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:114:3: ( ( ' ' | '\\t' )+ )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:114:5: ( ' ' | '\\t' )+
+            {
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:114:5: ( ' ' | '\\t' )+
+            int cnt3=0;
+            loop3:
+            do {
+                int alt3=2;
+                int LA3_0 = input.LA(1);
+
+                if ( (LA3_0=='\t'||LA3_0==' ') ) {
+                    alt3=1;
+                }
+
+
+                switch (alt3) {
+            	case 1 :
+            	    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:
+            	    {
+            	    if ( input.LA(1)=='\t'||input.LA(1)==' ' ) {
+            	        input.consume();
+
+            	    }
+            	    else {
+            	        MismatchedSetException mse =
+            	            new MismatchedSetException(null,input);
+            	        recover(mse);    throw mse;
+            	    }
+
+
+            	    }
+            	    break;
+
+            	default :
+            	    if ( cnt3 >= 1 ) break loop3;
+                        EarlyExitException eee =
+                            new EarlyExitException(3, input);
+                        throw eee;
+                }
+                cnt3++;
+            } while (true);
+
+            skip();
+
+            }
+
+            this.type = _type;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end WS
+
+    public void mTokens() throws RecognitionException {
+        // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:8: ( LITERAL | ID | EQUALS | QUOT | OR | AND | LEFTPAR | RIGHTPAR | WS )
+        int alt4=9;
+        switch ( input.LA(1) ) {
+        case '\"':
+            {
+            int LA4_1 = input.LA(2);
+
+            if ( (LA4_1==' '||LA4_1=='\"'||LA4_1=='.'||(LA4_1>='A' && LA4_1<='Z')||LA4_1=='_'||(LA4_1>='a' && LA4_1<='z')) ) {
+                alt4=1;
+            }
+            else {
+                alt4=4;}
+            }
+            break;
+        case 'A':
+        case 'B':
+        case 'C':
+        case 'D':
+        case 'E':
+        case 'F':
+        case 'G':
+        case 'H':
+        case 'I':
+        case 'J':
+        case 'K':
+        case 'L':
+        case 'M':
+        case 'N':
+        case 'O':
+        case 'P':
+        case 'Q':
+        case 'R':
+        case 'S':
+        case 'T':
+        case 'U':
+        case 'V':
+        case 'W':
+        case 'X':
+        case 'Y':
+        case 'Z':
+        case 'a':
+        case 'b':
+        case 'c':
+        case 'd':
+        case 'e':
+        case 'f':
+        case 'g':
+        case 'h':
+        case 'i':
+        case 'j':
+        case 'k':
+        case 'l':
+        case 'm':
+        case 'n':
+        case 'o':
+        case 'p':
+        case 'q':
+        case 'r':
+        case 's':
+        case 't':
+        case 'u':
+        case 'v':
+        case 'w':
+        case 'x':
+        case 'y':
+        case 'z':
+            {
+            alt4=2;
+            }
+            break;
+        case '=':
+            {
+            alt4=3;
+            }
+            break;
+        case '|':
+            {
+            alt4=5;
+            }
+            break;
+        case '&':
+            {
+            alt4=6;
+            }
+            break;
+        case '(':
+            {
+            alt4=7;
+            }
+            break;
+        case ')':
+            {
+            alt4=8;
+            }
+            break;
+        case '\t':
+        case ' ':
+            {
+            alt4=9;
+            }
+            break;
+        default:
+            NoViableAltException nvae =
+                new NoViableAltException("1:1: Tokens : ( LITERAL | ID | EQUALS | QUOT | OR | AND | LEFTPAR | RIGHTPAR | WS );", 4, 0, input);
+
+            throw nvae;
+        }
+
+        switch (alt4) {
+            case 1 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:10: LITERAL
+                {
+                mLITERAL(); 
+
+                }
+                break;
+            case 2 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:18: ID
+                {
+                mID(); 
+
+                }
+                break;
+            case 3 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:21: EQUALS
+                {
+                mEQUALS(); 
+
+                }
+                break;
+            case 4 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:28: QUOT
+                {
+                mQUOT(); 
+
+                }
+                break;
+            case 5 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:33: OR
+                {
+                mOR(); 
+
+                }
+                break;
+            case 6 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:36: AND
+                {
+                mAND(); 
+
+                }
+                break;
+            case 7 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:40: LEFTPAR
+                {
+                mLEFTPAR(); 
+
+                }
+                break;
+            case 8 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:48: RIGHTPAR
+                {
+                mRIGHTPAR(); 
+
+                }
+                break;
+            case 9 :
+                // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:1:57: WS
+                {
+                mWS(); 
+
+                }
+                break;
+
+        }
+
+    }
+
+
+ 
+
+}
\ No newline at end of file

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsParser.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsParser.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsParser.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ExpressionsParser.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,431 @@
+// $ANTLR 3.0.1 /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g 2008-11-19 22:26:30
+
+package org.apache.lenya.ac.attr.antlr;
+import java.util.HashMap;
+import org.apache.lenya.ac.attr.ErrorHandler;
+
+
+import org.antlr.runtime.*;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+
+public class ExpressionsParser extends Parser {
+    public static final String[] tokenNames = new String[] {
+        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "OR", "AND", "EQUALS", "LEFTPAR", "RIGHTPAR", "ID", "LITERAL", "QUOT", "WS"
+    };
+    public static final int RIGHTPAR=8;
+    public static final int EQUALS=6;
+    public static final int AND=5;
+    public static final int LITERAL=10;
+    public static final int LEFTPAR=7;
+    public static final int WS=12;
+    public static final int EOF=-1;
+    public static final int QUOT=11;
+    public static final int OR=4;
+    public static final int ID=9;
+
+        public ExpressionsParser(TokenStream input) {
+            super(input);
+        }
+        
+
+    public String[] getTokenNames() { return tokenNames; }
+    public String getGrammarFileName() { return "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g"; }
+
+
+    /** Map variable name to object holding value */
+        HashMap memory = new HashMap();
+        private ErrorHandler errorHandler;
+        
+        public void setErrorHandler(ErrorHandler handler) {
+        	this.errorHandler = handler;
+        }
+        
+        public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
+            String hdr = getErrorHeader(e);
+            String msg;
+        	if (e instanceof FailedPredicateException) {
+      	        msg = ((FailedPredicateException) e).predicateText;
+        	}
+      	    else {
+                msg = getErrorMessage(e, tokenNames);
+      	    }
+            emitErrorMessage(hdr+" "+msg);
+        }
+
+        public void emitErrorMessage(String msg) {
+        	this.errorHandler.error(msg);
+        }
+
+
+
+    // $ANTLR start prog
+    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:53:1: prog returns [boolean value] : e= orExpression ;
+    public final boolean prog() throws RecognitionException {
+        boolean value = false;
+
+        boolean e = false;
+
+
+        try {
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:54:5: (e= orExpression )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:54:7: e= orExpression
+            {
+            pushFollow(FOLLOW_orExpression_in_prog50);
+            e=orExpression();
+            _fsp--;
+
+            value = e; 
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return value;
+    }
+    // $ANTLR end prog
+
+
+    // $ANTLR start orExpression
+    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:57:1: orExpression returns [boolean value] : e= andExpression ( OR e= andExpression )* ;
+    public final boolean orExpression() throws RecognitionException {
+        boolean value = false;
+
+        boolean e = false;
+
+
+        try {
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:58:5: (e= andExpression ( OR e= andExpression )* )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:58:9: e= andExpression ( OR e= andExpression )*
+            {
+            pushFollow(FOLLOW_andExpression_in_orExpression77);
+            e=andExpression();
+            _fsp--;
+
+            value = e; 
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:59:5: ( OR e= andExpression )*
+            loop1:
+            do {
+                int alt1=2;
+                int LA1_0 = input.LA(1);
+
+                if ( (LA1_0==OR) ) {
+                    alt1=1;
+                }
+
+
+                switch (alt1) {
+            	case 1 :
+            	    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:59:7: OR e= andExpression
+            	    {
+            	    match(input,OR,FOLLOW_OR_in_orExpression87); 
+            	    pushFollow(FOLLOW_andExpression_in_orExpression91);
+            	    e=andExpression();
+            	    _fsp--;
+
+            	    value = value || e; 
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop1;
+                }
+            } while (true);
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return value;
+    }
+    // $ANTLR end orExpression
+
+
+    // $ANTLR start andExpression
+    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:62:1: andExpression returns [boolean value] : e= comparison ( AND e= comparison )* ;
+    public final boolean andExpression() throws RecognitionException {
+        boolean value = false;
+
+        boolean e = false;
+
+
+        try {
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:63:5: (e= comparison ( AND e= comparison )* )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:63:9: e= comparison ( AND e= comparison )*
+            {
+            pushFollow(FOLLOW_comparison_in_andExpression125);
+            e=comparison();
+            _fsp--;
+
+            value = e;
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:64:5: ( AND e= comparison )*
+            loop2:
+            do {
+                int alt2=2;
+                int LA2_0 = input.LA(1);
+
+                if ( (LA2_0==AND) ) {
+                    alt2=1;
+                }
+
+
+                switch (alt2) {
+            	case 1 :
+            	    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:64:7: AND e= comparison
+            	    {
+            	    match(input,AND,FOLLOW_AND_in_andExpression135); 
+            	    pushFollow(FOLLOW_comparison_in_andExpression139);
+            	    e=comparison();
+            	    _fsp--;
+
+            	    value = value && e;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop2;
+                }
+            } while (true);
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return value;
+    }
+    // $ANTLR end andExpression
+
+
+    // $ANTLR start comparison
+    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:67:1: comparison returns [boolean value] : (a= atom EQUALS b= atom | LEFTPAR e= orExpression RIGHTPAR );
+    public final boolean comparison() throws RecognitionException {
+        boolean value = false;
+
+        atom_return a = null;
+
+        atom_return b = null;
+
+        boolean e = false;
+
+
+        try {
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:68:5: (a= atom EQUALS b= atom | LEFTPAR e= orExpression RIGHTPAR )
+            int alt3=2;
+            int LA3_0 = input.LA(1);
+
+            if ( ((LA3_0>=ID && LA3_0<=LITERAL)) ) {
+                alt3=1;
+            }
+            else if ( (LA3_0==LEFTPAR) ) {
+                alt3=2;
+            }
+            else {
+                NoViableAltException nvae =
+                    new NoViableAltException("67:1: comparison returns [boolean value] : (a= atom EQUALS b= atom | LEFTPAR e= orExpression RIGHTPAR );", 3, 0, input);
+
+                throw nvae;
+            }
+            switch (alt3) {
+                case 1 :
+                    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:68:9: a= atom EQUALS b= atom
+                    {
+                    pushFollow(FOLLOW_atom_in_comparison173);
+                    a=atom();
+                    _fsp--;
+
+                    match(input,EQUALS,FOLLOW_EQUALS_in_comparison175); 
+                    pushFollow(FOLLOW_atom_in_comparison179);
+                    b=atom();
+                    _fsp--;
+
+
+                                if (a.value instanceof String && b.value instanceof String) {
+                                    value = a.value.equals(b.value);
+                                }
+                                else if (a.value instanceof String && b.value.getClass().isArray()) {
+                                    value = java.util.Arrays.asList((String[]) b.value).contains(a.value);
+                                }
+                                else if (a.value.getClass().isArray() && b.value instanceof String) {
+                                    value = java.util.Arrays.asList((String[]) a.value).contains(b.value);
+                                }
+                                else {
+                                    throw new FailedPredicateException(input, input.toString(a.start,a.stop) + " == " + input.toString(b.start,b.stop),
+                                        "Incompatible arguments for comparison: " + a.value + ", " + b.value);
+                                }
+                            
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:83:9: LEFTPAR e= orExpression RIGHTPAR
+                    {
+                    match(input,LEFTPAR,FOLLOW_LEFTPAR_in_comparison191); 
+                    pushFollow(FOLLOW_orExpression_in_comparison195);
+                    e=orExpression();
+                    _fsp--;
+
+                    match(input,RIGHTPAR,FOLLOW_RIGHTPAR_in_comparison197); 
+                    value = e;
+
+                    }
+                    break;
+
+            }
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return value;
+    }
+    // $ANTLR end comparison
+
+    public static class atom_return extends ParserRuleReturnScope {
+        public Object value;
+    };
+
+    // $ANTLR start atom
+    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:86:1: atom returns [Object value] : ( quotedString | ID );
+    public final atom_return atom() throws RecognitionException {
+        atom_return retval = new atom_return();
+        retval.start = input.LT(1);
+
+        Token ID2=null;
+        String quotedString1 = null;
+
+
+        try {
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:87:5: ( quotedString | ID )
+            int alt4=2;
+            int LA4_0 = input.LA(1);
+
+            if ( (LA4_0==LITERAL) ) {
+                alt4=1;
+            }
+            else if ( (LA4_0==ID) ) {
+                alt4=2;
+            }
+            else {
+                NoViableAltException nvae =
+                    new NoViableAltException("86:1: atom returns [Object value] : ( quotedString | ID );", 4, 0, input);
+
+                throw nvae;
+            }
+            switch (alt4) {
+                case 1 :
+                    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:87:9: quotedString
+                    {
+                    pushFollow(FOLLOW_quotedString_in_atom222);
+                    quotedString1=quotedString();
+                    _fsp--;
+
+                    retval.value = quotedString1;
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:88:9: ID
+                    {
+                    ID2=(Token)input.LT(1);
+                    match(input,ID,FOLLOW_ID_in_atom234); 
+
+                                Object v = memory.get(ID2.getText());
+                                if ( v != null ) {
+                                    retval.value = v;
+                                }
+                                else {
+                                	retval.value = "undefined";
+                                    throw new FailedPredicateException(input, ID2.getText(),
+                                        "Undefined variable \"" + ID2.getText() + "\"");
+                                }
+                            
+
+                    }
+                    break;
+
+            }
+            retval.stop = input.LT(-1);
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return retval;
+    }
+    // $ANTLR end atom
+
+
+    // $ANTLR start quotedString
+    // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:102:1: quotedString returns [String value] : LITERAL ;
+    public final String quotedString() throws RecognitionException {
+        String value = null;
+
+        Token LITERAL3=null;
+
+        try {
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:103:7: ( LITERAL )
+            // /Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g:103:9: LITERAL
+            {
+            LITERAL3=(Token)input.LT(1);
+            match(input,LITERAL,FOLLOW_LITERAL_in_quotedString267); 
+            value = LITERAL3.getText().substring(1, LITERAL3.getText().length() - 1);
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return value;
+    }
+    // $ANTLR end quotedString
+
+
+ 
+
+    public static final BitSet FOLLOW_orExpression_in_prog50 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_andExpression_in_orExpression77 = new BitSet(new long[]{0x0000000000000012L});
+    public static final BitSet FOLLOW_OR_in_orExpression87 = new BitSet(new long[]{0x0000000000000680L});
+    public static final BitSet FOLLOW_andExpression_in_orExpression91 = new BitSet(new long[]{0x0000000000000012L});
+    public static final BitSet FOLLOW_comparison_in_andExpression125 = new BitSet(new long[]{0x0000000000000022L});
+    public static final BitSet FOLLOW_AND_in_andExpression135 = new BitSet(new long[]{0x0000000000000680L});
+    public static final BitSet FOLLOW_comparison_in_andExpression139 = new BitSet(new long[]{0x0000000000000022L});
+    public static final BitSet FOLLOW_atom_in_comparison173 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_EQUALS_in_comparison175 = new BitSet(new long[]{0x0000000000000600L});
+    public static final BitSet FOLLOW_atom_in_comparison179 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFTPAR_in_comparison191 = new BitSet(new long[]{0x0000000000000680L});
+    public static final BitSet FOLLOW_orExpression_in_comparison195 = new BitSet(new long[]{0x0000000000000100L});
+    public static final BitSet FOLLOW_RIGHTPAR_in_comparison197 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_quotedString_in_atom222 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_ID_in_atom234 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LITERAL_in_quotedString267 = new BitSet(new long[]{0x0000000000000002L});
+
+}
\ No newline at end of file

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions__.g
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions__.g?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions__.g (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions__.g Wed Nov 19 14:37:20 2008
@@ -0,0 +1,36 @@
+lexer grammar Expressions;
+@members {
+
+    private ErrorHandler errorHandler;
+    
+    public void setErrorHandler(ErrorHandler handler) {
+    	this.errorHandler = handler;
+    }
+
+    public void emitErrorMessage(String msg) {
+    	this.errorHandler.error(msg);
+    }
+}
+@header {
+package org.apache.lenya.ac.attr.antlr;
+import org.apache.lenya.ac.attr.ErrorHandler;
+}
+
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 106
+LITERAL: '"' ('a'..'z'|'A'..'Z'|'_'|' '|'.')* '"';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 107
+ID: ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9')*;
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 108
+EQUALS: '==';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 109
+QUOT: '"';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 110
+OR: '||';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 111
+AND: '&&';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 112
+LEFTPAR: '(';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 113
+RIGHTPAR: ')';
+// $ANTLR src "/Users/nobby/apache/lenya/pure-https/trunk/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/Expressions.g" 114
+WS: (' '|'\t')+ {skip();} ;

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ParseException.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ParseException.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ParseException.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/antlr/ParseException.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.ac.attr.antlr;
+
+/**
+ * Thrown in attribute rule evaluators if an attribute is not defined.
+ */
+public class ParseException extends RuntimeException {
+
+    public ParseException() {
+        super();
+    }
+
+    public ParseException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    public ParseException(String arg0) {
+        super(arg0);
+    }
+
+    public ParseException(Throwable arg0) {
+        super(arg0);
+    }
+
+}

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeImpl.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeImpl.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeImpl.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeImpl.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.ac.attr.impl;
+
+import org.apache.lenya.ac.attr.Attribute;
+import org.apache.lenya.util.Assert;
+
+public class AttributeImpl implements Attribute {
+
+    private String description;
+    private String name;
+    private String alias;
+    
+    public AttributeImpl(String name, String alias, String description) {
+        Assert.notNull("name", name);
+        Assert.notNull("alias", alias);
+        Assert.notNull("description", description);
+        this.name = name;
+        this.alias = alias;
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return this.description;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public String getAlias() {
+        return this.alias;
+    }
+
+}

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeManagerImpl.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeManagerImpl.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeManagerImpl.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.ac.attr.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.lenya.ac.attr.AttributeManager;
+import org.apache.lenya.ac.attr.AttributeRuleEvaluator;
+import org.apache.lenya.ac.attr.AttributeRuleEvaluatorFactory;
+import org.apache.lenya.ac.attr.AttributeSet;
+
+public class AttributeManagerImpl extends AbstractLogEnabled implements Serviceable,
+        AttributeManager, Disposable, Initializable, ThreadSafe, Component {
+
+    private ServiceManager manager;
+    private ServiceSelector attrSetSelector;
+    private AttributeRuleEvaluatorFactory evaluatorFactory;
+    private Map name2attributeSet = new HashMap();
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+    }
+
+    public synchronized AttributeSet getAttributeSet(String name) {
+        AttributeSet attrs = (AttributeSet) this.name2attributeSet.get(name);
+        if (attrs == null) {
+            try {
+                attrs = (AttributeSet) this.attrSetSelector.select(name);
+            } catch (ServiceException e) {
+                throw new RuntimeException(e);
+            }
+            this.name2attributeSet.put(name, attrs);
+        }
+        return attrs;
+    }
+
+    public AttributeRuleEvaluator getEvaluator() {
+        return this.evaluatorFactory.getEvaluator();
+    }
+
+    public void dispose() {
+        if (this.attrSetSelector != null) {
+            this.manager.release(this.attrSetSelector);
+        }
+        if (this.evaluatorFactory != null) {
+            this.manager.release(this.evaluatorFactory);
+        }
+    }
+
+    public void initialize() throws Exception {
+        this.attrSetSelector = (ServiceSelector) this.manager
+                .lookup(AttributeSet.ROLE + "Selector");
+        this.evaluatorFactory = (AttributeRuleEvaluatorFactory) this.manager
+                .lookup(AttributeRuleEvaluatorFactory.ROLE);
+    }
+
+}

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeRuleImpl.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeRuleImpl.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeRuleImpl.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeRuleImpl.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.ac.attr.impl;
+
+import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.attr.AttributeOwner;
+import org.apache.lenya.ac.attr.AttributeRule;
+import org.apache.lenya.ac.attr.AttributeRuleEvaluator;
+import org.apache.lenya.ac.attr.AttributeSet;
+import org.apache.lenya.ac.attr.Message;
+import org.apache.lenya.ac.attr.ValidationResult;
+import org.apache.lenya.util.Assert;
+
+/**
+ * Attribute rule implementation.
+ */
+public class AttributeRuleImpl implements AttributeRule {
+    
+    /**
+     * @param rule
+     * @param attrSet
+     * @param evaluator
+     * @throws AccessControlException if the rule is not valid.
+     */
+    public AttributeRuleImpl(String rule, AttributeSet attrSet, AttributeRuleEvaluator evaluator)
+            throws AccessControlException {
+        Assert.notNull("rule", rule);
+        Assert.notNull("attribute set", attrSet);
+        Assert.notNull("evaluator", evaluator);
+        
+        ValidationResult result = evaluator.validate(rule, attrSet);
+        if (!result.succeeded()) {
+            StringBuffer msg = new StringBuffer();
+            Message[] messages = result.getMessages();
+            for (int i = 0; i < messages.length; i++) {
+                if (i > 0) {
+                    msg.append("; ");
+                }
+                msg.append(messages[i].getText());
+            }
+            throw new AccessControlException("The rule is not valid: " + msg.toString());
+        }
+        
+        this.rule = rule;
+        this.attributeSet = attrSet;
+        this.evaluator = evaluator;
+    }
+    
+    private String rule;
+    private AttributeSet attributeSet;
+    private AttributeRuleEvaluator evaluator;
+
+    public AttributeSet getAttributeSet() {
+        return this.attributeSet;
+    }
+
+    public String getRule() {
+        return this.rule;
+    }
+
+    public boolean matches(AttributeOwner owner) {
+        return this.evaluator.isComplied(owner, getRule());
+    }
+
+    public String toString() {
+        return getRule();
+    }
+    
+}

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeSetImpl.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeSetImpl.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeSetImpl.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/AttributeSetImpl.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.ac.attr.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.lenya.ac.attr.Attribute;
+import org.apache.lenya.ac.attr.AttributeSet;
+import org.apache.lenya.util.Assert;
+
+/**
+ * SAML attribute translator implementation.
+ */
+public class AttributeSetImpl extends AbstractLogEnabled implements AttributeSet, Configurable {
+
+    private static final String CONF_ATTRIBUTE = "Attribute";
+    private static final String CONF_ATTRIBUTE_NAME = "name";
+    private static final String CONF_ATTRIBUTE_ALIAS = "alias";
+    private static final String CONF_ATTRIBUTE_DESCRIPTION = "description";
+
+    /**
+     * Separator for multiple values.
+     */
+    public static final String MULTIVALUE_SEPARATOR = ";";
+
+    private Map name2attr;
+    private String name;
+
+    public void configure(Configuration attrTransConfig) throws ConfigurationException {
+        this.name2attr = new HashMap();
+        this.name = attrTransConfig.getAttribute(CONF_ATTRIBUTE_NAME);
+        Configuration[] transList = attrTransConfig.getChildren();
+        for (int i = 0; i < transList.length; i++) {
+            if (!transList[i].getName().equals(CONF_ATTRIBUTE))
+                throw new ConfigurationException("Invalid child config element: "
+                        + transList[i].getName());
+            String name = transList[i].getAttribute(CONF_ATTRIBUTE_NAME);
+            String alias = transList[i].getAttribute(CONF_ATTRIBUTE_ALIAS, name);
+            String descr = transList[i].getAttribute(CONF_ATTRIBUTE_DESCRIPTION, "");
+            Attribute attr = new AttributeImpl(name, alias, descr);
+            this.name2attr.put(name, attr);
+        }
+    }
+
+    public Attribute getAttribute(String name) {
+        Assert.isTrue("Attribute '" + name + "' exists", this.name2attr.containsKey(name));
+        return (Attribute) this.name2attr.get(name);
+    }
+
+    public String[] getAttributeNames() {
+        Set names = this.name2attr.keySet();
+        return (String[]) names.toArray(new String[names.size()]);
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+}

Added: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/EmptyAttributeSet.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/EmptyAttributeSet.java?rev=719102&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/EmptyAttributeSet.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/attr/impl/EmptyAttributeSet.java Wed Nov 19 14:37:20 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *  
+ */
+package org.apache.lenya.ac.attr.impl;
+
+import org.apache.lenya.ac.attr.Attribute;
+import org.apache.lenya.ac.attr.AttributeSet;
+
+/**
+ * An empty attribute set.
+ */
+public class EmptyAttributeSet implements AttributeSet {
+    
+    private static final String NAME = "empty";
+
+    public Attribute getAttribute(String name) {
+        throw new RuntimeException("No attributes defined.");
+    }
+
+    public String[] getAttributeNames() {
+        return new String[0];
+    }
+
+    public String getName() {
+        return NAME;
+    }
+
+}

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileAccreditableManager.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileAccreditableManager.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileAccreditableManager.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileAccreditableManager.java Wed Nov 19 14:37:20 2008
@@ -28,6 +28,7 @@
 import java.util.Set;
 
 import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.util.NetUtils;
 import org.apache.excalibur.source.Source;
@@ -38,6 +39,7 @@
 import org.apache.lenya.ac.RoleManager;
 import org.apache.lenya.ac.UserManager;
 import org.apache.lenya.ac.UserType;
+import org.apache.lenya.ac.attr.AttributeManager;
 import org.apache.lenya.ac.impl.AbstractAccreditableManager;
 import org.apache.lenya.util.Assert;
 
@@ -204,4 +206,17 @@
         }
     }
 
+    private AttributeManager attributeMgr;
+
+    public AttributeManager getAttributeManager() {
+        if (this.attributeMgr == null) {
+            try {
+                this.attributeMgr = (AttributeManager) this.manager.lookup(AttributeManager.ROLE);
+            } catch (ServiceException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return this.attributeMgr;
+    }
+
 }

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileGroup.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileGroup.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileGroup.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileGroup.java Wed Nov 19 14:37:20 2008
@@ -28,6 +28,7 @@
 import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.Accreditable;
 import org.apache.lenya.ac.Item;
 import org.apache.lenya.ac.ItemManager;
 import org.apache.lenya.ac.impl.AbstractGroup;
@@ -132,4 +133,5 @@
         assert (_configurationDirectory != null) && _configurationDirectory.isDirectory();
         this.configurationDirectory = _configurationDirectory;
     }
+
 }
\ No newline at end of file

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileIPRange.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileIPRange.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileIPRange.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileIPRange.java Wed Nov 19 14:37:20 2008
@@ -163,4 +163,5 @@
 
         return config;
     }
+
 }
\ No newline at end of file

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileItemManager.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileItemManager.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileItemManager.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileItemManager.java Wed Nov 19 14:37:20 2008
@@ -494,4 +494,13 @@
         return this.accreditableManager;
     }
 
+    protected boolean containsItem(String id) {
+        try {
+            loadItems();
+        } catch (AccessControlException e) {
+            throw new IllegalStateException(e.getMessage());
+        }
+        return this.items.containsKey(id);
+    }
+
 }

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FilePolicyManager.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FilePolicyManager.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FilePolicyManager.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FilePolicyManager.java Wed Nov 19 14:37:20 2008
@@ -534,7 +534,7 @@
         Set grantedRoles = new HashSet();
         Policy policy = getPolicy(accreditableManager, url);
         for (int i = 0; i < roles.length; i++) {
-            if (policy.check(identity, roles[i]) == Policy.RESULT_GRANTED) {
+            if (policy.check(identity, roles[i], accreditableManager) == Policy.RESULT_GRANTED) {
                 grantedRoles.add(roles[i]);
             }
         }

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUser.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUser.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUser.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUser.java Wed Nov 19 14:37:20 2008
@@ -31,6 +31,7 @@
 import org.apache.lenya.ac.GroupManager;
 import org.apache.lenya.ac.Item;
 import org.apache.lenya.ac.ItemManager;
+import org.apache.lenya.ac.ManagedUser;
 import org.apache.lenya.ac.impl.AbstractUser;
 import org.apache.lenya.ac.impl.ItemConfiguration;
 
@@ -38,7 +39,7 @@
  * File-based user implementation.
  * @version $Id$
  */
-public class FileUser extends AbstractUser implements Item, Serializable {
+public class FileUser extends AbstractUser implements Item, Serializable, ManagedUser {
 
     /**
      * 

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUserManager.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUserManager.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUserManager.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/file/FileUserManager.java Wed Nov 19 14:37:20 2008
@@ -138,4 +138,8 @@
         return SUFFIX;
     }
 
+    public boolean contains(String userId) {
+        return containsItem(userId);
+    }
+
 }
\ No newline at end of file

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroup.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroup.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroup.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroup.java Wed Nov 19 14:37:20 2008
@@ -29,13 +29,17 @@
 import org.apache.lenya.ac.Group;
 import org.apache.lenya.ac.Groupable;
 import org.apache.lenya.ac.ItemManager;
-
+import org.apache.lenya.ac.attr.AttributeOwner;
+import org.apache.lenya.ac.attr.AttributeRule;
+import org.apache.lenya.ac.attr.AttributeRuleEvaluator;
 
 /**
  * A group is a set of {@link Groupable}s.
  */
-public abstract class AbstractGroup extends AbstractItem implements Accreditable, Group {
+public abstract class AbstractGroup extends AbstractItem implements Group {
     
+    private static final long serialVersionUID = 1L;
+
     /**
      * Creates a new group.
      * @param itemManager The item manager.
@@ -106,14 +110,6 @@
     }
 
     /**
-     * @see org.apache.lenya.ac.Accreditable#getAccreditables()
-     */
-    public Accreditable[] getAccreditables() {
-        Accreditable[] accreditables = { this };
-        return accreditables;
-    }
-    
-    /**
      * Delete a group
      * @throws AccessControlException if the delete failed
      */
@@ -121,4 +117,27 @@
         removeAllMembers();
     }
 
+    public boolean matches(AttributeOwner user) {
+        AttributeRule rule = getRule();
+        return rule == null ? false : rule.matches(user);
+    }
+
+    protected AttributeRuleEvaluator getAttributeRuleEvaluator() {
+        return getItemManager().getAccreditableManager().getAttributeManager().getEvaluator();
+    }
+
+    private AttributeRule rule;
+
+    public void setRule(AttributeRule rule) {
+        this.rule = rule;
+    }
+
+    public AttributeRule getRule() {
+        return this.rule;
+    }
+
+    public Accreditable[] getAccreditablesToAuthorize() {
+        Accreditable[] accrs = { this };
+        return accrs;
+    }
 }

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroupable.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroupable.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroupable.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractGroupable.java Wed Nov 19 14:37:20 2008
@@ -81,20 +81,10 @@
         }
     }
 
-    /**
-     * @see org.apache.lenya.ac.Accreditable#getAccreditables()
-     */
-    public Accreditable[] getAccreditables() {
+    public Accreditable[] getAccreditablesToAuthorize() {
         Set accreditables = new HashSet();
         accreditables.add(this);
-
-        Group[] _groups = getGroups();
-
-        for (int i = 0; i < _groups.length; i++) {
-            Accreditable[] groupAccreditables = _groups[i].getAccreditables();
-            accreditables.addAll(Arrays.asList(groupAccreditables));
-        }
-
+        accreditables.addAll(Arrays.asList(getGroups()));
         return (Accreditable[]) accreditables.toArray(new Accreditable[accreditables.size()]);
     }
     

Modified: lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractUser.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractUser.java?rev=719102&r1=719101&r2=719102&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractUser.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules-core/ac/java/src/org/apache/lenya/ac/impl/AbstractUser.java Wed Nov 19 14:37:20 2008
@@ -18,8 +18,15 @@
 
 package org.apache.lenya.ac.impl;
 
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.Group;
 import org.apache.lenya.ac.ItemManager;
 import org.apache.lenya.ac.Password;
 import org.apache.lenya.ac.User;
@@ -116,7 +123,7 @@
      * @return Returns the defaultDocumentLocale.
      */
     public String getDefaultDocumentLocale() {
-        return defaultDocumentLocale;
+        return this.defaultDocumentLocale;
     }
 
     /**
@@ -130,7 +137,7 @@
      * @return Returns the defaultMenuLocale.
      */
     public String getDefaultMenuLocale() {
-        return defaultMenuLocale;
+        return this.defaultMenuLocale;
     }
 
     /**
@@ -168,4 +175,63 @@
         return this.encryptedPassword.equals(Password.encrypt(password));
     }
 
+    private Map attributes = new HashMap();
+
+    public String[] getAttributeValues(String name) throws AccessControlException {
+        return (String[]) this.attributes.get(name);
+    }
+
+    public String[] getAttributeNames() {
+        Set names = this.attributes.keySet();
+        return (String[]) names.toArray(new String[names.size()]);
+    }
+
+    /**
+     * Sets an attribute.
+     * @param name The name.
+     * @param values The values.
+     * @throws AccessControlException if the attribute name is not supported.
+     */
+    public void setAttributeValues(String name, String[] values) throws AccessControlException {
+        this.attributes.put(name, values);
+    }
+
+    protected boolean hasAttributes() {
+        return !this.attributes.isEmpty();
+    }
+
+    /**
+     * @return The explicitly assigned groups, which excludes groups that contain this user because
+     *         it matches the group's rule.
+     */
+    protected Group[] getExplicitlyAssignedGroups() {
+        return super.getGroups();
+    }
+
+    public Group[] getGroups() {
+        Set groups = new HashSet();
+        groups.addAll(Arrays.asList(getExplicitlyAssignedGroups()));
+        groups.addAll(Arrays.asList(getRuleGroups()));
+        return (Group[]) groups.toArray(new Group[groups.size()]);
+    }
+    
+    
+    protected Group[] getRuleGroups() {
+        Set ruleGroups = new HashSet();
+        if (hasAttributes()) {
+            try {
+                Group[] groups = getItemManager().getAccreditableManager().getGroupManager()
+                        .getGroups();
+                for (int i = 0; i < groups.length; i++) {
+                    if (groups[i].matches(this)) {
+                        ruleGroups.add(groups[i]);
+                    }
+                }
+            } catch (AccessControlException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return (Group[]) ruleGroups.toArray(new Group[ruleGroups.size()]);
+    }
+
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.