directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r234264 [8/11] - in /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src: ./ java/ java/main/ java/main/org/ java/main/org/apache/ java/main/org/apache/asn1new/ java/main/org/apache/asn1new/ldap/ java/main/org/apache/a...
Date Sun, 21 Aug 2005 16:54:00 GMT
Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java Sun Aug 21 09:53:27 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";
+        }
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,135 @@
+/*
+ *   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.EncoderException;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * 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
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The abandonned message ID  */
+    private int messageId;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new AbandonRequest object.
+     */
+    public AbandonRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the abandonned message ID
+     *
+     * @return Returns the MessageId.
+     */
+    public int getMessageId()
+    {
+        return messageId;
+    }
+
+    /**
+     * Set the abandonned message ID
+     *
+     * @param messageId The messageID to set.
+     */
+    public void setMessageId( int messageId )
+    {
+        this.messageId = messageId;
+    }
+
+    /**
+     * Compute the AbandonRequest length
+     * 
+     * AbandonRequest :
+     * 
+     * 0x50 0x0(1..4) MessageId
+     * 
+     * Length(AbandonRequest) = Length(0x50) + 1 + Length(MessageId)
+     */
+    public int computeLength()
+    {
+        return 1 + 1 + Value.getNbBytes( messageId );
+    }
+    
+    /**
+     * 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)
+        {
+            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 messageId value.
+            buffer.put( (byte)Value.getNbBytes( messageId ) );
+            
+            // The messageId
+            buffer.put( Value.getBytes( messageId ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            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( messageId ).append( '\n' );
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,416 @@
+/*
+ *   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.Asn1Object;
+import org.apache.asn1new.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;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+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.BasicAttribute;
+
+
+/**
+ * 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 Asn1Object
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private transient static final Logger log = LoggerFactory.getLogger( AddRequest.class );
+
+    /** Logging speed up  */
+    //private transient static final boolean DEBUG = log.isDebugEnabled();
+
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The DN to be added. */
+    private LdapDN entry;
+
+    /** The attributes list. */
+    private ArrayList 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 ------------------------------------------------------------------------------------
+
+    /**
+     * Initialize the ArrayList for attributes.
+     */
+    public void initAttributes()
+    {
+        attributes = new ArrayList();
+    }
+
+    /**
+     * Get the entry's attributes to be added
+     *
+     * @return Returns the attributes.
+     */
+    public ArrayList 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.add( 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 ) )
+        {
+            Iterator attributeIterator = attributes.iterator();
+            attributeLength = new LinkedList();
+            valuesLength = new LinkedList();
+            
+            // Compute the attributes length
+            while ( attributeIterator.hasNext() )
+            {
+                Attribute attribute = (Attribute)attributeIterator.next();
+                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.
+        return 1 + Length.getNbBytes( addRequestLength ) + addRequestLength;
+    }
+    
+    /**
+     * 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 ) )
+            {
+                Iterator attributeIterator = attributes.iterator();
+                int attributeNumber = 0;
+                
+                // Compute the attributes length
+                while ( attributeIterator.hasNext() )
+                {
+                    Attribute attribute = (Attribute)attributeIterator.next();
+                    
+                    // 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 !"); 
+        }
+
+        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" );
+
+            for ( int i = 0; i < attributes.size(); i++ )
+            {
+
+                Attribute attribute = ( Attribute ) attributes.get( i );
+
+                sb.append( "           Type[" ).append( i ).append( "] : '" )
+                  .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();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,109 @@
+/*
+ *   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.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 ------------------------------------------------------------------------------------
+
+    /**
+     * 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();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java Sun Aug 21 09:53:27 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( "" );
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,263 @@
+/*
+ *   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.asn1new.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 Asn1Object
+{
+    //~ 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 Asn1Object authentication;
+    
+    /** The bind request length */
+    private transient int bindRequestLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new BindRequest object.
+     */
+    public BindRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the user authentication
+     *
+     * @return The user authentication
+     */
+    public Asn1Object 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( Asn1Object 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();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,170 @@
+/*
+ *   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.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 ------------------------------------------------------------------------------------
+
+    /**
+     * @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();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,243 @@
+/*
+ *   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.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 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();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,109 @@
+/*
+ *   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.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 ------------------------------------------------------------------------------------
+
+    /**
+     * 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();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java Sun Aug 21 09:53:27 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.asn1new.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 String getControlValue()
+    {
+        return (controlValue == null ? "" : controlValue.toString() );
+    }
+
+    /**
+     * 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();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,139 @@
+/*
+ *   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.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+
+
+/**
+ * A DelRequest Message. Its syntax is :
+ *   DelRequest ::= [APPLICATION 10] LDAPDN
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DelRequest extends LdapMessage
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The entry to be deleted */
+    private LdapDN entry;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new DelRequest object.
+     */
+    public DelRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the entry to be deleted
+     *
+     * @return Returns the entry.
+     */
+    public String getEntry()
+    {
+        return ( ( entry == null ) ? "" : entry.toString() );
+    }
+
+    /**
+     * Set the entry to be deleted
+     *
+     * @param entry The entry to set.
+     */
+    public void setEntry( LdapDN entry )
+    {
+        this.entry = entry;
+    }
+
+    /**
+     * Compute the DelRequest length
+     * 
+     * DelRequest :
+     * 
+     * 0x4A L1 entry
+     * 
+     * L1 = Length(entry)
+     * 
+     * Length(DelRequest) = Length(0x4A) + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        // The entry
+        return 1 + Length.getNbBytes( entry.getLength() ) + entry.getLength();
+    }
+    
+    /**
+     * Encode the DelRequest message to a PDU.
+     * 
+     * DelRequest :
+     * 
+     * 0x4A LL entry
+     * 
+     * @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 DelRequest Tag
+            buffer.put( LdapConstants.DEL_REQUEST_TAG );
+
+            // The entry
+            buffer.put( Length.getBytes( entry.getLength() ) );
+            buffer.put( entry.getData() );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+            
+        return buffer;
+    }
+
+    /**
+     * Return a String representing a DelRequest
+     * 
+     * @return A DelRequest String
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Del request\n" );
+        sb.append( "        Entry : '" ).append( entry.toString() ).append( "'\n" );
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,107 @@
+/*
+ *   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.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * An DelResponse Message. Its syntax is :
+ *   DelResponse ::= [APPLICATION 11] LDAPResult
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DelResponse extends LdapResponse
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new DelResponse object.
+     */
+    public DelResponse()
+    {
+        super( );
+    }
+
+    /**
+     * Compute the DelResponse length
+     * 
+     * DelResponse :
+     * 
+     * 0x6B L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(DelResponse) = Length(0x6B) + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        int ldapResponseLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+    }
+
+    /**
+     * Encode the DelResponse 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.DEL_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 a DelResponse
+     *
+     * @return A DelResponse String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Del Response\n" );
+        sb.append( super.toString() );
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,206 @@
+/*
+ *   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.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.primitives.OID;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+
+/**
+ * A ExtendedRequest Message. Its syntax is :
+ *   ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ *              requestName      [0] LDAPOID,
+ *              requestValue     [1] OCTET STRING OPTIONAL }
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ExtendedRequest extends LdapMessage
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The name */
+    private OID requestName;
+
+    /** The value */
+    private OctetString requestValue;
+    
+    /** The extended request length */
+    private transient int extendedRequestLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new ExtendedRequest object.
+     */
+    public ExtendedRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the extended request name
+     *
+     * @return Returns the request name.
+     */
+    public String getRequestName()
+    {
+        return ( ( requestName == null ) ? "" : requestName.toString() );
+    }
+
+    /**
+     * Set the extended request name
+     *
+     * @param requestName The request name to set.
+     */
+    public void setRequestName( OID requestName )
+    {
+        this.requestName = requestName;
+    }
+
+    /**
+     * Get the extended request value
+     *
+     * @return Returns the request value.
+     */
+    public OctetString getRequestValue()
+    {
+        return requestValue;
+    }
+
+    /**
+     * Set the extended request value
+     *
+     * @param requestValue The request value to set.
+     */
+    public void setRequestValue( OctetString requestValue )
+    {
+        this.requestValue = requestValue;
+    }
+
+    /**
+     * Compute the ExtendedRequest length
+     * 
+     * ExtendedRequest :
+     * 
+     * 0x77 L1
+     *  |
+     *  +--> 0x80 L2 name
+     *  [+--> 0x81 L3 value]
+     * 
+     * L1 = Length(0x80) + Length(L2) + L2
+     *      [+ Length(0x81) + Length(L3) + L3]
+     * 
+     * Length(ExtendedRequest) = Length(0x77) + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        extendedRequestLength = 1 + Length.getNbBytes( requestName.getOIDLength() ) + requestName.getOIDLength();
+        
+        if ( requestValue != null)
+        {
+            extendedRequestLength += 1 + Length.getNbBytes( requestValue.getLength() ) + requestValue.getLength();
+        }
+        
+        return 1 + Length.getNbBytes( extendedRequestLength ) + extendedRequestLength;
+    }
+
+    /**
+     * Encode the ExtendedRequest message to a PDU.
+     * 
+     * ExtendedRequest :
+     * 
+     * 0x80 LL resquest name
+     * [0x81 LL request value]
+     * 
+     * @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.EXTENDED_REQUEST_TAG );
+            buffer.put( Length.getBytes( extendedRequestLength ) );
+            
+            // The requestName, if any
+            if ( requestName == null )
+            {
+                throw new EncoderException("The request name must not be null");
+            }
+            
+            buffer.put( (byte)LdapConstants.EXTENDED_REQUEST_NAME_TAG );
+            buffer.put( Length.getBytes( requestName.getOIDLength() ) );
+                
+            if ( requestName.getOIDLength() != 0 )
+            {
+                buffer.put( requestName.getOID() );
+            }
+
+            // The requestValue, if any
+            if ( requestValue != null )
+            {
+                buffer.put( (byte)LdapConstants.EXTENDED_REQUEST_VALUE_TAG );
+                buffer.put( Length.getBytes( requestValue.getLength() ) );
+                
+                if ( requestValue.getLength() != 0 )
+                {
+                    buffer.put( requestValue.getValue() );
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+            
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of an Extended Request
+     *
+     * @return an Extended Request String 
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Extended request\n" );
+        sb.append( "        Request name : '" ).append( requestName.toString() ).append( "'\n" );
+        
+        if ( requestValue != null )
+        {
+            sb.append( "        Request value : '" ).append( requestValue.toString() ).append( "'\n" );
+        }
+
+        return sb.toString();
+    }
+}



Mime
View raw message