You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/09/09 23:43:24 UTC

svn commit: r279887 [9/15] - in /directory/shared/ldap/branches/elecharny-cleanup/apache2-provider: ./ conf/ perfs/ perfs/org/ perfs/org/apache/ perfs/org/apache/asn1new/ perfs/org/apache/asn1new/ber/ src/ src/java/ src/java/main/ src/java/main/org/ sr...

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,385 @@
+/*
+ *   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.asn1new.ldap.codec.utils;
+
+import org.apache.asn1new.util.StringUtils;
+
+/**
+ * Utility class used by the LdapDN Parser.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DNUtils
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** <safe-init-char>    ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39] | 0x3B | [0x3D-0x7F] */
+    private static final boolean[] SAFE_INIT_CHAR =
+    {
+        false, true, true, true, true, true, true, true, true, true, false, true, true, false,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, false, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, false,
+        true, false, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true
+    };
+
+    /** <safe-char>        ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F] */
+    private static final boolean[] SAFE_CHAR =
+    {
+        false, true, true, true, true, true, true, true, true, true, false, true, true, false,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true
+    };
+
+    /** <base64-char>    ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A] */
+    private static final boolean[] BASE64_CHAR =
+    {
+        false, false, false, false, false, false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, false, false, false, false, false,
+        false, false, false, false, true, false, false, false, true, true, true, true, true, true,
+        true, true, true, true, true, false, false, false, true, false, false, false, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, false, false, false, false, false,
+        false, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
+        true, true, true, true, true, true, true, true, true, true, true, true, false, false,
+        false, false, false
+    };
+
+    /** '"'  | '#'  | '+'  | ','  | [0-9] | ';'  | '<'  | '='  | '>'  | [A-F] | '\' | [a-f] 
+     * 0x22 | 0x23 | 0x2B | 0x2C | [0x30-0x39] | 0x3B | 0x3C | 0x3D | 0x3E | [0x41-0x46] | 0x5C | [0x61-0x66] */
+    private static final boolean[] PAIR_CHAR =
+    {
+        false, false, false, false, false, false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, true, true, false, false, false,
+        false, false, false, false, true, true, false, false, false, true, true, true, true, true,
+        true, true, true, true, true, false, true, true, true, true, false, false, true, true,
+        true, true, true, true, false, false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, false, false, false, false, true,
+        false, false, false, false, true, true, true, true, true, true, false, false, false, false,
+        false, false, false, false, false, false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false
+    };
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Walk the buffer while characters are Safe String characters :
+     *  <safe-string>    ::= <safe-init-char> <safe-chars>
+     *  <safe-init-char> ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39] | 0x3B | [0x3D-0x7F]
+     *  <safe-chars>     ::= <safe-char> <safe-chars> |
+     *  <safe-char>      ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F]
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not a Safe Char
+     */
+    public static int parseSafeString( byte[] byteArray, int index )
+    {
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+            return -1;
+        }
+        else
+        {
+            byte c = byteArray[index];
+
+            if ( ( c > 127 ) || ( SAFE_INIT_CHAR[c] == false ) )
+            {
+                return -1;
+            }
+
+            index++;
+
+            while ( index < byteArray.length )
+            {
+                c = byteArray[index];
+
+                if ( ( c > 127 ) || ( SAFE_CHAR[c] == false ) )
+                {
+                    break;
+                }
+
+                index++;
+            }
+
+            return index;
+        }
+    }
+
+    /**
+     * Walk the buffer while characters are Alpha characters :
+     *  <alpha>    ::= [0x41-0x5A] | [0x61-0x7A]
+     * 
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not an Alpha Char
+     */
+    public static int parseAlphaASCII( byte[] byteArray, int index )
+    {
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+            return -1;
+        }
+        else
+        {
+            byte c = byteArray[index++];
+
+            if ( ( c > 127 ) || ( StringUtils.ALPHA[c] == false ) )
+            {
+                return -1;
+            }
+            else
+            {
+                return index;
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a Pair Char
+     *  <pairchar>    ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [0-9a-fA-F] [0-9a-fA-F]
+     *  
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Pair Char
+     */
+    public static boolean isPairChar( byte[] byteArray, int index )
+    {
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+            return false;
+        }
+        else
+        {
+            byte c = byteArray[index];
+
+            if ( ( c > 127 ) || ( PAIR_CHAR[c] == false ) )
+            {
+                return false;
+            }
+            else
+            {
+                if ( StringUtils.isHex( byteArray, index++ ) )
+                {
+                    return StringUtils.isHex( byteArray, index );
+                }
+                else
+                {
+                    return true;
+                }
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a String Char.
+     * Chars are Unicode, not ASCII.
+     *  <stringchar>    ::= [0x00-0xFFFF] - [,=+<>#;\"\n\r]
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The current char if it is a String Char, or '#' (this is
+     * simpler than throwing an exception :)
+     */
+    public static int isStringChar( byte[] byteArray, int index )
+    {
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+            return -1;
+        }
+        else
+        {
+            byte c = byteArray[index];
+
+            if ( ( c == 0x0A ) ||
+                    ( c == 0x0D ) ||
+                    ( c == '"' ) ||
+                    ( c == '#' ) ||
+                    ( c == '+' ) ||
+                    ( c == ',' ) ||
+                    ( c == ';' ) ||
+                    ( c == '<' ) ||
+                    ( c == '=' ) ||
+                    ( c == '>' ) )
+            {
+                return -1;
+            }
+            else
+            {
+                return StringUtils.countBytesPerChar(byteArray, index);
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a Quote Char
+     * We are testing Unicode chars
+     *  <quotechar>    ::= [0x00-0xFFFF] - [\"]
+     * 
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Quote Char
+     */
+    public static int isQuoteChar( byte[] byteArray, int index )
+    {
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+            return -1;
+        }
+        else
+        {
+            byte c = byteArray[index];
+
+            if ( ( c == '\\' ) || ( c == '"' ) )
+            {
+                return -1;
+            }
+            else
+            {
+                return StringUtils.countBytesPerChar(byteArray, index);
+            }
+        }
+    }
+
+    /**
+     * Parse an hex pair
+     *   <hexpair>    ::= <hex> <hex>
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The new position, -1 if the buffer does not contain an HexPair, -2 if the
+     * buffer contains an hex byte but not two.
+     */
+    public static int parseHexPair( byte[] byteArray, int index )
+    {
+        if ( StringUtils.isHex( byteArray, index ) )
+        {
+            if ( StringUtils.isHex( byteArray, index + 1 ) )
+            {
+                return index + 2;
+            }
+            else
+            {
+                return -2;
+            }
+        }
+        else
+        {
+            return -1;
+        }
+    }
+
+    /**
+     * Parse an hex string, which is a list of hex pairs
+     *  <hexstring>    ::= <hexpair> <hexpairs>
+     *  <hexpairs>    ::= <hexpair> <hexpairs> | e
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return Return the first position which is not an hex pair, or -1 if there is no
+     * hexpair at the beginning or if an hexpair is invalid (if we have only one hex instead of 2)
+     */
+    public static int parseHexString( byte[] byteArray, int index )
+    {
+        int result = parseHexPair( byteArray, index );
+
+        if ( result < 0 )
+        {
+            return -1;
+        }
+        else
+        {
+            index += 2;
+        }
+
+        while ( ( result = parseHexPair( byteArray, index ) ) >= 0 )
+        {
+            index += 2;
+        }
+
+        return ( ( result == -2 ) ? -1 : index );
+    }
+
+    /**
+     * Walk the buffer while characters are Base64 characters : 
+     *     <base64-string>      ::= <base64-char> <base64-chars>
+     *  <base64-chars>       ::= <base64-char> <base64-chars> |
+     *  <base64-char>        ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A]
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not a Base64 Char
+     */
+    public static int parseBase64String( byte[] byteArray, int index )
+    {
+        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= byteArray.length ) )
+        {
+            return -1;
+        }
+        else
+        {
+            byte c = byteArray[index];
+
+            if ( ( c > 127 ) || ( BASE64_CHAR[c] == false ) )
+            {
+                return -1;
+            }
+
+            index++;
+
+            while ( index < byteArray.length )
+            {
+                c = byteArray[index];
+
+                if ( ( c > 127 ) || ( BASE64_CHAR[c] == false ) )
+                {
+                    break;
+                }
+
+                index++;
+            }
+
+            return index;
+        }
+    }
+
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,200 @@
+/*
+ *   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.asn1new.ldap.codec.utils;
+
+/**
+ * This typesafe-enum represent the different resultCode of a LdapResult.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapResultEnum
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    public static final int SUCCESS                   = 0 ;
+    public static final int OPERATIONS_ERROR          = 1 ;
+    public static final int PROTOCOL_ERROR            = 2 ;
+    public static final int TIME_LIMIT_EXCEEDED       = 3 ;
+    public static final int SIZE_LIMIT_EXCEEDED       = 4 ;
+    public static final int COMPARE_FALSE             = 5 ;
+    public static final int COMPARE_TRUE              = 6 ;
+    public static final int AUTH_METHOD_NOT_SUPPORTED = 7 ;
+    public static final int STRONG_AUTH_REQUIRED      = 8 ;
+
+    // -- 9 reserved --
+    public static final int RESERVED_9                     = 9 ;
+
+    public static final int REFERRAL                       = 10 ; // -- new
+    public static final int ADMIN_LIMIT_EXCEEDED           = 11 ; //  -- new
+    public static final int UNAVAILABLE_CRITICAL_EXTENSION = 12 ; //  -- new
+    public static final int CONFIDENTIALITY_REQUIRED  	   = 13 ; //  -- new
+    public static final int SASL_BIND_IN_PROGRESS     = 14 ; //  -- new
+    public static final int NO_SUCH_ATTRIBUTE         = 16 ;
+    public static final int UNDEFINED_ATTRIBUTE_TYPE  = 17 ;
+    public static final int INAPPROPRIATE_MATCHING    = 18 ;
+    public static final int CONSTRAINT_VIOLATION      = 19 ;
+    public static final int ATTRIBUTE_OR_VALUE_EXISTS = 20 ;
+    public static final int INVALID_ATTRIBUTE_SYNTAX = 21 ;
+
+    // -- 22-31 unused --
+    public static final int UNUSED_22         = 22 ;
+    public static final int UNUSED_23         = 23 ;
+    public static final int UNUSED_24         = 24 ;
+    public static final int UNUSED_25         = 25 ;
+    public static final int UNUSED_26         = 26 ;
+    public static final int UNUSED_27         = 27 ;
+    public static final int UNUSED_28         = 28 ;
+    public static final int UNUSED_29         = 29 ;
+    public static final int UNUSED_30         = 30 ;
+    public static final int UNUSED_31         = 31 ;
+
+    public static final int NO_SUCH_OBJECT    = 32 ;
+    public static final int ALIAS_PROBLEM     = 33 ;
+    public static final int INVALID_DN_SYNTAX = 34 ;
+
+    // Reserved
+    public static final int RESERVED_FOR_UNDEFINED_IS_LEAF = 35 ;
+    
+    public static final int ALIAS_DEREFERENCING_PROBLEM = 36 ;
+
+    //-- 37-47 unused --
+    public static final int UNUSED_37                    = 37 ;
+    public static final int UNUSED_38                    = 38 ;
+    public static final int UNUSED_39                    = 39 ;
+    public static final int UNUSED_40                    = 40 ;
+    public static final int UNUSED_41                    = 41 ;
+    public static final int UNUSED_42                    = 42 ;
+    public static final int UNUSED_43                    = 43 ;
+    public static final int UNUSED_44                    = 44 ;
+    public static final int UNUSED_45                    = 45 ;
+    public static final int UNUSED_46                    = 46 ;
+    public static final int UNUSED_47                    = 47 ;
+
+    public static final int INAPPROPRIATE_AUTHENTICATION = 48 ;
+    public static final int INVALID_CREDENTIALS          = 49 ;
+    public static final int INSUFFICIENT_ACCESS_RIGHTS   = 50 ;
+    public static final int BUSY                         = 51 ;
+    public static final int UNAVAILABLE                  = 52 ;
+    public static final int UNWILLING_TO_PERFORM         = 53 ;
+    public static final int LOOP_DETECT                  = 54 ;
+
+    // -- 55-63 unused --
+    public static final int UNUSED_55                    = 55 ;
+    public static final int UNUSED_56                    = 56 ;
+    public static final int UNUSED_57                    = 57 ;
+    public static final int UNUSED_58                    = 58 ;
+    public static final int UNUSED_59                    = 59 ;
+    public static final int UNUSED_60                    = 60 ;
+    public static final int UNUSED_61                    = 61 ;
+    public static final int UNUSED_62                    = 62 ;
+    public static final int UNUSED_63                    = 63 ;
+
+    public static final int NAMING_VIOLATION             = 64 ;
+    public static final int OBJECT_CLASS_VIOLATION       = 65 ;
+    public static final int NOT_ALLOWED_ON_NON_LEAF      = 66 ;
+    public static final int NOT_ALLOWED_ON_RDN           = 67 ;
+    public static final int ENTRY_ALREADY_EXISTS         = 68 ;
+    public static final int OBJECT_CLASS_MODS_PROHIBITED = 69 ;
+
+    // -- 70 reserved for CLDAP --
+    public static final int RESERVED_FOR_CLDAP    = 70 ;
+
+    public static final int AFFECTS_MULTIPLE_DSAS = 71 ; // -- new
+
+    // -- 72-79 unused --
+    public static final int UNUSED_72 = 72 ;
+    public static final int UNUSED_73 = 73 ;
+    public static final int UNUSED_74 = 74 ;
+    public static final int UNUSED_75 = 75 ;
+    public static final int UNUSED_76 = 76 ;
+    public static final int UNUSED_77 = 77 ;
+    public static final int UNUSED_78 = 78 ;
+    public static final int UNUSED_79 = 79 ;
+
+    public static final int OTHER = 80 ;
+
+    // -- 81-90 reserved for APIs --
+    public static final int RESERVED_FOR_APIS_81 = 81 ;
+    public static final int RESERVED_FOR_APIS_82 = 82 ;
+    public static final int RESERVED_FOR_APIS_83 = 83 ;
+    public static final int RESERVED_FOR_APIS_84 = 84 ;
+    public static final int RESERVED_FOR_APIS_85 = 85 ;
+    public static final int RESERVED_FOR_APIS_86 = 86 ;
+    public static final int RESERVED_FOR_APIS_87 = 87 ;
+    public static final int RESERVED_FOR_APIS_88 = 88 ;
+    public static final int RESERVED_FOR_APIS_89 = 89 ;
+    public static final int RESERVED_FOR_APIS_90 = 90 ;
+    
+    public static final String errorCode(int resultCode) 
+    {
+        switch (resultCode)
+        {
+        	case RESERVED_9 : return "Reserved (9)";
+        	case UNUSED_22  : return "Unused (22)";
+        	case UNUSED_23  : return "Unused (23)";
+        	case UNUSED_24  : return "Unused (24)";
+        	case UNUSED_25  : return "Unused (25)";
+        	case UNUSED_26  : return "Unused (26)";
+        	case UNUSED_27  : return "Unused (27)";
+        	case UNUSED_28  : return "Unused (28)";
+        	case UNUSED_29  : return "Unused (29)";
+        	case UNUSED_30  : return "Unused (30)";
+        	case UNUSED_31  : return "Unused (31)";
+        	case RESERVED_FOR_UNDEFINED_IS_LEAF : return "Reserved for undefined is leaf (35)";
+			case UNUSED_37 : return "unused (37)";
+			case UNUSED_38 : return "unused (38)";
+			case UNUSED_39 : return "unused (39)";
+			case UNUSED_40 : return "unused (40)";
+			case UNUSED_41 : return "unused (41)";
+			case UNUSED_42 : return "unused (42)";
+			case UNUSED_43 : return "unused (43)";
+			case UNUSED_44 : return "unused (44)";
+			case UNUSED_45 : return "unused (45)";
+			case UNUSED_46 : return "unused (46)";
+			case UNUSED_47 : return "unused (47)";
+			case UNUSED_55 : return "unused (55)";
+			case UNUSED_56 : return "unused (56)";
+			case UNUSED_57 : return "unused (57)";
+			case UNUSED_58 : return "unused (58)";
+			case UNUSED_59 : return "unused (59)";
+			case UNUSED_60 : return "unused (60)";
+			case UNUSED_61 : return "unused (61)";
+			case UNUSED_62 : return "unused (62)";
+			case UNUSED_63 : return "unused (63)";
+			case RESERVED_FOR_CLDAP : return "RESERVED_FOR_CLDAP (70)";
+			case UNUSED_72 : return "unused (72)";
+			case UNUSED_73 : return "unused (73)";
+			case UNUSED_74 : return "unused (74)";
+			case UNUSED_75 : return "unused (75)";
+			case UNUSED_76 : return "unused (76)";
+			case UNUSED_77 : return "unused (77)";
+			case UNUSED_78 : return "unused (78)";
+			case UNUSED_79 : return "unused (79)";
+			case RESERVED_FOR_APIS_81 : return "RESERVED_FOR_APIS (81)";
+			case RESERVED_FOR_APIS_82 : return "RESERVED_FOR_APIS (82)";
+			case RESERVED_FOR_APIS_83 : return "RESERVED_FOR_APIS (83)";
+			case RESERVED_FOR_APIS_84 : return "RESERVED_FOR_APIS (84)";
+			case RESERVED_FOR_APIS_85 : return "RESERVED_FOR_APIS (85)";
+			case RESERVED_FOR_APIS_86 : return "RESERVED_FOR_APIS (86)";
+			case RESERVED_FOR_APIS_87 : return "RESERVED_FOR_APIS (87)";
+			case RESERVED_FOR_APIS_88 : return "RESERVED_FOR_APIS (88)";
+			case RESERVED_FOR_APIS_89 : return "RESERVED_FOR_APIS (89)";
+			case RESERVED_FOR_APIS_90 : return "RESERVED_FOR_APIS (90)";
+        	default : return "UNKOWN";
+        }
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,159 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.codec.EncoderException;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A AbandonRequest Message. Its syntax is :
+ *   AbandonRequest ::= [APPLICATION 16] MessageID
+ *   MessageID ::= INTEGER (0 .. maxInt)
+ *   maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) --
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AbandonRequest extends LdapMessage
+{
+	/** The logger */
+    private static Logger log = LoggerFactory.getLogger( AbandonRequest.class );
+
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The abandoned message ID  */
+    private int abandonedMessageId;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new AbandonRequest object.
+     */
+    public AbandonRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the abandoned message ID
+     *
+     * @return Returns the abandoned MessageId.
+     */
+    public int getAbandonedMessageId()
+    {
+        return abandonedMessageId;
+    }
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.ABANDON_REQUEST;
+    }
+
+    /**
+     * Set the abandoned message ID
+     *
+     * @param abandonedMessageId The abandoned messageID to set.
+     */
+    public void setAbandonedMessageId( int abandonedMessageId )
+    {
+        this.abandonedMessageId = abandonedMessageId;
+    }
+
+    /**
+     * Compute the AbandonRequest length
+     * 
+     * AbandonRequest :
+     * 
+     * 0x50 0x0(1..4) abandoned MessageId
+     * 
+     * Length(AbandonRequest) = Length(0x50) + 1 + Length(abandoned MessageId)
+     */
+    public int computeLength()
+    {
+    	int length = 1 + 1 + Value.getNbBytes( abandonedMessageId );
+    	
+    	if ( log.isDebugEnabled() )
+    	{
+    		log.debug( "Message length : " + length );
+    	}
+    	
+        return length;
+    }
+    
+    /**
+     * Encode the AbandonRequest message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer )  throws EncoderException
+    {
+        if (buffer == null)
+        {
+        	log.error( "Cannot put a PDU in a null buffer !" );
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+        
+        try 
+        {
+            // The tag
+            buffer.put(LdapConstants.ABANDON_REQUEST_TAG);
+            
+            // The length. It has to be evaluated depending on 
+            // the abandoned messageId value.
+            buffer.put( (byte)Value.getNbBytes( abandonedMessageId ) );
+            
+            // The abandoned messageId
+            buffer.put( Value.getBytes( abandonedMessageId ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+        	log.error( "The PDU buffer size is too small !" );
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        return buffer;
+    }
+
+    /**
+     * Return a String representing an AbandonRequest
+     * 
+     * @return A String representing the AbandonRequest
+    */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Abandon Request :\n" );
+        sb.append( "        Message Id : " ).append( abandonedMessageId ).append( '\n' );
+
+        return sb.toString();
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,436 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import org.apache.asn1.codec.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.util.StringUtils;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+
+
+/**
+ * An AddRequest Message. Its syntax is :
+ *   AddRequest ::= [APPLICATION 8] SEQUENCE {
+ *              entry           LDAPDN,
+ *              attributes      AttributeList }
+ *
+ *   AttributeList ::= SEQUENCE OF SEQUENCE {
+ *              type    AttributeDescription,
+ *              vals    SET OF AttributeValue }
+ * 
+ *   AttributeValue ::= OCTET STRING
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AddRequest extends LdapMessage
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private transient static final Logger log = LoggerFactory.getLogger( AddRequest.class );
+
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The DN to be added. */
+    private LdapDN entry;
+
+    /** The attributes list. */
+    private Attributes attributes;
+
+    /** The current attribute being decoded */
+    private transient Attribute currentAttribute;
+
+    /** The add request length */
+    private transient int addRequestLength;
+    
+    /** The attributes length */
+    private transient int attributesLength;
+    
+    /** The list of all attributes length */
+    private transient List attributeLength;
+    
+    /** The list of all vals length */
+    private transient List valuesLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new AddRequest object.
+     */
+    public AddRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.ADD_REQUEST;
+    }
+
+    /**
+     * Initialize the ArrayList for attributes.
+     */
+    public void initAttributes()
+    {
+        attributes = new BasicAttributes( true );
+    }
+
+    /**
+     * Get the entry's attributes to be added
+     *
+     * @return Returns the attributes.
+     */
+    public Attributes getAttributes()
+    {
+        return attributes;
+    }
+
+    /**
+     * Create a new attributeValue
+     * 
+     * @param type The attribute's name (called 'type' in the grammar) 
+     */
+    public void addAttributeType( LdapString type )
+    {
+        currentAttribute = new BasicAttribute( type.toString().toLowerCase() );
+        attributes.put( currentAttribute );
+    }
+
+    /**
+     * Add a new value to the current attribute
+     * 
+     * @param value The value to be added
+     */
+    public void addAttributeValue( OctetString value )
+    {
+        currentAttribute.add( value );
+    }
+
+    /**
+     * Get the added DN
+     * 
+     * @return Returns the entry.
+     */
+    public String getEntry()
+    {
+        return ( ( entry == null ) ? "" : entry.toString() );
+    }
+
+    /**
+     * Set the added DN.
+     * 
+     * @param entry The entry to set.
+     */
+    public void setEntry( LdapDN entry )
+    {
+        this.entry = entry;
+    }
+
+    /**
+     * Compute the AddRequest length
+     * 
+     * AddRequest :
+     * 
+     * 0x68 L1
+     *  |
+     *  +--> 0x04 L2 entry
+     *  +--> 0x30 L3 (attributes)
+     *        |
+     *        +--> 0x30 L4-1 (attribute)
+     *        |     |
+     *        |     +--> 0x04 L5-1 type
+     *        |     +--> 0x31 L6-1 (values)
+     *        |           |
+     *        |           +--> 0x04 L7-1-1 value
+     *        |           +--> ...
+     *        |           +--> 0x04 L7-1-n value
+     *        |
+     *        +--> 0x30 L4-2 (attribute)
+     *        |     |
+     *        |     +--> 0x04 L5-2 type
+     *        |     +--> 0x31 L6-2 (values)
+     *        |           |
+     *        |           +--> 0x04 L7-2-1 value
+     *        |           +--> ...
+     *        |           +--> 0x04 L7-2-n value
+     *        |
+     *        +--> ...
+     *        |
+     *        +--> 0x30 L4-m (attribute)
+     *              |
+     *              +--> 0x04 L5-m type
+     *              +--> 0x31 L6-m (values)
+     *                    |
+     *                    +--> 0x04 L7-m-1 value
+     *                    +--> ...
+     *                    +--> 0x04 L7-m-n value
+     * 
+     */
+    public int computeLength()
+    {
+        // The entry
+        addRequestLength = 1 + Length.getNbBytes( entry.getLength() ) + entry.getLength();
+        
+        // The attributes sequence
+        attributesLength = 0;
+        
+        if ( ( attributes != null ) && ( attributes.size() != 0 ) )
+        {
+            NamingEnumeration attributeIterator = attributes.getAll();
+            attributeLength = new LinkedList();
+            valuesLength = new LinkedList();
+            
+            // Compute the attributes length
+            while ( attributeIterator.hasMoreElements() )
+            {
+                Attribute attribute = (Attribute)attributeIterator.nextElement();
+                int localAttributeLength = 0;
+                int localValuesLength = 0;
+                
+                // Get the type length
+                int idLength = attribute.getID().getBytes().length;
+                localAttributeLength = 1 + Length.getNbBytes( idLength ) + idLength;
+                
+                // The values
+                try
+                {
+	                NamingEnumeration values = attribute.getAll();
+	                
+	                if ( values.hasMoreElements() )
+	                {
+                        localValuesLength = 0;
+	                    
+		                while ( values.hasMoreElements() )
+		                {
+		                    OctetString value = (OctetString)values.next();
+		                    
+                            localValuesLength += 1 + Length.getNbBytes( value.getLength() ) + value.getLength();
+		                }
+
+                        localAttributeLength += 1 + Length.getNbBytes( localValuesLength ) + localValuesLength; 
+	                }
+	                
+                }
+                catch (NamingException ne)
+                {
+                    return 0;
+                }
+                
+                // add the attribute length to the attributes length
+                attributesLength += 1 + Length.getNbBytes( localAttributeLength ) + localAttributeLength;
+                
+                attributeLength.add( new Integer( localAttributeLength ) );
+                valuesLength.add( new Integer( localValuesLength ) );
+            }
+        }
+        
+        addRequestLength += 1 + Length.getNbBytes( attributesLength ) + attributesLength;
+
+        // Return the result.
+        int result = 1 + Length.getNbBytes( addRequestLength ) + addRequestLength; 
+        
+        if ( log.isDebugEnabled() )
+        {
+        	log.debug( "AddRequest PDU length = " + result );
+        }
+        
+        return result;
+    }
+    
+    /**
+     * Encode the AddRequest message to a PDU.
+     * 
+     * AddRequest :
+     * 
+     * 0x68 LL
+     *   0x04 LL entry
+     *   0x30 LL attributesList
+     *     0x30 LL attributeList
+     *       0x04 LL attributeDescription
+     *       0x31 LL attributeValues
+     *         0x04 LL attributeValue
+     *         ... 
+     *         0x04 LL attributeValue
+     *     ... 
+     *     0x30 LL attributeList
+     *       0x04 LL attributeDescription
+     *       0x31 LL attributeValue
+     *         0x04 LL attributeValue
+     *         ... 
+     *         0x04 LL attributeValue 
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+        }
+
+        try 
+        {
+            // The AddRequest Tag
+            buffer.put( LdapConstants.ADD_REQUEST_TAG );
+            buffer.put( Length.getBytes( addRequestLength ) ) ;
+            
+            // The entry
+            Value.encode( buffer, entry );
+            
+            // The attributes sequence
+            buffer.put( UniversalTag.SEQUENCE_TAG );
+            buffer.put( Length.getBytes( attributesLength ) ) ;
+
+            // The partial attribute list
+            if ( ( attributes != null ) && ( attributes.size() != 0 ) )
+            {
+                NamingEnumeration attributeIterator = attributes.getAll();
+                int attributeNumber = 0;
+                
+                // Compute the attributes length
+                while ( attributeIterator.hasMoreElements() )
+                {
+                    Attribute attribute = (Attribute)attributeIterator.nextElement();
+                    
+                    // The attributes list sequence
+                    buffer.put( UniversalTag.SEQUENCE_TAG );
+                    int localAttributeLength = ( (Integer)attributeLength.get( attributeNumber ) ).intValue();
+                    buffer.put( Length.getBytes( localAttributeLength ) );
+
+                    // The attribute type
+                    Value.encode( buffer, attribute.getID() );
+                    
+                    // The values
+                    buffer.put( UniversalTag.SET_TAG );
+                    int localValuesLength = ( (Integer)valuesLength.get( attributeNumber ) ).intValue();
+                    buffer.put( Length.getBytes( localValuesLength ) );
+                    
+                    try
+                    {
+                        NamingEnumeration values = attribute.getAll();
+                        
+                        if ( values.hasMoreElements() )
+                        {
+                            while ( values.hasMoreElements() )
+                            {
+                                OctetString value = (OctetString)values.next();
+                                
+                                Value.encode( buffer, value );
+                            }
+                        }
+                        
+                    }
+                    catch (NamingException ne)
+                    {
+                        throw new EncoderException("Cannot enumerate the values");
+                    }
+                    
+                    // Go to the next attribute number;
+                    attributeNumber++;
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        if ( log.isDebugEnabled() )
+        {
+        	log.debug( "AddRequest encoding : " + StringUtils.dumpBytes( buffer.array() ) );
+        	log.debug( "AddRequest initial value : " + toString() );
+        }
+        
+        return buffer;
+    }
+
+    /**
+     * Return a String representing an AddRequest
+     * 
+     * @return A String representing the AddRequest
+    */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Add Request\n" );
+        sb.append( "        Entry : '" ).append( entry.toString() ).append( "'\n" );
+
+        if ( attributes != null )
+        {
+            sb.append( "        Attributes\n" );
+
+            NamingEnumeration attributesIterator = attributes.getAll();
+            
+            while (attributesIterator.hasMoreElements())
+            {
+                Attribute attribute = ( Attribute ) attributesIterator.nextElement();
+
+                sb.append( "           Type : '" ).append( attribute.getID() ).append( "'\n" );
+
+                for ( int j = 0; j < attribute.size(); j++ )
+                {
+
+                    try
+                    {
+
+                        OctetString attributeValue = ( OctetString ) attribute.get( j );
+                        sb.append( "               Val[" ).append( j ).append( "] : " )
+                          .append( attributeValue.toString() ).append( " \n" );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        log.error( "Naming exception will printing the '" + attribute.getID() +
+                            "'" );
+                    }
+
+                }
+            }
+        }
+
+        return sb.toString();
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,119 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.codec.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * An AddResponse Message. Its syntax is :
+ *   AddResponse ::= [APPLICATION 9] LDAPResult
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AddResponse extends LdapResponse
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new AddResponse object.
+     */
+    public AddResponse()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.ADD_RESPONSE;
+    }
+
+    /**
+     * Compute the AddResponse length
+     * 
+     * AddResponse :
+     * 
+     * 0x69 L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(AddResponse) = Length(0x69) + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        int ldapResponseLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+    }
+
+    /**
+     * Encode the AddResponse message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer )  throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+        
+        try
+        {
+            // The tag
+            buffer.put( LdapConstants.ADD_RESPONSE_TAG );
+            buffer.put( Length.getBytes( getLdapResponseLength() ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        // The ldapResult
+        return super.encode( buffer);
+    }
+
+    /**
+     * Get a String representation of an AddResponse
+     *
+     * @return An AddResponse String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Add Response\n" );
+        sb.append( super.toString() );
+
+        return sb.toString();
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,156 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+
+
+/**
+ * A class to store an attribute value assertion. Tha grammar is :
+ * 
+ * AttributeValueAssertion ::= SEQUENCE {
+ *           attributeDesc   AttributeDescription,
+ *           assertionValue  AssertionValue }
+ *
+ * AttributeDescription ::= LDAPString
+ * 
+ * AssertionValue ::= OCTET STRING
+ *                
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AttributeValueAssertion
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The attribute description */
+    private LdapString attributeDesc;
+
+    /** The assertion value */
+    private OctetString assertionValue;
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the assertion value 
+     *
+     * @return Returns the assertionValue.
+     */
+    public OctetString getAssertionValue()
+    {
+        return assertionValue;
+    }
+
+    /**
+     * Set the assertion value
+     *
+     * @param assertionValue The assertionValue to set.
+     */
+    public void setAssertionValue( OctetString assertionValue )
+    {
+        this.assertionValue = assertionValue;
+    }
+
+    /**
+     * Get the attribute description
+     *
+     * @return Returns the attributeDesc.
+     */
+    public String getAttributeDesc()
+    {
+        return ( ( attributeDesc == null ) ? null : attributeDesc.toString() );
+    }
+
+    /**
+     * Set the attribute description
+     *
+     * @param attributeDesc The attributeDesc to set.
+     */
+    public void setAttributeDesc( LdapString attributeDesc )
+    {
+        this.attributeDesc = attributeDesc;
+    }
+
+    /**
+     * Get a String representation of an AttributeValueAssertion
+     *
+     * @param tabs The spacing to be put before the string 
+     * @return An AttributeValueAssertion String 
+     */
+    public String toString( String tabs )
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( tabs ).append( "AttributeValueAssertion\n" );
+        sb.append( tabs ).append( "    Assertion description : '" )
+          .append( attributeDesc.toString() ).append( "'\n" );
+        sb.append( tabs ).append( "    Assertion value : '" ).append( assertionValue.toString() )
+          .append( "'\n" );
+
+        return sb.toString();
+    }
+
+    /**
+     * Get a String representation of an AttributeValueAssertion,
+     * as of RFC 2254.
+     *
+     * @param filterType The filter type 
+     * @return An AttributeValueAssertion String 
+     */
+    public String toStringRFC2254( int filterType)
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( attributeDesc.toString() );
+        
+        switch (filterType)
+        {
+        	case LdapConstants.EQUALITY_MATCH_FILTER :
+        	    sb.append( '=' );
+        		break;
+        		
+        	case LdapConstants.LESS_OR_EQUAL_FILTER :
+        	    sb.append( "<=" );
+        		break;
+        		
+        	case LdapConstants.GREATER_OR_EQUAL_FILTER :
+        	    sb.append( ">=" );
+        		break;
+        		
+        	case LdapConstants.APPROX_MATCH_FILTER :
+        	    sb.append( "~=" );
+        		break;
+        }
+        
+        sb.append( assertionValue.toString() );
+
+        return sb.toString();
+    }
+
+    /**
+     * Get a String representation of an AttributeValueAssertion
+     * 
+     * @return An AttributeValueAssertion String
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,272 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.codec.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+
+
+/**
+ * A BindRequest ldapObject. It's a sub-class of Asn1Object, and it extends
+ * the Asn1Object class to be seen as a member of the LdapMessage
+ * CHOICE.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class BindRequest extends LdapMessage
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The protocol Version to use. Should be 3 */
+    private int version;
+
+    /** The name of the user requesting a bind */
+    private LdapDN name;
+
+    /** The authentication used to bind the user */
+    private LdapAuthentication authentication;
+    
+    /** The bind request length */
+    private transient int bindRequestLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new BindRequest object.
+     */
+    public BindRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.BIND_REQUEST;
+    }
+
+    /**
+     * Get the user authentication
+     *
+     * @return The user authentication
+     */
+    public LdapAuthentication getAuthentication()
+    {
+        return authentication;
+    }
+
+    /**
+     * Get the user simple authentication
+     *
+     * @return The simple user authentication
+     */
+    public SimpleAuthentication getSimpleAuthentication()
+    {
+        return ( SimpleAuthentication ) authentication;
+    }
+
+    /**
+     * Get the user sasl authentication
+     *
+     * @return The sasl user authentication
+     */
+    public SaslCredentials getSaslAuthentication()
+    {
+        return ( SaslCredentials ) authentication;
+    }
+
+    /**
+     * Set the user authentication
+     *
+     * @param authentication The user authentication
+     */
+    public void setAuthentication( LdapAuthentication authentication )
+    {
+        this.authentication = authentication;
+    }
+
+    /**
+     * Get the user name
+     *
+     * @return The user name
+     */
+    public String getName()
+    {
+        return ( ( name == null ) ? null : name.toString() );
+    }
+
+    /**
+     * Set the user name
+     *
+     * @param name The user name
+     */
+    public void setName( LdapDN name )
+    {
+        this.name = name;
+    }
+
+    /**
+     * Get the protocol version
+     *
+     * @return The protocol version
+     */
+    public int getVersion()
+    {
+        return version;
+    }
+
+    /**
+     * Check if the Ldap version in use is 3
+     * 
+     * @return true if the ldap version is 3
+     */
+    public boolean isLdapV3()
+    {
+        return version == 3;
+    }
+
+    /**
+     * Set the protocol version
+     *
+     * @param version The protocol version
+     */
+    public void setVersion( int version )
+    {
+        this.version = version;
+    }
+
+    /**
+     * Compute the BindRequest length
+     * 
+     * BindRequest :
+     * 
+     * 0x60 L1
+     *  |
+     *  +--> 0x02 0x01 (1..127) version
+     *  +--> 0x04 L2 name
+     *  +--> authentication
+     * 
+     * L2 = Length(name)
+     * L3/4 = Length(authentication) 
+     * 
+     * Length(BindRequest) = Length(0x60) + Length(L1) + L1
+     *                       + Length(0x02) + 1 + 1
+     *                       + Length(0x04) + Length(L2) + L2 
+     *                       + Length(authentication)
+     */
+    public int computeLength()
+    {
+        bindRequestLength = 1 + 1 + 1; // Initialized with version
+        
+        // The name
+        bindRequestLength += 1 + Length.getNbBytes( name.getLength() ) + name.getLength();
+        
+        // The authentication
+        bindRequestLength += authentication.computeLength();
+
+        // Return the result.
+        return 1 + Length.getNbBytes( bindRequestLength ) + bindRequestLength;
+    }
+    
+    /**
+     * Encode the BindRequest message to a PDU.
+     * 
+     * BindRequest :
+     * 
+     * 0x60 LL
+     *   0x02 LL version
+     *   0x04 LL name
+     *   authentication.encode()
+     *     0x80 LL simple
+     *    /
+     *    \
+     *     0x83 LL mechanism
+     *     [0x04 LL credential]
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+        }
+
+        try 
+        {
+            // The BindRequest Tag
+            buffer.put( LdapConstants.BIND_REQUEST_TAG );
+            buffer.put( Length.getBytes( bindRequestLength ) ) ;
+
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        // The version
+        Value.encode( buffer, version );
+        
+        // The name
+        Value.encode( buffer, name );
+        
+        // The authentication
+        authentication.encode( buffer );
+
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of a BindRequest
+     *
+     * @return A BindRequest String 
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    BindRequest\n" );
+        sb.append( "        Version : '" ).append( version ).append( "'\n" );
+        sb.append( "        Name : '" ).append( name.toString() ).append( "'\n" );
+
+        if ( authentication instanceof SimpleAuthentication )
+        {
+            sb.append( "        Simple authentication : '" )
+              .append( ( ( SimpleAuthentication ) authentication ).toString() ).append(
+                "'\n" );
+        }
+        else
+        {
+            sb.append( ( ( SaslCredentials ) authentication ).toString() );
+        }
+
+        return sb.toString();
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,180 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.codec.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * A BindResponse Message. Its syntax is :
+ *   BindResponse ::= [APPLICATION 1] SEQUENCE {
+ *       COMPONENTS OF LDAPResult,
+ *       serverSaslCreds    [7] OCTET STRING OPTIONAL }
+ * 
+ *   LdapResult ::= resultCode matchedDN errorMessage (referrals)*
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class BindResponse extends LdapResponse
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The server credentials */
+    private OctetString serverSaslCreds;
+    
+    /** The bind response length */
+    private transient int bindResponseLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new BindResponse object.
+     */
+    public BindResponse()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.BIND_RESPONSE;
+    }
+
+    /**
+     * @return Returns the serverSaslCreds.
+     */
+    public OctetString getServerSaslCreds()
+    {
+        return serverSaslCreds;
+    }
+
+    /**
+	 * Set the server sasl credentials
+     * @param serverSaslCreds The serverSaslCreds to set.
+     */
+    public void setServerSaslCreds( OctetString serverSaslCreds )
+    {
+        this.serverSaslCreds = serverSaslCreds;
+    }
+    
+    /**
+     * Compute the BindResponse length
+     * 
+     * BindResponse :
+     * 
+     * 0x61 L1
+     *  |
+     *  +--> LdapResult
+     *  +--> [serverSaslCreds]
+     * 
+     * L1 = Length(LdapResult) [ + Length(serverSaslCreds) ]
+     * 
+     * Length(BindResponse) = Length(0x61) + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        int ldapResponseLength = super.computeLength();
+        
+        bindResponseLength = ldapResponseLength;
+        
+        if (serverSaslCreds != null)
+        {
+            bindResponseLength += 1 + Length.getNbBytes(serverSaslCreds.getLength()) + serverSaslCreds.getLength();
+        }
+        
+        return 1 + Length.getNbBytes( bindResponseLength ) + bindResponseLength;
+    }
+
+    /**
+     * Encode the BindResponse message to a PDU.
+     * 
+     * BindResponse :
+     * 
+     * LdapResult.encode
+     * [0x87 LL serverSaslCreds]
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+
+        try 
+        {
+            // The BindResponse Tag
+            buffer.put( LdapConstants.BIND_RESPONSE_TAG );
+            buffer.put( Length.getBytes( bindResponseLength ) );
+            
+            // The LdapResult
+            super.encode(buffer);
+
+            // The serverSaslCredential, if any
+            if ( serverSaslCreds != null )
+            {
+                buffer.put( (byte)LdapConstants.SERVER_SASL_CREDENTIAL_TAG );
+                buffer.put( Length.getBytes( serverSaslCreds.getLength() ) );
+                
+                if ( serverSaslCreds.getLength() != 0 )
+                {
+                    buffer.put( serverSaslCreds.getValue() );
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+            
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of a BindResponse
+     *
+     * @return A BindResponse String 
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    BindResponse\n" );
+        sb.append( super.toString() );
+        
+        if ( serverSaslCreds != null )
+        {
+            sb.append( "        Server sasl credentials : '" ).append( serverSaslCreds.toString() ).append( "'\n" );
+        }
+
+        return sb.toString();
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,253 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.codec.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+
+
+/**
+ * A CompareRequest Message. Its syntax is :
+ * CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ *              entry           LDAPDN,
+ *              ava             AttributeValueAssertion }
+ * 
+ * AttributeValueAssertion ::= SEQUENCE {
+ *              attributeDesc   AttributeDescription,
+ *              assertionValue  AssertionValue }
+ * 
+ * AttributeDescription ::= LDAPString
+ * 
+ * AssertionValue ::= OCTET STRING
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CompareRequest extends LdapMessage
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The entry to be compared */
+    private LdapDN entry;
+
+    /** The attribute to be compared */
+    private LdapString attributeDesc;
+
+    /** The value to be compared */
+    private OctetString assertionValue;
+    
+    /** The compare request length */
+    private transient int compareRequestLength;
+    
+    /** The attribute value assertion length */
+    private transient int avaLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new CompareRequest object.
+     */
+    public CompareRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.COMPARE_REQUEST;
+    }
+
+    /**
+     * Get the entry to be compared
+     *
+     * @return Returns the entry.
+     */
+    public String getEntry()
+    {
+        return ( ( entry == null ) ? "" : entry.toString() );
+    }
+
+    /**
+     * Set the entry to be compared
+     *
+     * @param entry The entry to set.
+     */
+    public void setEntry( LdapDN entry )
+    {
+        this.entry = entry;
+    }
+
+    /**
+     * Get the assertion value
+     *
+     * @return Returns the assertionValue.
+     */
+    public OctetString getAssertionValue()
+    {
+        return assertionValue;
+    }
+
+    /**
+     * Set the assertion value
+     *
+     * @param assertionValue The assertionValue to set.
+     */
+    public void setAssertionValue( OctetString assertionValue )
+    {
+        this.assertionValue = assertionValue;
+    }
+
+    /**
+     * Get the attribute description
+     *
+     * @return Returns the attributeDesc.
+     */
+    public String getAttributeDesc()
+    {
+        return ( ( attributeDesc == null ) ? "" : attributeDesc.toString() );
+    }
+
+    /**
+     * Set the attribute description
+     *
+     * @param attributeDesc The attributeDesc to set.
+     */
+    public void setAttributeDesc( LdapString attributeDesc )
+    {
+        this.attributeDesc = attributeDesc;
+    }
+
+    /**
+     * Compute the CompareRequest length
+     * 
+     * CompareRequest :
+     * 
+     * 0x6E L1 
+     *  |
+     *  +--> 0x04 L2 entry
+     *  +--> 0x30 L3 (ava)
+     *        |
+     *        +--> 0x04 L4 attributeDesc
+     *        +--> 0x04 L5 assertionValue
+     * 
+     * L3 = Length(0x04) + Length(L4) + L4
+     *      + Length(0x04) + Length(L5) + L5
+     * 
+     * Length(CompareRequest) = Length(0x6E) + Length(L1) + L1
+     *                          + Length(0x04) + Length(L2) + L2
+     *                          + Length(0x30) + Length(L3) + L3
+     * @return DOCUMENT ME!
+    */
+    public int computeLength()
+    {
+
+        // The entry
+        compareRequestLength = 1 + Length.getNbBytes( entry.getLength() ) + entry.getLength();
+
+        // The attribute value assertion
+        avaLength =
+            1 + Length.getNbBytes( attributeDesc.getLength() ) + attributeDesc.getLength() +
+            1 + Length.getNbBytes( assertionValue.getLength() ) + assertionValue.getLength();
+
+        compareRequestLength += 1 + Length.getNbBytes( avaLength ) + avaLength;
+
+        return 1 + Length.getNbBytes( compareRequestLength ) + compareRequestLength;
+    }
+
+    /**
+     * Encode the CompareRequest message to a PDU.
+     * 
+     * CompareRequest :
+     * 
+     * 0x6E LL
+     *   0x04 LL entry
+     *   0x30 LL attributeValueAssertion
+     *     0x04 LL attributeDesc
+     *     0x04 LL assertionValue
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+        }
+
+        try 
+        {
+            // The CompareRequest Tag
+            buffer.put( LdapConstants.COMPARE_REQUEST_TAG );
+            buffer.put( Length.getBytes( compareRequestLength ) ) ;
+            
+            // The entry
+            Value.encode( buffer, entry );
+
+            // The attributeValueAssertion sequence Tag
+            buffer.put( UniversalTag.SEQUENCE_TAG );
+            buffer.put( Length.getBytes( avaLength ) ) ;
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        // The attributeDesc
+        Value.encode( buffer, attributeDesc );
+        
+        // The assertionValue
+        Value.encode( buffer, assertionValue );
+
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of a Compare Request
+     *
+     * @return A Compare Request String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Compare request\n" );
+        sb.append( "        Entry : '" ).append( entry.toString() ).append( "'\n" );
+        sb.append( "        Attribute description : '" ).append( attributeDesc.toString() ).append(
+            "'\n" );
+        sb.append( "        Attribute value : '" ).append( assertionValue.toString() ).append(
+            "'\n" );
+
+        return sb.toString();
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,119 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.codec.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * An CompareResponse Message. Its syntax is :
+ *   CompareResponse ::= [APPLICATION 15] LDAPResult
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CompareResponse extends LdapResponse
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new CompareResponse object.
+     */
+    public CompareResponse()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.COMPARE_RESPONSE;
+    }
+
+    /**
+     * Compute the CompareResponse length
+     * 
+     * CompareResponse :
+     * 
+     * 0x6F L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(CompareResponse) = Length(0x6F) + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        int ldapResponseLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+    }
+
+    /**
+     * Encode the CompareResponse message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer )  throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+        
+        try
+        {
+            // The tag
+            buffer.put( LdapConstants.COMPARE_RESPONSE_TAG );
+            buffer.put( Length.getBytes( getLdapResponseLength() ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        // The ldapResult
+        return super.encode( buffer);
+    }
+
+    /**
+     * Get a String representation of an CompareResponse
+     *
+     * @return An CompareResponse String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Compare Response\n" );
+        sb.append( super.toString() );
+
+        return sb.toString();
+    }
+}

Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,215 @@
+/*
+ *   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.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1new.Asn1Object;
+import org.apache.asn1.codec.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.primitives.OID;
+import org.apache.asn1new.primitives.OctetString;
+
+
+/**
+ * A Asn1Object to store a Control.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class Control extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The control type */
+    private OID controlType;
+
+    /** The criticality (default value is false) */
+    private boolean criticality = false;
+
+    /** Optionnal control value */
+    private OctetString controlValue;
+    
+    /** The control length */
+    private transient int controlLength;
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the control type
+     *
+     * @return A string which represent the control type
+     */
+    public String getControlType()
+    {
+        return (controlType == null ? "" : controlType.toString() );
+    }
+
+    /**
+     * Set the control type
+     *
+     * @param controlType An OID to store
+     */
+    public void setControlType( OID controlType )
+    {
+        this.controlType = controlType;
+    }
+
+    /**
+     * Get the control value
+     *
+     * @return The control value
+     */
+    public byte[] getControlValue()
+    {
+        return controlValue == null ? new byte[]{} : controlValue.getValue();
+    }
+
+    /**
+     * Set the control value
+     *
+     * @param controlValue The control value to store
+     */
+    public void setControlValue( OctetString controlValue )
+    {
+        this.controlValue = controlValue;
+    }
+
+    /**
+     * Get the criticality
+     *
+     * @return <code>true</code> if the criticality flag is true.
+     */
+    public boolean getCriticality()
+    {
+        return criticality;
+    }
+
+    /**
+     * Set the criticality
+     *
+     * @param criticality The criticality value
+     */
+    public void setCriticality( boolean criticality )
+    {
+        this.criticality = criticality;
+    }
+
+    /**
+     * Compute the Control length
+     * 
+     * Control :
+     * 
+     * 0x30 L1
+     *  |
+     *  +--> 0x04 L2 controlType
+     * [+--> 0x01 0x01 criticality]
+     * [+--> 0x04 L3 controlValue] 
+     * 
+     * Control length = Length(0x30) + length(L1) 
+     *                  + Length(0x04) + Length(L2) + L2
+     *                  [+ Length(0x01) + 1 + 1]
+     *                  [+ Length(0x04) + Length(L3) + L3]
+     */
+    public int computeLength()
+    {
+        // The controlType
+        int controlTypeLengh = controlType.getOIDLength();
+        controlLength = 1 + Length.getNbBytes( controlTypeLengh ) + controlTypeLengh;  
+        
+        // The criticality, only if true
+        if (criticality == true)
+        {
+            controlLength += 1 + 1 + 1; // Always 3 for a boolean
+        }
+        
+        // The control value, if any
+        if (controlValue != null)
+        {
+            controlLength += 1 + Length.getNbBytes( controlValue.getLength() ) + controlValue.getLength();
+        }
+        
+        return 1 + Length.getNbBytes( controlLength ) + controlLength;
+    }
+    
+    /**
+     * Generate the PDU which contains the Control.
+     * 
+     * Control :
+     * 0x30 LL
+     *   0x04 LL type 
+     *   [0x01 0x01 criticality]
+     *   [0x04 LL value]
+     *   
+     * @param object The encoded PDU
+     * @return A ByteBuffer that contaons the PDU
+     * @throws EncoderException If anything goes wrong.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        try 
+        {
+            // The LdapMessage Sequence
+            buffer.put( UniversalTag.SEQUENCE_TAG );
+            
+            // The length has been calculated by the computeLength method
+            buffer.put( Length.getBytes( controlLength ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+            
+        // The control type
+        Value.encode( buffer, controlType );
+
+        // The control criticality, if true
+        if ( criticality == true )
+        {
+            Value.encode( buffer, criticality );
+        }
+        
+        // The control value, if any
+        if ( controlValue != null )
+        {
+            Value.encode( buffer, controlValue );
+        }
+
+        return buffer;
+    }
+
+    /**
+     * Return a String representing a Control
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        
+        sb.append("    Control\n");
+        sb.append("        Control type : '").append( controlType.toString() ).append("'\n");
+        sb.append("        Criticality : '").append( criticality ).append( "'\n") ;
+        
+        if ( controlValue != null ) 
+        {
+            sb.append("        Control value : '").append(controlValue.toString()).append("'\n");
+        }
+        
+        return sb.toString();
+    }
+}