You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by vt...@apache.org on 2004/12/10 14:29:15 UTC

svn commit: r111503 - in incubator/directory/janus/trunk/script/src: java/org/apache/janus/script java/org/apache/janus/script/xml java/org/apache/janus/script/xml/parser test/org/apache/janus/script/xml

Author: vtence
Date: Fri Dec 10 05:29:13 2004
New Revision: 111503

URL: http://svn.apache.org/viewcvs?view=rev&rev=111503
Log:
Clarified some test names; Policy builder in progress ...
Added:
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/RuleSetBuilder.java
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRuleSetBuilder.java
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/NodeParser.java
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/parser/
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/parser/TruePredicateNodeParser.java
   incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRuleSetBuilderTest.java
      - copied, changed from r111271, incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JPolicyBuilderTest.java
   incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Permissions.java
   incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Subjects.java
Removed:
   incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JPolicyBuilderTest.java
Modified:
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JGroupBuilder.java
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRoleBuilder.java
   incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JGroupBuilderTest.java
   incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java
   incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRoleBuilderTest.java

Added: incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/RuleSetBuilder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/RuleSetBuilder.java?view=auto&rev=111503
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/RuleSetBuilder.java	Fri Dec 10 05:29:13 2004
@@ -0,0 +1,8 @@
+package org.apache.janus.script;
+
+import org.apache.janus.authorization.RuleSet;
+
+public interface RuleSetBuilder
+{
+    void buildRuleSet( RuleSet ruleSet );
+}

Modified: incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JGroupBuilder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JGroupBuilder.java?view=diff&rev=111503&p1=incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JGroupBuilder.java&r1=111502&p2=incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JGroupBuilder.java&r2=111503
==============================================================================
--- incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JGroupBuilder.java	(original)
+++ incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JGroupBuilder.java	Fri Dec 10 05:29:13 2004
@@ -16,7 +16,6 @@
  */
 package org.apache.janus.script.xml;
 
-import org.apache.janus.authentication.attribute.MutableInformationProvider;
 import org.apache.janus.authentication.attribute.GroupPrincipal;
 import org.apache.janus.authentication.attribute.MutableInformationProvider;
 import org.apache.janus.script.InformationProviderBuilderMonitor;
@@ -39,8 +38,7 @@
 
     public static Dom4JGroupBuilder fromReader( Reader reader, InformationProviderBuilderMonitor monitor ) throws DocumentException
     {
-        Document doc = Dom4JUtils.readDocument( reader );
-        return new Dom4JGroupBuilder( doc, monitor );
+        return new Dom4JGroupBuilder( Dom4JUtils.readDocument( reader ), monitor );
     }
 
     public Dom4JGroupBuilder( Document doc )

Modified: incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java?view=diff&rev=111503&p1=incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java&r1=111502&p2=incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java&r2=111503
==============================================================================
--- incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java	(original)
+++ incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java	Fri Dec 10 05:29:13 2004
@@ -24,10 +24,9 @@
 import org.apache.janus.script.NullRealmBuilderMonitor;
 import org.apache.janus.script.RealmBuilder;
 import org.apache.janus.script.RealmBuilderMonitor;
-import org.dom4j.Element;
-import org.dom4j.DocumentException;
 import org.dom4j.Document;
-import org.dom4j.io.SAXReader;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -48,14 +47,12 @@
 
     public static Dom4JRealmBuilder fromReader( Reader reader ) throws DocumentException
     {
-        Document doc = readDocument( reader );
-        return new Dom4JRealmBuilder( doc );
+        return new Dom4JRealmBuilder( Dom4JUtils.readDocument( reader ) );
     }
 
     public static Dom4JRealmBuilder fromReader( Reader reader, RealmBuilderMonitor monitor ) throws DocumentException
     {
-        Document doc = readDocument( reader );
-        return new Dom4JRealmBuilder( doc, monitor );
+        return new Dom4JRealmBuilder( Dom4JUtils.readDocument( reader ), monitor );
     }
 
     public Dom4JRealmBuilder( Document doc )
@@ -114,13 +111,5 @@
         String password = user.attributeValue( "password" );
         creds.add( new PasswordCredential( password ) );
         return creds;
-    }
-
-    private static Document readDocument( Reader reader ) throws DocumentException
-    {
-        SAXReader xmlReader = new SAXReader();
-        Document doc = xmlReader.read( reader );
-
-        return doc;
     }
 }

Modified: incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRoleBuilder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRoleBuilder.java?view=diff&rev=111503&p1=incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRoleBuilder.java&r1=111502&p2=incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRoleBuilder.java&r2=111503
==============================================================================
--- incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRoleBuilder.java	(original)
+++ incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRoleBuilder.java	Fri Dec 10 05:29:13 2004
@@ -38,8 +38,7 @@
 
     public static Dom4JRoleBuilder fromReader( Reader reader, InformationProviderBuilderMonitor monitor ) throws DocumentException
     {
-        Document doc = Dom4JUtils.readDocument( reader );
-        return new Dom4JRoleBuilder( doc, monitor );
+        return new Dom4JRoleBuilder( Dom4JUtils.readDocument( reader ), monitor );
     }
 
     public Dom4JRoleBuilder( Document doc )

Added: incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRuleSetBuilder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRuleSetBuilder.java?view=auto&rev=111503
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRuleSetBuilder.java	Fri Dec 10 05:29:13 2004
@@ -0,0 +1,123 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import org.apache.janus.authorization.DefaultRule;
+import org.apache.janus.authorization.Effect;
+import org.apache.janus.authorization.Predicate;
+import org.apache.janus.authorization.RuleSet;
+import org.apache.janus.authorization.effect.DenyOverridesEffect;
+import org.apache.janus.authorization.effect.Effects;
+import org.apache.janus.authorization.effect.FirstApplicableEffect;
+import org.apache.janus.authorization.effect.LastApplicableEffect;
+import org.apache.janus.authorization.effect.PermitOverridesEffect;
+import org.apache.janus.script.RuleSetBuilder;
+import org.apache.janus.script.xml.parser.TruePredicateNodeParser;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Dom4JRuleSetBuilder implements RuleSetBuilder
+{
+    private final Element m_element;
+    private final Map m_parsers;
+    private final Map m_effects;
+
+    public static Dom4JRuleSetBuilder fromReader( Reader reader ) throws DocumentException
+    {
+        return new Dom4JRuleSetBuilder( Dom4JUtils.readDocument( reader ) );
+    }
+
+    public Dom4JRuleSetBuilder( Element element )
+    {
+        m_element = element;
+        m_parsers = new HashMap();
+        m_effects = new HashMap();
+
+        registerParsers();
+        registerEffects();
+    }
+
+    private void registerParsers()
+    {
+        m_parsers.put( "any", new TruePredicateNodeParser() );
+    }
+
+    private void registerEffects()
+    {
+        m_effects.put( "grant", Effects.GRANT );
+        m_effects.put( "deny", Effects.DENY );
+        m_effects.put( "not-applicable", Effects.NOT_APPLICABLE );
+        m_effects.put( "permit-overrides", new PermitOverridesEffect() );
+        m_effects.put( "deny-overrides", new DenyOverridesEffect() );
+        m_effects.put( "first-applicable", new FirstApplicableEffect() );
+        m_effects.put( "last-applicable", new LastApplicableEffect() );
+    }
+
+    public Dom4JRuleSetBuilder( Document doc )
+    {
+        this( doc.getRootElement() );
+    }
+
+    public void buildRuleSet( RuleSet ruleSet )
+    {
+        Element rule = m_element.element( "rule" );
+        addRule( ruleSet, rule );
+    }
+
+    private void addRule( RuleSet ruleSet, Element element )
+    {
+        String effectName = element.attributeValue( "effect" );
+        DefaultRule rule = new DefaultRule( effect( effectName ) );
+        setSubjectPredicate( rule, element );
+        setPermissionPredicate( rule, element );
+        ruleSet.addRule( rule );
+    }
+
+    private Effect effect( String name )
+    {
+        return (Effect) m_effects.get( name );
+    }
+
+    private void setSubjectPredicate( DefaultRule rule, Element element )
+    {
+        Element subjects = element.element( "subjects" );
+        List predicates = subjects.elements();
+        Element e = (Element) predicates.get( 0 );
+        rule.matchSubjects( predicate( e ) );
+    }
+
+    private Predicate predicate( Element e )
+    {
+        NodeParser nodeParser = (NodeParser) m_parsers.get( e.getName() );
+        return (Predicate) nodeParser.parse( e );
+    }
+
+    private void setPermissionPredicate( DefaultRule rule, Element element )
+    {
+        Element permissions = element.element( "permissions" );
+        List predicates = permissions.elements();
+        Element e = (Element) predicates.get( 0 );
+        rule.matchPermissions( predicate( e ) );
+    }
+}
+

Added: incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/NodeParser.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/NodeParser.java?view=auto&rev=111503
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/NodeParser.java	Fri Dec 10 05:29:13 2004
@@ -0,0 +1,24 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import org.dom4j.Element;
+
+public interface NodeParser
+{
+    Object parse( Element e );
+}

Added: incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/parser/TruePredicateNodeParser.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/parser/TruePredicateNodeParser.java?view=auto&rev=111503
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/parser/TruePredicateNodeParser.java	Fri Dec 10 05:29:13 2004
@@ -0,0 +1,29 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml.parser;
+
+import org.apache.janus.script.xml.NodeParser;
+import org.apache.janus.authorization.predicate.Predicates;
+import org.dom4j.Element;
+
+public class TruePredicateNodeParser implements NodeParser
+{
+    public Object parse( Element e )
+    {
+        return Predicates.TRUE;
+    }
+}

Modified: incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JGroupBuilderTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JGroupBuilderTest.java?view=diff&rev=111503&p1=incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JGroupBuilderTest.java&r1=111502&p2=incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JGroupBuilderTest.java&r2=111503
==============================================================================
--- incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JGroupBuilderTest.java	(original)
+++ incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JGroupBuilderTest.java	Fri Dec 10 05:29:13 2004
@@ -31,7 +31,7 @@
  */
 public class Dom4JGroupBuilderTest extends MockObjectTestCase
 {
-    public void testParsesUsersFromXMLDocumentAndAddsGroupAttributesToProvider() throws Exception
+    public void testAddsGroupAttributesToUsers() throws Exception
     {
         Dom4JGroupBuilder builder = Dom4JGroupBuilder.fromReader( new StringReader( userWithTwoGroups() ) );
 
@@ -54,7 +54,7 @@
         return content;
     }
 
-    public void testParsesGroupsFromXMLDocumentAndAddsGroupAttributesToProvider() throws Exception
+    public void testAddsGroupAttributesToGroups() throws Exception
     {
         Dom4JGroupBuilder builder = Dom4JGroupBuilder.fromReader( new StringReader( groupWithTwoGroups() ) );
 

Deleted: /incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JPolicyBuilderTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JPolicyBuilderTest.java?view=auto&rev=111502
==============================================================================

Modified: incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java?view=diff&rev=111503&p1=incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java&r1=111502&p2=incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java&r2=111503
==============================================================================
--- incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java	(original)
+++ incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java	Fri Dec 10 05:29:13 2004
@@ -38,7 +38,7 @@
         junit.textui.TestRunner.run( Dom4JRealmBuilderTest.class );
     }
 
-    public void testParsesUsersFromXMLDocumentAndAddsIdentitiesToRealm() throws Exception
+    public void testParsesDocumentAndAddsIdentitiesToRealm() throws Exception
     {
         Dom4JRealmBuilder builder = Dom4JRealmBuilder.fromReader( new StringReader( realmWithTwoIdentities() ) );
 

Modified: incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRoleBuilderTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRoleBuilderTest.java?view=diff&rev=111503&p1=incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRoleBuilderTest.java&r1=111502&p2=incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRoleBuilderTest.java&r2=111503
==============================================================================
--- incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRoleBuilderTest.java	(original)
+++ incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRoleBuilderTest.java	Fri Dec 10 05:29:13 2004
@@ -24,7 +24,7 @@
 
 public class Dom4JRoleBuilderTest extends MockObjectTestCase
 {
-    public void testParsesUsersFromXMLDocumentAndAddRoleAttributesToUsers() throws Exception
+    public void testAddsRoleAttributesToUsers() throws Exception
     {
         Dom4JRoleBuilder builder = Dom4JRoleBuilder.fromReader( new StringReader( userWithTwoRoles() ) );
 
@@ -47,7 +47,7 @@
         return content;
     }
 
-    public void testParsesGroupsFromXMLDocumentAndAddsRoleAttributesToGroups() throws Exception
+    public void testAddsRoleAttributesToGroups() throws Exception
     {
         Dom4JRoleBuilder builder = Dom4JRoleBuilder.fromReader( new StringReader( groupsWithRoles() ) );
 
@@ -72,7 +72,7 @@
         return content;
     }
 
-    public void testParsesRolesFromXMLDocumentAndAddsRoleAttributesToRoles() throws Exception
+    public void testAddsRoleAttributesToRoles() throws Exception
     {
         Dom4JRoleBuilder builder = Dom4JRoleBuilder.fromReader( new StringReader( roleWithTwoRoles() ) );
 

Copied: incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRuleSetBuilderTest.java (from r111271, incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JPolicyBuilderTest.java)
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRuleSetBuilderTest.java?view=diff&rev=111503&p1=incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JPolicyBuilderTest.java&r1=111271&p2=incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRuleSetBuilderTest.java&r2=111503
==============================================================================
--- incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JPolicyBuilderTest.java	(original)
+++ incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRuleSetBuilderTest.java	Fri Dec 10 05:29:13 2004
@@ -16,38 +16,36 @@
  */
 package org.apache.janus.script.xml;
 
-import org.jmock.Mock;
+import org.apache.janus.authorization.Policy;
+import org.apache.janus.authorization.effect.DenyOverridesEffect;
+import org.apache.janus.authorization.effect.Effects;
 import org.jmock.MockObjectTestCase;
-import org.apache.janus.authentication.attribute.MutableInformationProvider;
 
 import java.io.StringReader;
 
-public class Dom4JPolicyBuilderTest extends MockObjectTestCase
+public class Dom4JRuleSetBuilderTest extends MockObjectTestCase
 {
-    public void testSupportsDenyOverridesPolicyAlgorithm() throws Exception
+    public void testParsesDocumentAndAddsRulesToPolicy() throws Exception
     {
-//        Dom4JRoleBuilder builder = Dom4JRoleBuilder.fromReader( new StringReader( emptyDenyOverridesPolicy() ) );
-//
-//        Mock mockProvider = new Mock( MutableInformationProvider.class );
-//        mockProvider.expects( once() ).method( "addAttribute" ).with( eq( Usernames.joe() ), eq( Roles.user() ) ).will( returnValue( true ) );
-//        mockProvider.expects( once() ).method( "addAttribute" ).with( eq( Usernames.joe() ), eq( Roles.developer() ) ).will( returnValue( true ) );
-//
-//        builder.buildProvider( ( MutableInformationProvider ) mockProvider.proxy() );
-//
-//        mockProvider.verify();
+        Dom4JRuleSetBuilder builder = Dom4JRuleSetBuilder.fromReader( new StringReader( policyWithSingleRule() ) );
+
+        Policy policy = new Policy( new DenyOverridesEffect() );
+        builder.buildRuleSet( policy );
+
+        assertEquals( Effects.GRANT, policy.evaluate( Subjects.anybody(), Permissions.anything() ).reduce() );
     }
 
-    private String emptyDenyOverridesPolicy()
+    private String policyWithSingleRule()
     {
         String content =
                 "<policy>\n" +
-                "    <rule effect=\"deny\">\n" +
-                "        <subject>\n" +
+                "    <rule effect=\"grant\">\n" +
+                "        <subjects>\n" +
                 "            <any/>\n" +
-                "        </subject>\n" +
-                "        <permission>\n" +
+                "        </subjects>\n" +
+                "        <permissions>\n" +
                 "            <any/>\n" +
-                "        </permission>\n" +
+                "        </permissions>\n" +
                 "    </rule>\n" +
                 "</policy>";
         return content;

Added: incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Permissions.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Permissions.java?view=auto&rev=111503
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Permissions.java	Fri Dec 10 05:29:13 2004
@@ -0,0 +1,28 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import org.apache.janus.authorization.Permission;
+import org.apache.janus.authorization.BasicPermission;
+
+public class Permissions
+{
+    public static Permission anything()
+    {
+        return new BasicPermission( "anything" );
+    }
+}

Added: incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Subjects.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Subjects.java?view=auto&rev=111503
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Subjects.java	Fri Dec 10 05:29:13 2004
@@ -0,0 +1,27 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.script.xml;
+
+import javax.security.auth.Subject;
+
+public class Subjects
+{
+    public static Subject anybody()
+    {
+        return new Subject();
+    }
+}