directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10086 - in incubator/directory/snickers/trunk: ber/src/java/org/apache/snickers/ber ber/src/java/org/apache/snickers/ber/digester ldap-ber-provider/src/java/org/apache/snickers/ldap ldap-ber-provider/src/test/org/apache/snickers/ldap
Date Sun, 18 Apr 2004 19:54:58 GMT
Author: akarasulu
Date: Sun Apr 18 12:54:49 2004
New Revision: 10086

Added:
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindRequestTest.java
  (contents, props changed)
Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/BERDigester.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
Log:
Commit changes ...

o found major digester bug where tags were not properly being popped off of the
  tagStack
o noticed and corrected flaw where Tuple was not copying the rawTag on clone
o fixed bind simple credentials to use a Context Specific tag of [0] instead
  of the UNIVERSAL OCTET STRING tag.



Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java	(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/Tuple.java	Sun
Apr 18 12:54:49 2004
@@ -379,6 +379,7 @@
     {
         Tuple t = new Tuple() ;
         t.id = id ;
+        t.rawTag = rawTag ;
         t.isPrimitive = isPrimitive ;
         t.typeClass = typeClass ;
         t.length = length ;

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/BERDigester.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/BERDigester.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/BERDigester.java
Sun Apr 18 12:54:49 2004
@@ -194,6 +194,12 @@
              */
             matched = rules.match( tagStack ) ;
             fireFinishEvent() ;
+            tagStack.pop() ;
+            
+            if ( BERDigester.this.tagStack.empty() )
+            {
+                BERDigester.this.decodeOccurred( getRoot() ) ;
+            }
         }
     }
 
@@ -1090,7 +1096,6 @@
                 {
                     rule = ( Rule ) matched.remove( j ) ;
                     rule.finish() ;
-                    tagStack.pop() ;
                     monitor.ruleCompleted( this, rule ) ;
                     seen.add( rule ) ;
                 } 

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
Sun Apr 18 12:54:49 2004
@@ -20,6 +20,7 @@
 import java.nio.ByteBuffer ;
 
 import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
+import org.apache.snickers.ber.TagEnum;
 
 import org.apache.ldap.common.message.BindRequest ;
 
@@ -33,6 +34,16 @@
  */
 public class BindSimpleCredentialsRule extends PrimitiveOctetStringRule
 {
+    private static final TagEnum TAG = new TagEnum(
+            "BindSimpleCredentials", 0x80000000, 0 ) {} ;
+
+
+    public BindSimpleCredentialsRule()
+    {
+        super( TAG ) ;
+    }
+
+
     /**
      * Allows the super method to push a ByteBuffer onto the top of the stack
      * which contains the drained contents of the superclass' ByteAccumulator.

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindRequestTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindRequestTest.java
Sun Apr 18 12:54:49 2004
@@ -0,0 +1,99 @@
+/*
+ *   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.snickers.ldap ;
+
+
+import junit.framework.TestCase ;
+
+import org.apache.commons.codec.stateful.CallbackHistory ;
+
+import org.apache.ldap.common.message.BindRequest ;
+import org.apache.ldap.common.message.MessageEncoder ;
+import org.apache.ldap.common.message.BindRequestImpl ;
+
+import org.apache.snickers.ber.digester.BERDigester ;
+import org.apache.snickers.ber.digester.rules.PrimitiveIntDecodeRule ;
+
+import java.nio.ByteBuffer ;
+
+
+/**
+ * Tests the capability to end to end decode a BindRequest.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BindRequestTest extends TestCase
+{
+    BERDigester digester ;
+    CallbackHistory history = new CallbackHistory() ;
+
+
+    protected void setUp() throws Exception
+    {
+        super.setUp() ;
+
+        digester = new BERDigester() ;
+        digester.setCallback( history ) ;
+
+        int[] msgIdPat = { 0x10000000, 0x02000000 } ;
+        digester.addRule( msgIdPat, new PrimitiveIntDecodeRule() ) ;
+
+        int[] reqPat = { 0x10000000, 0x40000000 } ;
+        digester.addRule( reqPat, new BindRequestRule() ) ;
+
+        int[] versionPat = { 0x10000000, 0x40000000, 0x02000000 } ;
+        digester.addRule( versionPat, new BindVersionRule() ) ;
+
+        int[] namePat = { 0x10000000, 0x40000000, 0x04000000 } ;
+        digester.addRule( namePat, new BindNameRule() ) ;
+
+        int[] credPat = { 0x10000000, 0x40000000, 0x80000000 } ;
+        digester.addRule( credPat, new BindSimpleCredentialsRule() ) ;
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown() ;
+        digester = null ;
+        history = null ;
+    }
+
+
+    /**
+     * Tests a simple bind request decode.
+     */
+    public void testSimple() throws Exception
+    {
+        BindRequestImpl req = new BindRequestImpl( 33 ) ;
+        req.setCredentials( "hello".getBytes() ) ;
+        req.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        req.setSimple( true ) ;
+        req.setVersion3( false ) ;
+        MessageEncoder encoder = new MessageEncoder() ;
+        ByteBuffer buf = ByteBuffer.wrap( encoder.encode( req ) ) ;
+        digester.decode( buf ) ;
+        BindRequest decoded = ( BindRequest ) digester.getRoot() ;
+        assertNotNull( decoded ) ;
+        assertTrue( "hello".equals( new String( decoded.getCredentials() ) ) ) ;
+        assertEquals( "uid=akarasulu,dc=example,dc=com", decoded.getName() ) ;
+        assertFalse( decoded.getVersion3() ) ;
+        assertTrue( decoded.getSimple() ) ;
+        assertSame( decoded, history.getMostRecent() ) ;
+    }
+}
\ No newline at end of file

Mime
View raw message