directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r552349 - in /directory/shared/trunk/ldap/src: main/antlr/ACIItem.g main/java/org/apache/directory/shared/ldap/aci/ACIItemChecker.java test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
Date Sun, 01 Jul 2007 18:11:50 GMT
Author: ersiner
Date: Sun Jul  1 11:11:49 2007
New Revision: 552349

URL: http://svn.apache.org/viewvc?view=rev&rev=552349
Log:
Fix for DIRSERVER-891. Used the original ACIItem grammar instead of the light Checher grammar
for the Checker parser. Enabled commented out tests and they pass now.

Modified:
    directory/shared/trunk/ldap/src/main/antlr/ACIItem.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemChecker.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java

Modified: directory/shared/trunk/ldap/src/main/antlr/ACIItem.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/ACIItem.g?view=diff&rev=552349&r1=552348&r2=552349
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/ACIItem.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/ACIItem.g Sun Jul  1 11:11:49 2007
@@ -494,7 +494,10 @@
         // A Dn can be considered as a set of attributeTypeAndValues
         // So, parse the set as a Dn and extract each attributeTypeAndValue
         LdapDN attributeTypeAndValueSetAsDn = new LdapDN( token.getText() );
-        attributeTypeAndValueSetAsDn.normalize( oidsMap );
+        if ( oidsMap != null )
+        {        
+            attributeTypeAndValueSetAsDn.normalize( oidsMap );
+        }
         Enumeration attributeTypeAndValueSet = attributeTypeAndValueSetAsDn.getAll();
         while ( attributeTypeAndValueSet.hasMoreElements() )
         {
@@ -1159,7 +1162,10 @@
     token:SAFEUTF8STRING
     {
         name = new LdapDN( token.getText() );
-        name.normalize( oidsMap );
+        if ( oidsMap != null )
+        {
+            name.normalize( oidsMap );
+        }
         log.debug( "recognized a DistinguishedName: " + token.getText() );
     }
     ;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemChecker.java?view=diff&rev=552349&r1=552348&r2=552349
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemChecker.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemChecker.java
Sun Jul  1 11:11:49 2007
@@ -42,10 +42,10 @@
 public class ACIItemChecker
 {
     /** the antlr generated parser being wrapped */
-    private ReusableAntlrACIItemChecker checker;
+    private ReusableAntlrACIItemParser checker;
 
     /** the antlr generated lexer being wrapped */
-    private ReusableAntlrACIItemCheckerLexer lexer;
+    private ReusableAntlrACIItemLexer lexer;
 
     private final boolean isNormalizing;
 
@@ -55,27 +55,9 @@
      */
     public ACIItemChecker()
     {
-        this.lexer = new ReusableAntlrACIItemCheckerLexer( new StringReader( "" ) );
-        this.checker = new ReusableAntlrACIItemChecker( lexer );
-
-        this.checker.init(); // this method MUST be called while we cannot do
-        // constructor overloading for antlr generated parser
+        this.lexer = new ReusableAntlrACIItemLexer( new StringReader( "" ) );
+        this.checker = new ReusableAntlrACIItemParser( lexer );
         this.isNormalizing = false;
-    }
-
-
-    /**
-     * Creates a normalizing ACIItem parser.
-     */
-    public ACIItemChecker(NameComponentNormalizer normalizer, Map oidsMap )
-    {
-        this.lexer = new ReusableAntlrACIItemCheckerLexer( new StringReader( "" ) );
-        this.checker = new ReusableAntlrACIItemChecker( lexer );
-
-        this.checker.setNormalizer( normalizer );
-        this.checker.init(); // this method MUST be called while we cannot do
-        // constructor overloading for antlr generated parser
-        this.isNormalizing = true;
     }
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java?view=diff&rev=552349&r1=552348&r2=552349
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
Sun Jul  1 11:11:49 2007
@@ -258,37 +258,37 @@
     {
         String spec;
         
-//        // no name-value-pair
-//        spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none
 , "
-//            + "itemOrUserFirst userFirst:  { userPermissions { { protectedItems{ entry
 , attributeType { cn  , ou }  , attributeValue { must_be_a_name_value_pair } , "
-//            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } }, userClasses
{  allUsers  , name { \"ou=people,cn=ersin\" }, "
-//            + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
-//            + " maximum   2, minimum  1 } } }  }  }   ";
-//        try
-//        {
-//            checker.parse( spec );
-//            fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair
}'");
-//        }
-//        catch ( ParseException e )
-//        {
-//            // Expected
-//        }
-//        
-//        // no name-value-pair
-//        spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none
 , "
-//            + "itemOrUserFirst userFirst:  { userPermissions { { protectedItems{ entry
 , attributeType { cn  , ou }  , attributeValue { x=y,m=n,k=l,x } , "
-//            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } }, userClasses
{  allUsers  , name { \"ou=people,cn=ersin\" }, "
-//            + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
-//            + " maximum   2, minimum  1 } } }  }  }   ";
-//        try
-//        {
-//            checker.parse( spec );
-//            fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair
}'");
-//        }
-//        catch ( ParseException e )
-//        {
-//            // Expected
-//        }
+        // no name-value-pair
+        spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none 
, "
+            + "itemOrUserFirst userFirst:  { userPermissions { { protectedItems{ entry  ,
attributeType { cn  , ou }  , attributeValue { must_be_a_name_value_pair } , "
+            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } }, userClasses
{  allUsers  , name { \"ou=people,cn=ersin\" }, "
+            + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
+            + " maximum   2, minimum  1 } } }  }  }   ";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair
}'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        // no name-value-pair
+        spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none 
, "
+            + "itemOrUserFirst userFirst:  { userPermissions { { protectedItems{ entry  ,
attributeType { cn  , ou }  , attributeValue { x=y,m=n,k=l,x } , "
+            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } }, userClasses
{  allUsers  , name { \"ou=people,cn=ersin\" }, "
+            + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
+            + " maximum   2, minimum  1 } } }  }  }   ";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair
}'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
     }
     
     
@@ -310,38 +310,38 @@
             // Expected
         }
         
-//        spec = "{ identificationTag \"id2\" }";
-//        try
-//        {
-//            checker.parse( spec );
-//            fail("Expected ParseException, ACIItem is incomplete'");
-//        }
-//        catch ( ParseException e )
-//        {
-//            // Expected
-//        }
-//        
-//        spec = "{ identificationTag \"id2\", precedence 14 } ";
-//        try
-//        {
-//            checker.parse( spec );
-//            fail("Expected ParseException, ACIItem is incomplete'");
-//        }
-//        catch ( ParseException e )
-//        {
-//            // Expected
-//        }
-//        
-//        spec = "{ identificationTag \"id2\", precedence 14, authenticationLevel none }
";
-//        try
-//        {
-//            checker.parse( spec );
-//            fail("Expected ParseException, ACIItem is incomplete'");
-//        }
-//        catch ( ParseException e )
-//        {
-//            // Expected
-//        }
+        spec = "{ identificationTag \"id2\" }";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        spec = "{ identificationTag \"id2\", precedence 14 } ";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        spec = "{ identificationTag \"id2\", precedence 14, authenticationLevel none } ";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
     }
     
 }



Mime
View raw message