directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 20627 - in incubator/directory/snickers/trunk: . ber-codec/src/java/org/apache/snickers/ber ber-codec/src/java/org/apache/snickers/ber/primitives ber-codec/src/test/org/apache/snickers/ber codec-stateful/src/docbook codec-stateful/src/images ldap-ber-provider/src/docbook ldap-ber-provider/src/images ldap-ber-provider/src/java/org/apache/snickers/ldap ldap-ber-provider/src/test/org/apache/snickers/ldap ldap-ber-provider/src/test/org/apache/snickers/ldap/testutils
Date Sun, 30 May 2004 03:56:36 GMT
Author: akarasulu
Date: Sat May 29 20:56:35 2004
New Revision: 20627

Added:
   incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/primitives/ContextSpecificTag.java
  (contents, props changed)
   incubator/directory/snickers/trunk/codec-stateful/src/docbook/
   incubator/directory/snickers/trunk/codec-stateful/src/images/
   incubator/directory/snickers/trunk/ldap-ber-provider/src/docbook/
   incubator/directory/snickers/trunk/ldap-ber-provider/src/images/
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/CompareRequestRule.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/CompareRequestRuleTest.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/testutils/
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/testutils/RuleTestCase.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/testutils/TestUtils.java
  (contents, props changed)
Modified:
   incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Tag.java
   incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TagEnum.java
   incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/TagTest.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindResponseRuleTest.java
   incubator/directory/snickers/trunk/project.xml
Log:
Commit changes ...

 o added some directories that maven wanted
 o added Tag method to create a int encoded tag using our scheme
 o added a tag type for context specific tags
 o added digester factory for registering all the ldap rules in one place
 o added test utility classes
 o added req/resp rule pair for compare  



Modified: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Tag.java
==============================================================================
--- incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Tag.java
(original)
+++ incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/Tag.java
Sat May 29 20:56:35 2004
@@ -29,8 +29,11 @@
  */
 public class Tag
 {
-    /** tag mask for the primitive/constructed bit - 0010 0000 - 0x20 */
-    private static final int PRIMITIVE_MASK = 0x20 ;
+    /** tag flag for the primitive/constructed bit - 0010 0000 - 0x20 */
+    private static final int CONSTRUCTED_FLAG = 0x20 ;
+    /** tag mask for the primitive/constructed bit - 1101 1111 - 0xDF */
+    // private static final int CONSTRUCTED_MASK = ~CONSTRUCTED_FLAG ;
+
     /** tag mask for the short tag format - 0001 1111 - 0x1F */
     static final int SHORT_MASK = 0x1F ;
     /** tag mask for the long tag format - 0111 1111 - 0x7F */
@@ -38,6 +41,15 @@
     /** tag flag indicating the use of the long tag encoding form */
     private static final int LONG_FLAG = 0x80 ;
 
+    /** the max id size with one tag octet */
+    private static final int ONE_OCTET_IDMAX = 30 ;
+    /** the max id size with two tag octets */
+    private static final int TWO_OCTET_IDMAX = (1<<7)-1 ;
+    /** the max id size with three tag octets */
+    private static final int THREE_OCTET_IDMAX = (1<<14)-1 ;
+    /** the max id size with four tag octets */
+    private static final int FOUR_OCTET_IDMAX = (1<<21)-1 ;
+
     /** tag id */
     private int id = 0 ;
     /** whether or not this tag represents a primitive type */
@@ -195,6 +207,66 @@
     }
 
 
+    // ------------------------------------------------------------------------
+    // Utility Methods For Dealing With Tags and Tag Octets
+    // ------------------------------------------------------------------------
+
+
+    /**
+     *
+     *
+     * @param type
+     * @param id
+     * @param isConstructed
+     * @return
+     */
+    public final static int
+            getIntEncodedTag( TypeClass type, int id, boolean isConstructed )
+    {
+        int value = type.getValue() << 24 ;
+
+        if ( isConstructed )
+        {
+            value |= ( CONSTRUCTED_FLAG << 24 ) ;
+        }
+
+        if ( id <= ONE_OCTET_IDMAX )
+        {
+            value |= ( id << 24 ) ;
+        }
+        else if ( id <= TWO_OCTET_IDMAX )
+        {
+            value |= ( SHORT_MASK << 24 ) ;
+            value |= ( id & 0x0000007F ) << 16 ;
+        }
+        else if ( id <= THREE_OCTET_IDMAX )
+        {
+            value |= ( SHORT_MASK << 24 ) ;
+            value |= ( id & 0x00003F80 ) << 9 ;
+            value |= ( id & 0x0000007F ) << 8 ;
+            value |= 0x00800000 ;
+        }
+        else if ( id <= FOUR_OCTET_IDMAX )
+        {
+            value |= ( SHORT_MASK << 24 ) ;
+            value |= ( id & 0x001FC000 ) << 2 ;
+            value |= ( id & 0x00003F80 ) << 1 ;
+            value |= ( id & 0x0000007F ) ;
+            value |= 0x00808000 ;
+        }
+        else
+        {
+            String msg = "Id argument value of " + id
+                    + " was greater than the maximum supported id of "
+                    + FOUR_OCTET_IDMAX ;
+            throw new IllegalArgumentException( msg ) ;
+        }
+
+        return value ;
+    }
+
+
+
     /**
      * Gets the tag id of a TLV from tag octets.
      * 
@@ -278,7 +350,7 @@
      */
     public final static boolean isPrimitive( int octet )
     {
-        return ( octet & PRIMITIVE_MASK ) == 0 ;
+        return ( octet & CONSTRUCTED_FLAG ) == 0 ;
     }
 
 
@@ -290,6 +362,6 @@
      */
     public final static boolean isConstructed( int octet )
     {
-        return ( octet & PRIMITIVE_MASK ) == PRIMITIVE_MASK ;
+        return ( octet & CONSTRUCTED_FLAG ) == CONSTRUCTED_FLAG ;
     }
 }

Modified: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TagEnum.java
==============================================================================
--- incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TagEnum.java
(original)
+++ incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TagEnum.java
Sat May 29 20:56:35 2004
@@ -52,4 +52,26 @@
     {
         return this.id ;
     }
+
+
+    /**
+     * Gets the primitive version of a tag.
+     *
+     * @return the primitive version of a tag with the P/C bit set to 0
+     */
+    public final int getPrimitiveTag()
+    {
+        return getValue() & 0xDFFFFFFF ;
+    }
+
+
+    /**
+     * Gets the constructed version of a tag.
+     *
+     * @return the constructed version of a tag with the P/C bit set to 1
+     */
+    public final int getConstructedTag()
+    {
+        return getValue() | 0x20000000 ;
+    }
 }

Added: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/primitives/ContextSpecificTag.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/primitives/ContextSpecificTag.java
Sat May 29 20:56:35 2004
@@ -0,0 +1,40 @@
+/*
+ *   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.ber.primitives ;
+
+
+import org.apache.snickers.ber.TagEnum ;
+import org.apache.snickers.ber.Tag;
+import org.apache.snickers.ber.TypeClass;
+
+
+/**
+ * Easy to use tag with public constructor for the CONTEXT_SPECIFIC type class.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class ContextSpecificTag extends TagEnum
+{
+    public ContextSpecificTag( int id, boolean isConstructed )
+    {
+        super( ( isConstructed ? "constructed " : "primitive " )
+                + "[" + id + "]", Tag.getIntEncodedTag( TypeClass.CONTEXT_SPECIFIC,
+                        id, isConstructed ), id ) ;
+    }
+}

Modified: incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/TagTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/TagTest.java
(original)
+++ incubator/directory/snickers/trunk/ber-codec/src/test/org/apache/snickers/ber/TagTest.java
Sat May 29 20:56:35 2004
@@ -18,6 +18,7 @@
 
 
 import org.apache.commons.lang.ArrayUtils ;
+import org.apache.snickers.ber.primitives.UniversalTag;
 
 import junit.framework.TestCase ;
 
@@ -281,6 +282,66 @@
         catch ( Throwable t ) 
         {
             assertNotNull( t ) ;
+        }
+    }
+
+
+    public void testGetIntEncodedTag()
+    {
+        assertEquals( UniversalTag.INTEGER.getPrimitiveTag(),
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL,
+                        UniversalTag.INTEGER.getTagId(), false ) ) ;
+
+        assertEquals( 0x01000000,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, 1, false ) ) ;
+
+        assertEquals( 0x0F000000,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, 15, false ) ) ;
+
+        assertEquals( 0x1E000000,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, 30, false ) ) ;
+
+        assertEquals( 0x1F1F0000,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, 31, false ) ) ;
+
+        assertEquals( 0x1F7E0000,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, 126, false ) ) ;
+
+        assertEquals( 0x1F7F0000,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, 127, false ) ) ;
+
+        assertEquals( 0x1F810000,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, 128, false ) ) ;
+
+        assertEquals( 0x1F810100,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, 129, false ) ) ;
+
+        assertEquals( 0x3FFF7E00,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, (1<<14)-2, true ) ) ;
+
+        assertEquals( 0x1FFF7F00,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, (1<<14)-1, false ) ) ;
+
+        assertEquals( 0xDF818000,
+                Tag.getIntEncodedTag( TypeClass.PRIVATE, (1<<14), false ) ) ;
+
+        assertEquals( 0x5F818001,
+                Tag.getIntEncodedTag( TypeClass.APPLICATION, (1<<14)+1, false ) ) ;
+
+        assertEquals( 0x9FFFFF7E,
+                Tag.getIntEncodedTag( TypeClass.CONTEXT_SPECIFIC,
+                        (1<<21)-2, false ) ) ;
+
+        assertEquals( 0x1FFFFF7F,
+                Tag.getIntEncodedTag( TypeClass.UNIVERSAL, (1<<21)-1, false ) ) ;
+
+        try
+        {
+            Tag.getIntEncodedTag( TypeClass.UNIVERSAL, (1<<21), false ) ;
+            fail( "should never get here due to an exception" ) ;
+        }
+        catch( IllegalArgumentException e )
+        {
         }
     }
 }

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/CompareRequestRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/CompareRequestRule.java
Sat May 29 20:56:35 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.snickers.ldap ;
+
+
+/**
+ * Document this class.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class CompareRequestRule 
+{
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/CompareRequestRuleTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/CompareRequestRuleTest.java
Sat May 29 20:56:35 2004
@@ -0,0 +1,67 @@
+/*
+ *   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 java.nio.ByteBuffer ;
+
+import org.apache.ldap.common.message.* ;
+import org.apache.snickers.ber.TupleTreeDecoder ;
+import org.apache.snickers.ber.DefaultMutableTupleNode ;
+import org.apache.commons.codec.stateful.CallbackHistory ;
+
+
+/**
+ * Document this class.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class CompareRequestRuleTest
+{
+
+    public void testBindResponseOutput() throws Exception
+    {
+        // build the PDU
+        BindResponseImpl resp = new BindResponseImpl( 540 ) ;
+        resp.setServerSaslCreds( "hello".getBytes() ) ;
+        LdapResultImpl result = new LdapResultImpl( resp ) ;
+        result.setResultCode( ResultCodeEnum.BUSY ) ;
+        result.setErrorMessage( "An Error Message!" ) ;
+        result.setMatchedDn( "uid=akarasulu,dc=example,dc=com" ) ;
+        ReferralImpl referral = new ReferralImpl( result ) ;
+        referral.addLdapUrl( "hello" ) ;
+        referral.addLdapUrl( "world" ) ;
+        result.setReferral( referral ) ;
+        resp.setLdapResult( result ) ;
+        MessageEncoder encoder = new MessageEncoder() ;
+        byte[] pdu = encoder.encode( resp ) ;
+        ByteBuffer buf = ByteBuffer.wrap( pdu ) ;
+
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        CallbackHistory cb = new CallbackHistory() ;
+        decoder.setCallback( cb ) ;
+        decoder.decode( buf ) ;
+        DefaultMutableTupleNode node = ( DefaultMutableTupleNode ) cb.getMostRecent() ;
+        StringBuffer sb = new StringBuffer() ;
+        node.printDepthFirst( sb, 0 ) ;
+        System.out.println( sb.toString() ) ;
+    }
+
+
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java
Sat May 29 20:56:35 2004
@@ -0,0 +1,45 @@
+/*
+ *   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 org.apache.snickers.ber.digester.BERDigester;
+
+
+/**
+ * A factory that creates a digester for processing LDAPv3 message PDUs.
+ *
+ * @todo extract a protocol independent DigesterFactory interface from this and
+ * put it back into the ber-codec then have this class implement that interface.
+ * Determine if we want to have factories instantiate and configure (build?)
+ * digesters using configuration files?
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class LdapDigesterFactory
+{
+    public BERDigester create()
+    {
+        BERDigester digester = new BERDigester() ;
+
+        
+
+        return digester ;
+    }
+}

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
Sat May 29 20:56:35 2004
@@ -23,6 +23,7 @@
 import java.util.List ;
 
 import org.apache.snickers.ber.TagEnum ;
+import org.apache.snickers.ber.primitives.ContextSpecificTag;
 
 
 /**
@@ -36,7 +37,7 @@
     /** the bind request tag encoded as an integer */
     private static final int BIND_REQUEST_TAG = 0x60000000 ;
     /** the bind response tag encoded as an integer */
-    private static final int BIND_RESPONSE_TAG = 0x61000000 ;
+    private static final int BIND_RESPONSE_TAG = 0x41000000 ;
 
     /** the unbind request tag encoded as an integer */
     private static final int UNBIND_REQUEST_TAG = 0x42000000 ;
@@ -199,6 +200,14 @@
     public static final LdapTag EXTENDED_RESPONSE = new LdapTag(
             "EXTENDED_RESPONSE", EXTENDED_RESPONSE_TAG,
             EXTENDED_RESPONSE_ID ) ;
+
+    /** Context specific tag used for LDAPResult referrals */
+    public static final ContextSpecificTag REFERRAL_TAG =
+            new ContextSpecificTag( 3, true ) ;
+
+    /** Context specific tag used for BindResponse serverSaslCreds */
+    public static final ContextSpecificTag SERVER_SASL_CREDS_TAG =
+            new ContextSpecificTag( 7, true ) ;
 
 
     // -----------------------------------------------------------------------

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindResponseRuleTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindResponseRuleTest.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindResponseRuleTest.java
Sat May 29 20:56:35 2004
@@ -25,6 +25,7 @@
 import org.apache.snickers.ber.digester.BERDigester ;
 
 import org.apache.snickers.ber.* ;
+import org.apache.snickers.ber.primitives.UniversalTag;
 import org.apache.snickers.ber.digester.rules.PrimitiveIntDecodeRule ;
 import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
 
@@ -94,42 +95,52 @@
     {
         int[] pattern = new int[2] ;
 
-        pattern[0] = 0x10000000 ;
-        pattern[1] = 0x02000000 ;
+
+        // -------------------------------------------
+        // build pattern and addRule for the messageId
+        // -------------------------------------------
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = UniversalTag.INTEGER.getPrimitiveTag() ;
         digester.addRule( pattern, new PrimitiveIntDecodeRule() ) ;
 
-        // for the BindResponse and the LdapResult
-        pattern[1] = 0x41000000 ;
+
+        // -----------------------------------------------
+        // modify pattern and addRule for the BindResponse
+        // -----------------------------------------------
+        pattern[1] = LdapTag.BIND_RESPONSE.getPrimitiveTag() ;
         digester.addRule( pattern, new BindResponseRule() ) ;
 
+
+        // -----------------------------------------------
+        // modify pattern and addRule for the BindResponse
+        // -----------------------------------------------
         pattern = new int[3] ;
-        pattern[0] = 0x10000000 ;
-        pattern[1] = 0x41000000 ;
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.BIND_RESPONSE.getPrimitiveTag() ;
 
         // for the resultCode
-        pattern[2] = 0x0a000000 ;
-        digester.addRule( pattern, new ResultCodeRule() ) ;
+        pattern[2] = UniversalTag.ENUMERATED.getPrimitiveTag() ;
 
         // for matchedDN and errorMessage
-        pattern[2] = 0x04000000 ;
+        pattern[2] = UniversalTag.OCTET_STRING.getPrimitiveTag() ;
         digester.addRule( pattern, new ResultMatchedDNRule() ) ;
         digester.addRule( pattern, new ErrorMessageRule() ) ;
 
         // for referral
-        pattern[2] = 0x83000000 ;
+        pattern[2] = LdapTag.REFERRAL_TAG.getPrimitiveTag() ;
         digester.addRule( pattern, new ReferralRule() ) ;
 
         // for serverSaslCreds
-        pattern[2] = 0x87000000 ;
+        pattern[2] = LdapTag.SERVER_SASL_CREDS_TAG.getPrimitiveTag() ;
         TagEnum tag = new TagEnum( "ServerSaslCreds", 0x87000000, 7 ) {} ;
         digester.addRule( pattern, new PrimitiveOctetStringRule( tag ) ) ;
 
         // for LDAPURLs of referral
         pattern = new int[4] ;
-        pattern[0] = 0x10000000 ;
-        pattern[1] = 0x41000000 ;
-        pattern[2] = 0x83000000 ;
-        pattern[3] = 0x04000000 ;
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern[1] = LdapTag.BIND_RESPONSE.getPrimitiveTag() ;
+        pattern[2] = LdapTag.REFERRAL_TAG.getPrimitiveTag() ;
+        pattern[3] = UniversalTag.OCTET_STRING.getPrimitiveTag() ;
         digester.addRule( pattern, new ReferralUrlRule() ) ;
 
         // build the PDU

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/testutils/RuleTestCase.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/testutils/RuleTestCase.java
Sat May 29 20:56:35 2004
@@ -0,0 +1,36 @@
+/*
+ *   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.testutils ;
+
+
+import java.nio.ByteBuffer ;
+
+import junit.framework.TestCase ;
+import org.apache.ldap.common.message.Message ;
+
+
+/**
+ * Base test case used for testing the operation of digester rules.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public abstract class RuleTestCase extends TestCase
+{
+    protected abstract Message getTestMessage( Object[] args ) ;
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/testutils/TestUtils.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/testutils/TestUtils.java
Sat May 29 20:56:35 2004
@@ -0,0 +1,79 @@
+/*
+ *   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.testutils ;
+
+
+import java.nio.ByteBuffer ;
+
+import org.apache.commons.codec.stateful.CallbackHistory ;
+
+import org.apache.ldap.common.message.Message ;
+import org.apache.ldap.common.message.MessageEncoder ;
+
+import org.apache.snickers.ber.TupleTreeDecoder ;
+import org.apache.snickers.ber.DefaultMutableTupleNode ;
+
+
+/**
+ * Utilities functions for use by test cases and for debugging.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class TestUtils
+{
+    /**
+     * Generates the tuple tree for an LDAP Message PDU.
+     *
+     * @param pdu the LDAP message PDU to generate the tree for
+     * @return the root node of the tuple tree
+     * @throws Exception if there are any problems generating the Tuple tree
+     */
+    public static DefaultMutableTupleNode getTupleTree( Message pdu )
+            throws Exception
+    {
+        DefaultMutableTupleNode node = null ;
+        MessageEncoder encoder = new MessageEncoder() ;
+        ByteBuffer buf = ByteBuffer.wrap( encoder.encode( pdu ) ) ;
+        TupleTreeDecoder decoder = new TupleTreeDecoder() ;
+        CallbackHistory cb = new CallbackHistory() ;
+
+        decoder.setCallback( cb ) ;
+        decoder.decode( buf ) ;
+        node = ( DefaultMutableTupleNode ) cb.getMostRecent() ;
+        return node ;
+    }
+
+
+    /**
+     * Generates a string containing the pretty printed and nested tuple tree
+     * for an LDAP Message PDU.
+     *
+     * @param pdu the LDAP message PDU to print the tree for
+     * @return a string containing the pretty printed and nested tuple tree
+     * @throws Exception if there are any problems generating the Tuple tree
+     */
+    public static String printTupleTree( Message pdu ) throws Exception
+    {
+        DefaultMutableTupleNode node = null ;
+        StringBuffer sb = new StringBuffer() ;
+        node = getTupleTree( pdu ) ;
+        node.printDepthFirst( sb, 0 ) ;
+        return sb.toString() ;
+    }
+}

Modified: incubator/directory/snickers/trunk/project.xml
==============================================================================
--- incubator/directory/snickers/trunk/project.xml	(original)
+++ incubator/directory/snickers/trunk/project.xml	Sat May 29 20:56:35 2004
@@ -159,7 +159,7 @@
         </includes>
               
         <excludes>
-            <exclude></exclude>
+            <exclude>**/testutils/*</exclude>
         </excludes>
         
         <resources>

Mime
View raw message