directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10076 - in incubator/directory/snickers/trunk: ber/src/java/org/apache/snickers/ber ber/src/java/org/apache/snickers/ber/digester/rules ber/src/java/org/apache/snickers/ber/primitives ldap-ber-provider/src/java/org/apache/snickers/ldap ldap-ber-provider/src/test/org/apache/snickers/ldap
Date Sun, 18 Apr 2004 03:39:37 GMT
Author: akarasulu
Date: Sat Apr 17 20:39:36 2004
New Revision: 10076

Added:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TagEnum.java  
(contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
  (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindSimpleCredentialsRuleTest.java
  (contents, props changed)
Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRule.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindRequestRule.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
Log:
Commiting Changes ...

o added new type safe enum base TagEnum for prefab tags
o made UniversalTag and LdapTag extend TagEnum
o added rule for setting simple bind credentials
o added empty testcase for bind credentials
o modified PrimitiveOctetStringRule to be extensible so other app rules can 
  extend it: this was done so BindSimpleCredentialsRule can extend it but 
  this will not be the last time this basic rule is extended.  The idea is
  to have any application specific rule be able to extend it.


Added: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TagEnum.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TagEnum.java	Sat
Apr 17 20:39:36 2004
@@ -0,0 +1,55 @@
+/*
+ *   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 ;
+
+
+import org.apache.commons.lang.enum.ValuedEnum ;
+
+
+/**
+ * Abstract base class for type safe tag enumerations following the agreed upon
+ * convention for representing tags as integers.  This way the type safe
+ * enumeration also represents a preconstructed tag.  ASN.1 application module
+ * specific enumerations should extend this base for use with the digester.
+ *
+ * @see <a href="">link to a document explaining how we encoded prefab tags</a>
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public abstract class TagEnum extends ValuedEnum
+{
+    /** the id for this tag */
+    private final int id ;
+
+
+    protected TagEnum( final String name, final int value, final int id )
+    {
+        super( name, value ) ;
+        this.id = id ;
+    }
+
+
+    /**
+     * Gets the id of this tag.
+     *
+     * @return the id of the tag
+     */
+    public final int getTagId()
+    {
+        return this.id ;
+    }
+}

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRule.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/rules/PrimitiveOctetStringRule.java
Sat Apr 17 20:39:36 2004
@@ -19,6 +19,7 @@
 
 import org.apache.snickers.ber.Length ;
 import org.apache.snickers.ber.TypeClass ;
+import org.apache.snickers.ber.TagEnum;
 import org.apache.snickers.ber.digester.AbstractRule ;
 import org.apache.snickers.ber.primitives.UniversalTag ;
 
@@ -38,9 +39,12 @@
  */
 public class PrimitiveOctetStringRule extends AbstractRule
 {
-    private ByteAccumulator accumulator = new ByteAccumulator( 0 ) ;
-    /** used to determin if our type is constructed or primitive */
+    /** used to accumulate value bytes */
+    private final ByteAccumulator accumulator = new ByteAccumulator( 0 ) ;
+    /** used to determine if our type is constructed or primitive */
     private boolean isConstructed = false ;
+    /** the tag to be accepted which defaults to an UNIVERSAL OCTET_STRING */
+    private final TagEnum tag ;
 
 
     // -----------------------------------------------------------------------
@@ -49,10 +53,26 @@
 
 
     /**
-     * Creates a rule using defaults.
+     * Creates a rule using defaults where only the OCTET_STRING tag id
+     * is accepted.
      */
-    PrimitiveOctetStringRule()
+    public PrimitiveOctetStringRule()
     {
+        tag = UniversalTag.OCTET_STRING ;
+    }
+
+
+    /**
+     * Creates a rule where only a specific tag is accepted.  Sometimes
+     * OCTET_STRING fields are tagged with application specific tags.  In
+     * this case we match for a different tag.
+     *
+     *
+     * @param tag the tag to accept
+     */
+    public PrimitiveOctetStringRule( TagEnum tag )
+    {
+        this.tag = tag ;
     }
 
 
@@ -61,8 +81,10 @@
     // -----------------------------------------------------------------------
 
 
-    /* (non-Javadoc)
-     * @see org.apache.snickers.ber.Rule#tag(int, boolean,
+    /**
+     * Rejects tag id's that are not equal to this Rules's id.
+     *
+     * @see org.apache.snickers.ber.digester.Rule#tag(int, boolean,
      * org.apache.snickers.ber.TypeClass)
      */
     public void tag( int id, boolean isPrimitive, TypeClass typeClass )
@@ -74,11 +96,11 @@
             return ;
         }
 
-        if ( id != UniversalTag.OCTET_STRING.getTagId() )
+        if ( this.tag.getTagId() != id )
         {
             throw new IllegalArgumentException(
-                    "Expecting " + UniversalTag.OCTET_STRING.getName()
-                    + " with an id of " + UniversalTag.OCTET_STRING.getTagId()
+                    "Expecting " + this.tag.getName()
+                    + " with an id of " + this.tag.getTagId()
                     + " but instead got a tag id of " + id ) ;
         }
     }

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/primitives/UniversalTag.java
Sat Apr 17 20:39:36 2004
@@ -21,13 +21,14 @@
 import java.util.List ;
 
 import org.apache.commons.lang.enum.EnumUtils ;
-import org.apache.commons.lang.enum.ValuedEnum ;
+
+import org.apache.snickers.ber.TagEnum ;
 
 
 /**
- * Type safe enum for ASN.1 UNIVERSAL class tags.  The tags values are 
+ * Type safe enum for ASN.1 UNIVERSAL class tags.  The tags values are
  * constructed using the SNACC representation for tags without the 
- * primitive/constructed bit.  This is done because several bit, octet and 
+ * primitive/constructed bit.  This is done because several bit, octet and
  * character string types can be encoded as primitives or as constructed types 
  * to chunk the value out.
  * <p>
@@ -73,137 +74,137 @@
  * Apache Directory Project</a>
  * @version $Rev$
  */
-public class UniversalTag extends ValuedEnum
+public class UniversalTag extends TagEnum
 {
     /** value for the tag */
-    public static final int RESERVED0_VAL =                 0x00000000 ;
+    private static final int RESERVED0_VAL =                 0x00000000 ;
     /** value for the tag */
-    public static final int BOOLEAN_VAL =                   0x01000000 ;
+    private static final int BOOLEAN_VAL =                   0x01000000 ;
     /** value for the tag */
-    public static final int INTEGER_VAL =                   0x02000000 ;
+    private static final int INTEGER_VAL =                   0x02000000 ;
     /** value for the tag */
-    public static final int BIT_STRING_VAL =                0x03000000 ;
+    private static final int BIT_STRING_VAL =                0x03000000 ;
     /** value for the tag */
-    public static final int OCTET_STRING_VAL =              0x04000000 ;
+    private static final int OCTET_STRING_VAL =              0x04000000 ;
     /** value for the tag */
-    public static final int NULL_VAL =                      0x05000000 ;
+    private static final int NULL_VAL =                      0x05000000 ;
     /** value for the tag */
-    public static final int OBJECT_IDENTIFIER_VAL =         0x06000000 ;
+    private static final int OBJECT_IDENTIFIER_VAL =         0x06000000 ;
     /** value for the tag */
-    public static final int OBJECT_DESCRIPTOR_VAL =         0x07000000 ;
+    private static final int OBJECT_DESCRIPTOR_VAL =         0x07000000 ;
     /** value for the tag */
-    public static final int EXTERNAL_INSTANCE_OF_VAL =      0x08000000 ;
+    private static final int EXTERNAL_INSTANCE_OF_VAL =      0x08000000 ;
     /** value for the tag */
-    public static final int REAL_VAL =                      0x09000000 ;
+    private static final int REAL_VAL =                      0x09000000 ;
     /** value for the tag */
-    public static final int ENUMERATED_VAL =                0x0a000000 ;
+    private static final int ENUMERATED_VAL =                0x0a000000 ;
     /** value for the tag */
-    public static final int EMBEDDED_PDV_VAL =              0x0b000000 ;
+    private static final int EMBEDDED_PDV_VAL =              0x0b000000 ;
     /** value for the tag */
-    public static final int UTF8_STRING_VAL =               0x0c000000 ;
+    private static final int UTF8_STRING_VAL =               0x0c000000 ;
     /** value for the tag */
-    public static final int RELATIVE_OID_VAL =              0x0d000000 ;
+    private static final int RELATIVE_OID_VAL =              0x0d000000 ;
     /** value for the tag */
-    public static final int RESERVED14_VAL =                0x0e000000 ;
+    private static final int RESERVED14_VAL =                0x0e000000 ;
     /** value for the tag */
-    public static final int RESERVED15_VAL =                0x0f000000 ;
+    private static final int RESERVED15_VAL =                0x0f000000 ;
     /** value for the tag */
-    public static final int SEQUENCE_SEQUENCE_OF_VAL =      0x10000000 ;
+    private static final int SEQUENCE_SEQUENCE_OF_VAL =      0x10000000 ;
     /** value for the tag */
-    public static final int SET_SET_OF_VAL =                0x11000000 ;
+    private static final int SET_SET_OF_VAL =                0x11000000 ;
     /** value for the tag */
-    public static final int NUMERIC_STRING_VAL =            0x12000000 ;
+    private static final int NUMERIC_STRING_VAL =            0x12000000 ;
     /** value for the tag */
-    public static final int PRINTABLE_STRING_VAL =          0x13000000 ;
+    private static final int PRINTABLE_STRING_VAL =          0x13000000 ;
     /** value for the tag */
-    public static final int TELETEX_STRING_VAL =            0x14000000 ;
+    private static final int TELETEX_STRING_VAL =            0x14000000 ;
     /** value for the tag */
-    public static final int VIDEOTEX_STRING_VAL =           0x15000000 ;
+    private static final int VIDEOTEX_STRING_VAL =           0x15000000 ;
     /** value for the tag */
-    public static final int IA5_STRING_VAL =                0x16000000 ;
+    private static final int IA5_STRING_VAL =                0x16000000 ;
     /** value for the tag */
-    public static final int UTC_TIME_VAL =                  0x17000000 ;
+    private static final int UTC_TIME_VAL =                  0x17000000 ;
     /** value for the tag */
-    public static final int GENERALIZED_TIME_VAL =          0x18000000 ;
+    private static final int GENERALIZED_TIME_VAL =          0x18000000 ;
     /** value for the tag */
-    public static final int GRAPHIC_STRING_VAL =            0x19000000 ;
+    private static final int GRAPHIC_STRING_VAL =            0x19000000 ;
     /** value for the tag */
-    public static final int VISIBLE_STRING_VAL =            0x1a000000 ;
+    private static final int VISIBLE_STRING_VAL =            0x1a000000 ;
     /** value for the tag */
-    public static final int GENERAL_STRING_VAL =            0x1b000000 ;
+    private static final int GENERAL_STRING_VAL =            0x1b000000 ;
     /** value for the tag */
-    public static final int UNIVERSAL_STRING_VAL =          0x1c000000 ;
+    private static final int UNIVERSAL_STRING_VAL =          0x1c000000 ;
     /** value for the tag */
-    public static final int CHARACTER_STRING_VAL =          0x1d000000 ;
+    private static final int CHARACTER_STRING_VAL =          0x1d000000 ;
     /** value for the tag */
-    public static final int BMP_STRING_VAL =                0x1e000000 ;
+    private static final int BMP_STRING_VAL =                0x1e000000 ;
     /** value for the tag */
-    public static final int RESERVED31_VAL =                0x1f000000 ;
+    private static final int RESERVED31_VAL =                0x1f000000 ;
 
     /** value for the tag */
-    public static final int RESERVED0_ID =                 0 ;
+    private static final int RESERVED0_ID =                 0 ;
     /** value for the tag */
-    public static final int BOOLEAN_ID =                   1 ;
+    private static final int BOOLEAN_ID =                   1 ;
     /** value for the tag */
-    public static final int INTEGER_ID =                   2 ;
+    private static final int INTEGER_ID =                   2 ;
     /** value for the tag */
-    public static final int BIT_STRING_ID =                3 ;
+    private static final int BIT_STRING_ID =                3 ;
     /** value for the tag */
-    public static final int OCTET_STRING_ID =              4 ;
+    private static final int OCTET_STRING_ID =              4 ;
     /** value for the tag */
-    public static final int NULL_ID =                      5 ;
+    private static final int NULL_ID =                      5 ;
     /** value for the tag */
-    public static final int OBJECT_IDENTIFIER_ID =         6 ;
+    private static final int OBJECT_IDENTIFIER_ID =         6 ;
     /** value for the tag */
-    public static final int OBJECT_DESCRIPTOR_ID =         7 ;
+    private static final int OBJECT_DESCRIPTOR_ID =         7 ;
     /** value for the tag */
-    public static final int EXTERNAL_INSTANCE_OF_ID =      8 ;
+    private static final int EXTERNAL_INSTANCE_OF_ID =      8 ;
     /** value for the tag */
-    public static final int REAL_ID =                      9 ;
+    private static final int REAL_ID =                      9 ;
     /** value for the tag */
-    public static final int ENUMERATED_ID =                10 ;
+    private static final int ENUMERATED_ID =                10 ;
     /** value for the tag */
-    public static final int EMBEDDED_PDV_ID =              11 ;
+    private static final int EMBEDDED_PDV_ID =              11 ;
     /** value for the tag */
-    public static final int UTF8_STRING_ID =               12 ;
+    private static final int UTF8_STRING_ID =               12 ;
     /** value for the tag */
-    public static final int RELATIVE_OID_ID =              13 ;
+    private static final int RELATIVE_OID_ID =              13 ;
     /** value for the tag */
-    public static final int RESERVED14_ID =                14 ;
+    private static final int RESERVED14_ID =                14 ;
     /** value for the tag */
-    public static final int RESERVED15_ID =                15 ;
+    private static final int RESERVED15_ID =                15 ;
     /** value for the tag */
-    public static final int SEQUENCE_SEQUENCE_OF_ID =      16 ;
+    private static final int SEQUENCE_SEQUENCE_OF_ID =      16 ;
     /** value for the tag */
-    public static final int SET_SET_OF_ID =                17 ;
+    private static final int SET_SET_OF_ID =                17 ;
     /** value for the tag */
-    public static final int NUMERIC_STRING_ID =            18 ;
+    private static final int NUMERIC_STRING_ID =            18 ;
     /** value for the tag */
-    public static final int PRINTABLE_STRING_ID =          19 ;
+    private static final int PRINTABLE_STRING_ID =          19 ;
     /** value for the tag */
-    public static final int TELETEX_STRING_ID =            20 ;
+    private static final int TELETEX_STRING_ID =            20 ;
     /** value for the tag */
-    public static final int VIDEOTEX_STRING_ID =           21 ;
+    private static final int VIDEOTEX_STRING_ID =           21 ;
     /** value for the tag */
-    public static final int IA5_STRING_ID =                22 ;
+    private static final int IA5_STRING_ID =                22 ;
     /** value for the tag */
-    public static final int UTC_TIME_ID =                  23 ;
+    private static final int UTC_TIME_ID =                  23 ;
     /** value for the tag */
-    public static final int GENERALIZED_TIME_ID =          24 ;
+    private static final int GENERALIZED_TIME_ID =          24 ;
     /** value for the tag */
-    public static final int GRAPHIC_STRING_ID =            25 ;
+    private static final int GRAPHIC_STRING_ID =            25 ;
     /** value for the tag */
-    public static final int VISIBLE_STRING_ID =            26 ;
+    private static final int VISIBLE_STRING_ID =            26 ;
     /** value for the tag */
-    public static final int GENERAL_STRING_ID =            27 ;
+    private static final int GENERAL_STRING_ID =            27 ;
     /** value for the tag */
-    public static final int UNIVERSAL_STRING_ID =          28 ;
+    private static final int UNIVERSAL_STRING_ID =          28 ;
     /** value for the tag */
-    public static final int CHARACTER_STRING_ID =          29 ;
+    private static final int CHARACTER_STRING_ID =          29 ;
     /** value for the tag */
-    public static final int BMP_STRING_ID =                30 ;
+    private static final int BMP_STRING_ID =                30 ;
     /** value for the tag */
-    public static final int RESERVED31_ID =                31 ;
+    private static final int RESERVED31_ID =                31 ;
 
     /** enum for the tag */
     public static final UniversalTag BOOLEAN = 
@@ -318,12 +319,9 @@
 
 
     // -----------------------------------------------------------------------
-    // Members
+    // C O N S T R U C T O R S
     // -----------------------------------------------------------------------
 
-    /** the id of the UNIVERSAL tag */
-    private final int id ;
-
 
     /**
      * Private constructor so no other instances can be created other than the
@@ -334,20 +332,13 @@
      */
     private UniversalTag( final String name, final int value, final int id )
     {
-        super( name, value ) ;
-        this.id = id ;
+        super( name, value, id ) ;
     }
 
 
-    /**
-     * Gets the id of the universal tag.
-     *
-     * @return the id of the universal tag
-     */
-    public int getTagId()
-    {
-        return this.id ;
-    }
+    // -----------------------------------------------------------------------
+    // Members
+    // -----------------------------------------------------------------------
 
 
     /**

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindRequestRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindRequestRule.java
(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindRequestRule.java
Sat Apr 17 20:39:36 2004
@@ -36,7 +36,8 @@
 {
     /** the tag nesting pattern without the constructed bits */
     private static final int[] NESTING_PATTERN = {
-        UniversalTag.SEQUENCE_SEQUENCE_OF_VAL, LdapTag.BIND_REQUEST_TAG
+        UniversalTag.SEQUENCE_SEQUENCE_OF.getValue(),
+        LdapTag.BIND_REQUEST.getValue()
     } ;
 
 

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/BindSimpleCredentialsRule.java
Sat Apr 17 20:39:36 2004
@@ -0,0 +1,83 @@
+/*
+ *   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.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
+
+import org.apache.ldap.common.message.BindRequest ;
+
+
+/**
+ * A BER digester rule used to populate the simple credentials of a
+ * BindRequest while decoding.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BindSimpleCredentialsRule extends PrimitiveOctetStringRule
+{
+    /**
+     * Creates a rule that
+     */
+    public BindSimpleCredentialsRule()
+    {
+        super( LdapTag.BIND_REQUEST ) ;
+    }
+
+
+    /**
+     * Allows the super method to push a ByteBuffer onto the top of the stack
+     * which contains the drained contents of the superclass' ByteAccumulator.
+     * This ByteBuffer is popped first then used to populate the credentials.
+     * There is no need to copy this buffer since it will not be used again
+     * by the ByteAccumulator of the superclass so we should be able to use
+     * the byte[] based backing store if one is present.  However it might
+     * have to be copied even then.  Situations requiring a copy are when the
+     * buffer has a limit less than the capacity or when there is no
+     * accessible array to the buffer.
+     *
+     * @see org.apache.snickers.ber.digester.Rule#finish()
+     */
+    public void finish()
+    {
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+        // peek at the BindRequest underneath whose creds we set
+        BindRequest req = ( BindRequest ) getDigester().peek() ;
+
+        byte[] credentials = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            credentials = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            credentials = new byte[buf.remaining()] ;
+            buf.get( credentials ) ;
+        }
+
+        req.setCredentials( credentials ) ;
+    }
+}

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 Apr 17 20:39:36 2004
@@ -18,11 +18,12 @@
 
 
 import org.apache.commons.lang.enum.EnumUtils ;
-import org.apache.commons.lang.enum.ValuedEnum ;
 
 import java.util.Map ;
 import java.util.List ;
 
+import org.apache.snickers.ber.TagEnum ;
+
 
 /**
  * Prefabricated LDAP tags encoded as integers.
@@ -30,57 +31,57 @@
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class LdapTag extends ValuedEnum
+public class LdapTag extends TagEnum
 {
     /** the bind request tag encoded as an integer */
-    public static final int BIND_REQUEST_TAG = 0x60000000 ;
+    private static final int BIND_REQUEST_TAG = 0x60000000 ;
     /** the bind response tag encoded as an integer */
-    public static final int BIND_RESPONSE_TAG = 0x61000000 ;
+    private static final int BIND_RESPONSE_TAG = 0x61000000 ;
 
     /** the unbind request tag encoded as an integer */
-    public static final int UNBIND_REQUEST_TAG = 0x42000000 ;
+    private static final int UNBIND_REQUEST_TAG = 0x42000000 ;
 
     /** the search request tag encoded as an integer */
-    public static final int SEARCH_REQUEST_TAG = 0x63000000 ;
+    private static final int SEARCH_REQUEST_TAG = 0x63000000 ;
     /** the search result entry response tag encoded as an integer */
-    public static final int SEARCH_RESULT_ENTRY_TAG = 0x64000000 ;
+    private static final int SEARCH_RESULT_ENTRY_TAG = 0x64000000 ;
     /** the search result done tag encoded as an integer */
-    public static final int SEARCH_RESULT_DONE_TAG = 0x65000000 ;
+    private static final int SEARCH_RESULT_DONE_TAG = 0x65000000 ;
     /** the search result reference response tag encoded as an integer */
-    public static final int SEARCH_RESULT_REFERENCE_TAG = 0x73000000 ;
+    private static final int SEARCH_RESULT_REFERENCE_TAG = 0x73000000 ;
 
     /** the modify request tag encoded as an integer */
-    public static final int MODIFY_REQUEST_TAG = 0x66000000 ;
+    private static final int MODIFY_REQUEST_TAG = 0x66000000 ;
     /** the modify response tag encoded as an integer */
-    public static final int MODIFY_RESPONSE_TAG = 0x67000000 ;
+    private static final int MODIFY_RESPONSE_TAG = 0x67000000 ;
 
     /** the add request tag encoded as an integer */
-    public static final int ADD_REQUEST_TAG = 0x68000000 ;
+    private static final int ADD_REQUEST_TAG = 0x68000000 ;
     /** the add response tag encoded as an integer */
-    public static final int ADD_RESPONSE_TAG = 0x69000000 ;
+    private static final int ADD_RESPONSE_TAG = 0x69000000 ;
 
     /** the delete request tag encoded as an integer */
-    public static final int DEL_REQUEST_TAG = 0x4a000000 ;
+    private static final int DEL_REQUEST_TAG = 0x4a000000 ;
     /** the delete response tag encoded as an integer */
-    public static final int DEL_RESPONSE_TAG = 0x6b000000 ;
+    private static final int DEL_RESPONSE_TAG = 0x6b000000 ;
 
     /** the modify dn request tag encoded as an integer */
-    public static final int MODIFYDN_REQUEST_TAG = 0x6c000000 ;
+    private static final int MODIFYDN_REQUEST_TAG = 0x6c000000 ;
     /** the modify dn response tag encoded as an integer */
-    public static final int MODIFYDN_RESPONSE_TAG = 0x6d000000 ;
+    private static final int MODIFYDN_RESPONSE_TAG = 0x6d000000 ;
 
     /** the compare request tag encoded as an integer */
-    public static final int COMPARE_REQUEST_TAG = 0x6e000000 ;
+    private static final int COMPARE_REQUEST_TAG = 0x6e000000 ;
     /** the compare response tag encoded as an integer */
-    public static final int COMPARE_RESPONSE_TAG = 0x6f000000 ;
+    private static final int COMPARE_RESPONSE_TAG = 0x6f000000 ;
 
     /** the abandon request tag encoded as an integer */
-    public static final int ABANDON_REQUEST_TAG = 0x50000000 ;
+    private static final int ABANDON_REQUEST_TAG = 0x50000000 ;
 
     /** the extended request tag encoded as an integer */
-    public static final int EXTENDED_REQUEST_TAG = 0x77000000 ;
+    private static final int EXTENDED_REQUEST_TAG = 0x77000000 ;
     /** the extended response tag encoded as an integer */
-    public static final int EXTENDED_RESPONSE_TAG = 0x78000000 ;
+    private static final int EXTENDED_RESPONSE_TAG = 0x78000000 ;
 
 
     // -----------------------------------------------------------------------
@@ -89,54 +90,54 @@
 
 
     /** the bind request id as an integer */
-    public static final int BIND_REQUEST_ID =               0 ;
+    private static final int BIND_REQUEST_ID =               0 ;
     /** the bind response id as an integer */
-    public static final int BIND_RESPONSE_ID =              1 ;
+    private static final int BIND_RESPONSE_ID =              1 ;
 
     /** the unbind request id as an integer */
-    public static final int UNBIND_REQUEST_ID =             2 ;
+    private static final int UNBIND_REQUEST_ID =             2 ;
 
     /** the search request id as an integer */
-    public static final int SEARCH_REQUEST_ID =             3 ;
+    private static final int SEARCH_REQUEST_ID =             3 ;
     /** the search result entry response id as an integer */
-    public static final int SEARCH_RESULT_ENTRY_ID =        4 ;
+    private static final int SEARCH_RESULT_ENTRY_ID =        4 ;
     /** the search result done id as an integer */
-    public static final int SEARCH_RESULT_DONE_ID =         5 ;
+    private static final int SEARCH_RESULT_DONE_ID =         5 ;
     /** the search result reference response id as an integer */
-    public static final int SEARCH_RESULT_REFERENCE_ID =    19 ;
+    private static final int SEARCH_RESULT_REFERENCE_ID =    19 ;
 
     /** the modify request id as an integer */
-    public static final int MODIFY_REQUEST_ID =             6 ;
+    private static final int MODIFY_REQUEST_ID =             6 ;
     /** the modify response id as an integer */
-    public static final int MODIFY_RESPONSE_ID =            7 ;
+    private static final int MODIFY_RESPONSE_ID =            7 ;
 
     /** the add request id as an integer */
-    public static final int ADD_REQUEST_ID =                8 ;
+    private static final int ADD_REQUEST_ID =                8 ;
     /** the add response id as an integer */
-    public static final int ADD_RESPONSE_ID =               9 ;
+    private static final int ADD_RESPONSE_ID =               9 ;
 
     /** the delete request id as an integer */
-    public static final int DEL_REQUEST_ID =                10 ;
+    private static final int DEL_REQUEST_ID =                10 ;
     /** the delete response id as an integer */
-    public static final int DEL_RESPONSE_ID =               11 ;
+    private static final int DEL_RESPONSE_ID =               11 ;
 
     /** the modify dn request id as an integer */
-    public static final int MODIFYDN_REQUEST_ID =           12 ;
+    private static final int MODIFYDN_REQUEST_ID =           12 ;
     /** the modify dn response id as an integer */
-    public static final int MODIFYDN_RESPONSE_ID =          13 ;
+    private static final int MODIFYDN_RESPONSE_ID =          13 ;
 
     /** the compare request id as an integer */
-    public static final int COMPARE_REQUEST_ID =            14 ;
+    private static final int COMPARE_REQUEST_ID =            14 ;
     /** the compare response id as an integer */
-    public static final int COMPARE_RESPONSE_ID =           15 ;
+    private static final int COMPARE_RESPONSE_ID =           15 ;
 
     /** the abandon request id as an integer */
-    public static final int ABANDON_REQUEST_ID =            16 ;
+    private static final int ABANDON_REQUEST_ID =            16 ;
 
     /** the extended request id as an integer */
-    public static final int EXTENDED_REQUEST_ID =           23 ;
+    private static final int EXTENDED_REQUEST_ID =           23 ;
     /** the extended response id as an integer */
-    public static final int EXTENDED_RESPONSE_ID =          24 ;
+    private static final int EXTENDED_RESPONSE_ID =          24 ;
 
     
     // -----------------------------------------------------------------------
@@ -204,10 +205,6 @@
     // Members
     // -----------------------------------------------------------------------
 
-    /** the id of the UNIVERSAL tag */
-    private final int id ;
-
-
     /**
      * Private constructor so no other instances can be created other than the
      * public static constants in this class.
@@ -217,19 +214,7 @@
      */
     private LdapTag( final String name, final int value, final int id )
     {
-        super( name, value ) ;
-        this.id = id ;
-    }
-
-
-    /**
-     * Gets the id of the universal tag.
-     *
-     * @return the id of the universal tag
-     */
-    public int getTagId()
-    {
-        return this.id ;
+        super( name, value, id ) ;
     }
 
 

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindSimpleCredentialsRuleTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/BindSimpleCredentialsRuleTest.java
Sat Apr 17 20:39:36 2004
@@ -0,0 +1,66 @@
+/*
+ *   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 ;
+
+
+/**
+ * Tests the BindSimpleCredentialsRule to make sure it behaves as expected.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BindSimpleCredentialsRuleTest extends TestCase
+{
+    /** a test instance */
+    BindSimpleCredentialsRule bindSimpleCredentialsRule ;
+
+
+    /**
+     * Resets the test instance.
+     *
+     * @throws Exception on super call
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp() ;
+        bindSimpleCredentialsRule = new BindSimpleCredentialsRule() ;
+    }
+
+
+    /**
+     * Clears (nulls out) the test instance.
+     *
+     * @throws Exception on super call
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown() ;
+        bindSimpleCredentialsRule = null ;
+    }
+
+
+    /**
+     * Tests the finish() method of this Rule.
+     */
+    public void testFinish()
+    {
+        fail( "test not implemented" ) ;
+    }
+}
\ No newline at end of file

Mime
View raw message