directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r327718 - in /directory/shared/ldap/trunk/common/src: antlr/ java/org/apache/ldap/common/util/ test/org/apache/ldap/common/aci/
Date Sat, 22 Oct 2005 23:27:31 GMT
Author: ersiner
Date: Sat Oct 22 16:27:14 2005
New Revision: 327718

URL: http://svn.apache.org/viewcvs?rev=327718&view=rev
Log:
Continuing to relax ACIItem grammar.
Added some utilities for easier grammar component existence/duplication tracking.
Modified grammar using new utilities in order to allow some compound components to have subcomponents
in any order.
Modified some test cases and added more for new relaxed grammar parts.

TODO:
There are still parts of the grammar that needs relaxing.
Utility classes may need to be refactored.

Added:
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/AbstractSimpleComponentsMonitor.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/ComponentsMonitor.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryAndOptionalComponentsMonitor.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryComponentsMonitor.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/OptionalComponentsMonitor.java
Modified:
    directory/shared/ldap/trunk/common/src/antlr/ACIItem.g
    directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/aci/ACIItemParserTest.java

Modified: directory/shared/ldap/trunk/common/src/antlr/ACIItem.g
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/antlr/ACIItem.g?rev=327718&r1=327717&r2=327718&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/antlr/ACIItem.g (original)
+++ directory/shared/ldap/trunk/common/src/antlr/ACIItem.g Sat Oct 22 16:27:14 2005
@@ -43,6 +43,9 @@
 import org.apache.ldap.common.name.NameComponentNormalizer;
 import org.apache.ldap.common.subtree.SubtreeSpecification;
 import org.apache.ldap.common.subtree.SubtreeSpecificationModifier;
+import org.apache.ldap.common.util.ComponentsMonitor;
+import org.apache.ldap.common.util.MandatoryAndOptionalComponentsMonitor;
+import org.apache.ldap.common.util.MandatoryComponentsMonitor;
 import org.apache.ldap.common.util.NamespaceTools;
 import org.apache.ldap.common.util.NoDuplicateKeysMap;
 import org.slf4j.Logger;
@@ -106,6 +109,8 @@
     private AuthenticationLevel m_authenticationLevel;
     private int m_aciPrecedence;
     
+    private boolean isItemFirstACIItem;
+    
     // shared global data needed to avoid extensive pass/return stuff
     private Set m_protectedItems;
     private Map m_protectedItemsMap;
@@ -120,7 +125,9 @@
     private Set chopAfterExclusions;
     private SubtreeSpecificationModifier ssModifier = null;
     
-    private ACIItem m_ACIItem = null;
+    private ComponentsMonitor mainACIItemComponentsMonitor;
+    private ComponentsMonitor itemPermissionComponentsMonitor;
+    private ComponentsMonitor userPermissionComponentsMonitor;
     
     
     /**
@@ -200,19 +207,71 @@
 {
     log.debug( "entered theACIItem()" );
     l_ACIItem = null;
+    mainACIItemComponentsMonitor = new MandatoryComponentsMonitor( 
+            new String [] { "identificationTag", "precedence", "authenticationLevel", "itemOrUserFirst"
} );
 }
     :
     OPEN_CURLY
-        ( SP )* aci_identificationTag ( SP )*
-        SEP ( SP )* aci_precedence ( SP )*
-        SEP ( SP )* aci_authenticationLevel ( SP )*
-        SEP ( SP )* aci_itemOrUserFirst ( SP )*
+        ( SP )* mainACIItemComponent ( SP )*
+            ( SEP ( SP )* mainACIItemComponent ( SP )* )*
     CLOSE_CURLY
     {
-        l_ACIItem = m_ACIItem;
+        if ( !mainACIItemComponentsMonitor.finalStateValid() )
+        {
+            throw new RecognitionException( "Missing mandatory ACIItem components: " 
+                    + mainACIItemComponentsMonitor.getRemainingComponents() );
+        }
+        
+        if ( isItemFirstACIItem )
+        {
+            l_ACIItem = new ItemFirstACIItem(
+                    m_identificationTag,
+                    m_precedence,
+                    m_authenticationLevel,
+                    m_protectedItems,
+                    m_itemPermissions );
+        }
+        else
+        {
+            l_ACIItem = new UserFirstACIItem(
+                    m_identificationTag,
+                    m_aciPrecedence,
+                    m_authenticationLevel,
+                    m_userClasses,
+                    m_userPermissions );
+        }
+        
     }
     ;
-
+    
+mainACIItemComponent
+{
+    log.debug( "entered mainACIItemComponent()" );
+}
+    :
+    aci_identificationTag
+    {
+        mainACIItemComponentsMonitor.useComponent( "identificationTag" );
+    }
+    | aci_precedence
+    {
+        mainACIItemComponentsMonitor.useComponent( "precedence" );
+    }
+    | aci_authenticationLevel
+    {
+        mainACIItemComponentsMonitor.useComponent( "authenticationLevel" );
+    }
+    | aci_itemOrUserFirst
+    {
+        mainACIItemComponentsMonitor.useComponent( "itemOrUserFirst" );
+    }
+    ;
+    exception
+    catch [IllegalArgumentException e]
+    {
+        throw new RecognitionException( e.getMessage() );
+    }
+    
 aci_identificationTag
 {
     log.debug( "entered aci_identificationTag()" );
@@ -306,12 +365,7 @@
             SEP ( SP )* itemPermissions
         ( SP )* CLOSE_CURLY
     {
-        m_ACIItem = new ItemFirstACIItem(
-                m_identificationTag,
-                m_precedence,
-                m_authenticationLevel,
-                m_protectedItems,
-                m_itemPermissions );
+        isItemFirstACIItem = true;
     }
     ;
 
@@ -326,12 +380,7 @@
             SEP ( SP )* userPermissions
         ( SP )* CLOSE_CURLY
     {
-        m_ACIItem = new UserFirstACIItem(
-                m_identificationTag,
-                m_aciPrecedence,
-                m_authenticationLevel,
-                m_userClasses,
-                m_userPermissions );
+        isItemFirstACIItem = false;
     }
     ;
 
@@ -651,26 +700,46 @@
 {
     log.debug( "entered itemPermission()" );
     l_itemPermission = null;
+    itemPermissionComponentsMonitor = new MandatoryAndOptionalComponentsMonitor( 
+            new String [] { "userClasses", "grantsAndDenials" }, new String [] { "precedence"
} );
 }
     :
     OPEN_CURLY ( SP )*
-        ( precedence ( SP )* 
-          ( SEP ) ( SP )* userClasses ( SP )*
-          ( SEP ) ( SP )* grantsAndDenials ( SP )*
-          {
-              l_itemPermission = new ItemPermission( m_precedence, m_grantsAndDenials, m_userClasses
);
-          }
-        |
-          userClasses ( SP )*
-          ( SEP ) ( SP )* grantsAndDenials ( SP )*
-          {
-              // precedence defaults to ACIItem precedence
-              l_itemPermission = new ItemPermission( m_aciPrecedence, m_grantsAndDenials,
m_userClasses );
-          }
-        )
+        anyItemPermission ( SP )*
+            ( SEP ( SP )* anyItemPermission ( SP )* )*
     CLOSE_CURLY
+    {
+        if ( !itemPermissionComponentsMonitor.finalStateValid() )
+        {
+            throw new RecognitionException( "Missing mandatory itemPermission components:
" 
+                    + itemPermissionComponentsMonitor.getRemainingComponents() );
+        }
+        
+        l_itemPermission = new ItemPermission( m_precedence, m_grantsAndDenials, m_userClasses
);
+    }
     ;
 
+anyItemPermission
+    :
+    precedence
+    {
+        itemPermissionComponentsMonitor.useComponent( "precedence" );
+    }
+    | userClasses
+    {
+        itemPermissionComponentsMonitor.useComponent( "userClasses" );
+    }
+    | grantsAndDenials
+    {
+        itemPermissionComponentsMonitor.useComponent( "grantsAndDenials" );
+    }
+    ;
+    exception
+    catch [IllegalArgumentException e]
+    {
+        throw new RecognitionException( e.getMessage() );
+    }
+
 grantsAndDenials
 {
     log.debug( "entered grantsAndDenials()" );
@@ -883,25 +952,45 @@
 {
     log.debug( "entered userPermission()" );
     l_userPermission = null;
+    userPermissionComponentsMonitor = new MandatoryAndOptionalComponentsMonitor( 
+             new String [] { "protectedItems", "grantsAndDenials" }, new String [] { "precedence"
} );
 }
+     :
+     OPEN_CURLY ( SP )*
+         anyUserPermission ( SP )*
+             ( SEP ( SP )* anyUserPermission ( SP )* )*
+     CLOSE_CURLY
+     {
+         if ( !userPermissionComponentsMonitor.finalStateValid() )
+         {
+             throw new RecognitionException( "Missing mandatory userPermission components:
" 
+                     + userPermissionComponentsMonitor.getRemainingComponents() );
+         }
+         
+         l_userPermission = new UserPermission( m_aciPrecedence, m_grantsAndDenials, m_protectedItems
);
+     }
+     ;
+
+anyUserPermission
     :
-    OPEN_CURLY ( SP )*
-        ( precedence ( SP )* 
-          ( SEP ) ( SP )* protectedItems ( SP )*
-          ( SEP ) ( SP )* grantsAndDenials ( SP )*
-          {
-              l_userPermission = new UserPermission(m_precedence, m_grantsAndDenials, m_protectedItems
);
-          }
-        |
-          protectedItems ( SP )*
-          ( SEP ) ( SP )* grantsAndDenials ( SP )*
-          {
-              // precedence defaults to ACIItem precedence
-              l_userPermission = new UserPermission(m_aciPrecedence, m_grantsAndDenials,
m_protectedItems );
-          }
-        )
-    CLOSE_CURLY
+    precedence
+    {
+        userPermissionComponentsMonitor.useComponent( "precedence" );
+    }
+    | protectedItems
+    {
+        userPermissionComponentsMonitor.useComponent( "protectedItems" );
+    }
+    | grantsAndDenials
+    {
+        userPermissionComponentsMonitor.useComponent( "grantsAndDenials" );
+    }
     ;
+    exception
+    catch [IllegalArgumentException e]
+    {
+        throw new RecognitionException( e.getMessage() );
+    }
 
 subtreeSpecification returns [SubtreeSpecification ss]
 {

Added: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/AbstractSimpleComponentsMonitor.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/AbstractSimpleComponentsMonitor.java?rev=327718&view=auto
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/AbstractSimpleComponentsMonitor.java
(added)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/AbstractSimpleComponentsMonitor.java
Sat Oct 22 16:27:14 2005
@@ -0,0 +1,59 @@
+/*
+ *   Copyright 2005 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.ldap.common.util;
+
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+
+public abstract class AbstractSimpleComponentsMonitor implements ComponentsMonitor
+{
+    private List components;
+
+    public AbstractSimpleComponentsMonitor( String [] components )
+    {
+        // register components
+        this.components = new LinkedList( Arrays.asList( components ) );
+    }
+    
+    public ComponentsMonitor useComponent( String component ) throws IllegalArgumentException
+    {
+        if ( !components.remove( component ) )
+        {
+            throw new IllegalArgumentException( "Unregistered or previously used component:
" + component );
+        }
+        
+        return this;
+    }
+
+    public boolean allComponentsUsed()
+    {
+        return components.isEmpty();
+    }
+
+    public List getRemainingComponents()
+    {
+        return Collections.unmodifiableList( components );
+    }
+
+    public abstract boolean finalStateValid();
+}

Added: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/ComponentsMonitor.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/ComponentsMonitor.java?rev=327718&view=auto
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/ComponentsMonitor.java
(added)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/ComponentsMonitor.java
Sat Oct 22 16:27:14 2005
@@ -0,0 +1,12 @@
+package org.apache.ldap.common.util;
+
+import java.util.List;
+
+public interface ComponentsMonitor
+{
+    public ComponentsMonitor useComponent( String component ) throws IllegalArgumentException;
+    public boolean allComponentsUsed();
+    public boolean finalStateValid();
+    public List getRemainingComponents();
+    
+}

Added: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryAndOptionalComponentsMonitor.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryAndOptionalComponentsMonitor.java?rev=327718&view=auto
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryAndOptionalComponentsMonitor.java
(added)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryAndOptionalComponentsMonitor.java
Sat Oct 22 16:27:14 2005
@@ -0,0 +1,97 @@
+/*
+ *   Copyright 2005 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.ldap.common.util;
+
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+
+public class MandatoryAndOptionalComponentsMonitor implements ComponentsMonitor
+{
+    private ComponentsMonitor mandatoryComponentsMonitor;
+    private ComponentsMonitor optionalComponentsMonitor;
+    
+    public MandatoryAndOptionalComponentsMonitor( String [] mandatoryComponents,
+            String [] optionalComponents ) throws IllegalArgumentException
+    {
+        // check for common elements
+        for ( int i = 0; i < mandatoryComponents.length; i++ )
+        {
+            for ( int j = 0; j < optionalComponents.length; j++ )
+            {
+                if ( mandatoryComponents[i].equals( optionalComponents[j] ) )
+                {
+                    throw new IllegalArgumentException( 
+                            "Common element, \"" + mandatoryComponents[i] + 
+                            "\" detected for Mandatory and Optional components." );
+                }
+            }
+        }
+        
+        mandatoryComponentsMonitor = new MandatoryComponentsMonitor( mandatoryComponents
);
+        optionalComponentsMonitor = new OptionalComponentsMonitor( optionalComponents );
+    }
+
+    public ComponentsMonitor useComponent( String component )
+    {
+        try
+        {
+            mandatoryComponentsMonitor.useComponent( component );
+        }
+        catch ( IllegalArgumentException e1 )
+        {
+            try
+            {
+                optionalComponentsMonitor.useComponent( component );
+            }
+            catch ( IllegalArgumentException e2 )
+            {
+                throw new IllegalArgumentException( 
+                        "Unregistered or previously used component: " + component );
+            }
+        }
+        
+        return this;
+    }
+
+    public boolean allComponentsUsed()
+    {
+        return ( mandatoryComponentsMonitor.allComponentsUsed() && 
+            optionalComponentsMonitor.allComponentsUsed() );
+    }
+
+    public boolean finalStateValid()
+    {
+        return ( mandatoryComponentsMonitor.finalStateValid() && 
+                optionalComponentsMonitor.finalStateValid() );
+    }
+
+    public List getRemainingComponents()
+    {
+        List remainingComponents = new LinkedList();
+        
+        remainingComponents.addAll( mandatoryComponentsMonitor.getRemainingComponents() );
+        remainingComponents.addAll( optionalComponentsMonitor.getRemainingComponents() );
+        
+        return Collections.unmodifiableList( remainingComponents );
+    }
+
+}

Added: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryComponentsMonitor.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryComponentsMonitor.java?rev=327718&view=auto
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryComponentsMonitor.java
(added)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/MandatoryComponentsMonitor.java
Sat Oct 22 16:27:14 2005
@@ -0,0 +1,33 @@
+/*
+ *   Copyright 2005 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.ldap.common.util;
+
+
+public class MandatoryComponentsMonitor extends AbstractSimpleComponentsMonitor
+{
+    public MandatoryComponentsMonitor( String [] components )
+    {
+        super( components );
+    }
+
+    public boolean finalStateValid()
+    {
+        return allComponentsUsed();
+    }
+}

Added: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/OptionalComponentsMonitor.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/OptionalComponentsMonitor.java?rev=327718&view=auto
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/OptionalComponentsMonitor.java
(added)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/util/OptionalComponentsMonitor.java
Sat Oct 22 16:27:14 2005
@@ -0,0 +1,33 @@
+/*
+ *   Copyright 2005 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.ldap.common.util;
+
+
+public class OptionalComponentsMonitor extends AbstractSimpleComponentsMonitor
+{
+    public OptionalComponentsMonitor( String [] components )
+    {
+        super( components );
+    }
+
+    public boolean finalStateValid()
+    {
+        return true;
+    }
+}

Modified: directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/aci/ACIItemParserTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/aci/ACIItemParserTest.java?rev=327718&r1=327717&r2=327718&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/aci/ACIItemParserTest.java
(original)
+++ directory/shared/ldap/trunk/common/src/test/org/apache/ldap/common/aci/ACIItemParserTest.java
Sat Oct 22 16:27:14 2005
@@ -122,7 +122,7 @@
     }
     
     
-    public void testItemFirstOrderOfProtectedItemsDoesNotMatter() throws Exception
+    public void testOrderOfProtectedItemsDoesNotMatter() throws Exception
     {
         String spec = " {  identificationTag  \"id1\" , precedence 114  , authenticationLevel
simple  , " +
                 "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3  
 , ou }, entry , " +
@@ -136,7 +136,7 @@
         parser.parse(spec);
     }
     
-    public void testUserFirstOrderOfUserClassesDoesNotMatter() throws Exception
+    public void testOrderOfUserClassesDoesNotMatter() throws Exception
     {
         String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel
none  , " +
                 "itemOrUserFirst userFirst:  { userClasses {  name { \"ou=people,cn=ersin\"
}, allUsers, " +
@@ -148,7 +148,7 @@
         parser.parse(spec);
     }
     
-    public void testItemFirstOrderOfProtectedItemsDoesNotMatterButDuplicatesMatter() throws
Exception
+    public void testOrderOfProtectedItemsDoesNotMatterButDuplicatesMatter() throws Exception
     {
         String spec = " {  identificationTag  \"id1\" , precedence 114  , authenticationLevel
simple  , " +
                 "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3  
 , ou }, entry, entry , " +
@@ -170,7 +170,7 @@
         }
     }
     
-    public void testUserFirstOrderOfUserClassesDoesNotMatterButDuplicatesMatter() throws
Exception
+    public void testOrderOfUserClassesDoesNotMatterButDuplicatesMatter() throws Exception
     {
         String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel
none  , " +
                 "itemOrUserFirst userFirst:  { userClasses {  name { \"ou=people,cn=ersin\"
}, allUsers, allUsers, " +
@@ -189,4 +189,106 @@
             assertNotNull( e );
         }
     }
+        
+    public void testItemPermissionComponentsOrderDoesNotMatter() throws Exception
+    {
+        String spec = " {  identificationTag  \"id1\" , precedence 114  , authenticationLevel
simple  , " +
+                "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3  
 , ou }, entry , " +
+                " rangeOfValues (cn=ErsinEr) , attributeValue { ou=people  , cn=Ersin  },"
+
+                "classes and : { item: xyz , or:{item:X,item:Y}   }}  , " +
+                "itemPermissions { { grantsAndDenials  {  denyCompare  , grantModify }, userClasses
{allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } " +
+                " , subtree { { base \"ou=people\" } } }   }," +
+                "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\"
} " +
+                " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare
 , grantModify } } } }}";
+
+        parser.parse( spec );
+    }
+    
+    public void testItemPermissionComponentsOrderDoesNotMatterButDuplicatesMatter() throws
Exception
+    {
+        String spec = " {  identificationTag  \"id1\" , precedence 114  , authenticationLevel
simple  , " +
+                "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3  
 , ou }, entry , " +
+                " rangeOfValues (cn=ErsinEr) , attributeValue { ou=people  , cn=Ersin  },"
+
+                "classes and : { item: xyz , or:{item:X,item:Y}   }}  , " +
+                "itemPermissions { { userClasses {allUsers  , userGroup { \"1.2=y,z=t\" 
, \"a=b,c=d\" } " +
+                " , subtree { { base \"ou=people\" } } }, grantsAndDenials  {  denyCompare
 , grantModify }, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } " +
+                " , subtree { { base \"ou=people\" } } }   }," +
+                "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\"
} " +
+                " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare
 , grantModify } } } }}";
+
+        try
+        {
+            parser.parse(spec);
+            fail( "testItemPermissionComponentsOrderDoesNotMatterButDuplicatesMatter() should
not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+    
+    public void testUserPermissionComponentsOrderDoesNotMatter() throws Exception
+    {
+        String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel
none  , " +
+                "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\"
}, " +
+                "subtree {{ base \"ou=system\", specificationFilter and:{ } }, { base \"ou=ORGANIZATIONUNIT\","
+
+                "minimum  1, maximum   2 } } }  , " +
+                "userPermissions { { grantsAndDenials { grantBrowse }, protectedItems{ entry
 , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , " +
+                "rangeOfValues (cn=ErsinEr) }  } } }  }   ";
+        
+        parser.parse( spec );
+    }
+    
+    public void testUserPermissionComponentsOrderDoesNotMatterButDuplicatesMatter() throws
Exception
+    {
+        String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel
none  , " +
+                "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\"
}, " +
+                "subtree {{ base \"ou=system\", specificationFilter and:{ } }, { base \"ou=ORGANIZATIONUNIT\","
+
+                "minimum  1, maximum   2 } } }  , " +
+                "userPermissions { { grantsAndDenials { grantBrowse }, grantsAndDenials {
grantBrowse }, protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l}
, " +
+                "rangeOfValues (cn=ErsinEr) }  } } }  }   ";
+        
+        try
+        {
+            parser.parse(spec);
+            fail( "testUserPermissionComponentsOrderDoesNotMatterButDuplicatesMatter() should
not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+    
+    public void testOrderOfMainACIComponentsDoesNotMatter() throws Exception
+    {
+        String spec = "{   itemOrUserFirst userFirst:  { userClasses {  allUsers  , name
{ \"ou=people,cn=ersin\" }, " +
+                "subtree {{ base \"ou=system\", specificationFilter and:{ } }, { base \"ou=ORGANIZATIONUNIT\","
+
+                "minimum  1, maximum   2 } } }  , " +
+                "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }
 , attributeValue {x=y,m=n,k=l} , " +
+                "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } },
" +
+                " identificationTag \"id2\"   , authenticationLevel none, precedence 14 }
  ";
+
+        parser.parse( spec );
+    }
+    
+    public void testOrderOfMainACIComponentsDoesNotMatterButDuplicatesMatter() throws Exception
+    {
+        String spec = "{   itemOrUserFirst userFirst:  { userClasses {  allUsers  , name
{ \"ou=people,cn=ersin\" }, " +
+                "subtree {{ base \"ou=system\", specificationFilter and:{ } }, { base \"ou=ORGANIZATIONUNIT\","
+
+                "minimum  1, maximum   2 } } }  , " +
+                "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }
 , attributeValue {x=y,m=n,k=l} , " +
+                "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } },
" +
+                " identificationTag \"id2\"   , authenticationLevel none, authenticationLevel
simple, precedence 14 }   ";
+
+        try
+        {
+            parser.parse(spec);
+            fail( "testOrderOfMainACIComponentsDoesNotMatterButDuplicatesMatter() should
not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+    
 }



Mime
View raw message