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 [10/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/ s...

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,149 @@
+/*
+ *   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;
+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 message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.DEL_REQUEST;
+    }
+
+    /**
+     * 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();
+    }
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,117 @@
+/*
+ *   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 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( );
+    }
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.DEL_RESPONSE;
+    }
+
+    /**
+     * 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();
+    }
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,216 @@
+/*
+ *   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.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 message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.EXTENDED_REQUEST;
+    }
+
+    /**
+     * 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();
+    }
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,236 @@
+/*
+ *   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.OID;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+
+/**
+ * A ExtendedResponse Message. Its syntax is :
+ *   ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ *              COMPONENTS OF LDAPResult,
+ *              responseName     [10] LDAPOID OPTIONAL,
+ *              response         [11] OCTET STRING OPTIONAL }
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ExtendedResponse extends LdapResponse
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The name */
+    private OID responseName;
+
+    /** The response */
+    private OctetString response;
+    
+    /** The extended response length */
+    private transient int extendedResponseLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new ExtendedResponse object.
+     */
+    public ExtendedResponse()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.EXTENDED_RESPONSE;
+    }
+
+    /**
+     * Get the extended response name
+     *
+     * @return Returns the name.
+     */
+    public String getResponseName()
+    {
+        return ( ( responseName == null ) ? "" : responseName.toString() );
+    }
+
+    /**
+     * Set the extended response name
+     *
+     * @param name The name to set.
+     */
+    public void setResponseName( OID responseName )
+    {
+        this.responseName = responseName;
+    }
+
+    /**
+     * Get the extended response
+     *
+     * @return Returns the response.
+     */
+    public OctetString getResponse()
+    {
+        return response;
+    }
+
+    /**
+     * Set the extended response
+     *
+     * @param response The response to set.
+     */
+    public void setResponse( OctetString response )
+    {
+        this.response = response;
+    }
+
+    /**
+     * Compute the ExtendedResponse length
+     * 
+     * ExtendedResponse :
+     * 
+     * 0x78 L1
+     *  |
+     *  +--> LdapResult
+     * [+--> 0x8A L2 name
+     * [+--> 0x8B L3 response]]
+     * 
+     * L1 = Length(LdapResult)
+     *      [ + Length(0x8A) + Length(L2) + L2
+     *       [ + Length(0x8B) + Length(L3) + L3]]
+     * 
+     * Length(ExtendedResponse) = Length(0x78) + Length(L1) + L1
+     * @return The ExtendedResponse length
+    */
+    public int computeLength()
+    {
+
+        extendedResponseLength = super.computeLength();
+
+        if ( responseName != null )
+        {
+            extendedResponseLength += 1 + Length.getNbBytes( responseName.getOIDLength() ) +
+            responseName.getOIDLength();
+
+            if ( response != null )
+            {
+                extendedResponseLength += 1 + Length.getNbBytes( response.getLength() ) +
+                    response.getLength();
+            }
+        }
+
+        return 1 + Length.getNbBytes( extendedResponseLength ) + extendedResponseLength;
+    }
+
+    /**
+     * Encode the ExtendedResponse message to a PDU.
+     * 
+     * ExtendedResponse :
+     * 
+     * LdapResult.encode()
+     * [0x8A LL response name]
+     * [0x8B LL response]
+     * 
+     * @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_RESPONSE_TAG );
+            buffer.put( Length.getBytes( extendedResponseLength ) );
+            
+            // The LdapResult
+            super.encode(buffer);
+
+            // The responseName, if any
+            if ( responseName != null )
+            {
+                buffer.put( (byte)LdapConstants.EXTENDED_RESPONSE_RESPONSE_NAME_TAG );
+                buffer.put( Length.getBytes( responseName.getOIDLength() ) );
+                
+                if ( responseName.getOIDLength() != 0 )
+                {
+                    buffer.put( responseName.getOID() );
+                }
+            }
+
+            // The response, if any
+            if ( response != null )
+            {
+                buffer.put( (byte)LdapConstants.EXTENDED_RESPONSE_RESPONSE_TAG );
+                buffer.put( Length.getBytes( response.getLength() ) );
+                
+                if ( response.getLength() != 0 )
+                {
+                    buffer.put( response.getValue() );
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+            
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of an ExtendedResponse
+     *
+     * @return An ExtendedResponse String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Extended Response\n" );
+        sb.append( super.toString() );
+
+        if ( responseName != null )
+        {
+            sb.append( "        Response name :'" ).append( responseName.toString() ).append( "'\n" );
+        }
+
+        if ( response != null )
+        {
+            sb.append( "        Response :'" ).append( response.toString() ).append( "'\n" );
+        }
+
+        return sb.toString();
+    }
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapAuthentication.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapAuthentication.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapAuthentication.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapAuthentication.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,29 @@
+/*
+ *   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;
+
+/**
+ * This abstract class is just used to have a common super class for
+ * authentication classes, like Simple and SASL. We may have future extensions
+ * as authentication type 1 and 2 are reserved actually in LDAP V3
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class LdapAuthentication extends Asn1Object {
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapMessage.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapMessage.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapMessage.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapMessage.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,600 @@
+/*
+ *   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.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.ldap.codec.LdapConstants;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * The main ldapObject : every Ldap Message are encapsulated in it. It contains
+ * a message Id, a operation (protocolOp) and one ore more Controls.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapMessage extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The message ID */
+    private int messageId;
+
+    /** The request or response being carried by the message */
+    private Asn1Object protocolOp;
+
+    /** The controls */
+    private ArrayList controls;
+    
+    /** The current control */
+    private transient Control currentControl;
+    
+    /** The LdapMessage length */
+    private transient int ldapMessageLength;
+    
+    /** The controls length */
+    private transient int controlsLength;
+    
+    /** The controls sequence length */
+    private transient int controlsSequenceLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new LdapMessage object.
+     */
+    public LdapMessage()
+    {
+        // We should not create this kind of object directly
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the Control Object at a specific index 
+     *
+     * @param i The index of the Control Object to get
+     *
+     * @return The selected Control Object
+     */
+    public Control getControls( int i )
+    {
+        return (Control)controls.get( i );
+    }
+
+    /**
+     * Get the Control Objects 
+     *
+     * @return The Control Objects
+     */
+    public ArrayList getControls()
+    {
+        return controls;
+    }
+
+    /**
+     * Get the current Control Object 
+     *
+     * @return The current Control Object
+     */
+    public Control getCurrentControl()
+    {
+        return currentControl;
+    }
+
+    /**
+     * Add a control to the Controls array
+     *
+     * @param control The Control to add
+     */
+    public void addControl( Control control )
+    {
+        currentControl = control;
+        this.controls.add( control );
+    }
+
+    /**
+     * Init the controls array
+     */
+    public void initControl(  )
+    {
+        controls = new ArrayList();
+    }
+
+    /**
+     * Get the message ID
+     *
+     * @return The message ID
+     */
+    public int getMessageId()
+    {
+        return messageId;
+    }
+
+    /**
+     * Set the message ID
+     *
+     * @param messageId The message ID
+     */
+    public void setMessageId( int messageId )
+    {
+        this.messageId = messageId;
+    }
+
+    /**
+     * Get the message type
+     *
+     * @return The message type
+     */
+    public int getMessageType()
+    {
+    	return ( (LdapMessage)protocolOp) .getMessageType();
+    }
+
+    /**
+     * Get the message type Name
+     *
+     * @return The message type name
+     */
+    public String getMessageTypeName()
+    {
+    	switch ( ( (LdapMessage)protocolOp) .getMessageType() )
+    	{
+    	    case LdapConstants.ABANDON_REQUEST         : return "ABANDON_REQUEST";
+    	    case LdapConstants.ADD_REQUEST             : return "ADD_REQUEST";
+    	    case LdapConstants.ADD_RESPONSE            : return "ADD_RESPONSE";
+    	    case LdapConstants.BIND_REQUEST            : return "BIND_REQUEST";
+    	    case LdapConstants.BIND_RESPONSE           : return "BIND_RESPONSE";
+    	    case LdapConstants.COMPARE_REQUEST         : return "COMPARE_REQUEST";
+    	    case LdapConstants.COMPARE_RESPONSE        : return "COMPARE_REQUEST";
+    	    case LdapConstants.DEL_REQUEST             : return "DEL_REQUEST";
+    	    case LdapConstants.DEL_RESPONSE            : return "DEL_RESPONSE";
+    	    case LdapConstants.EXTENDED_REQUEST        : return "EXTENDED_REQUEST";
+    	    case LdapConstants.EXTENDED_RESPONSE       : return "EXTENDED_RESPONSE";
+    	    case LdapConstants.MODIFYDN_REQUEST        : return "MODIFYDN_REQUEST";
+    	    case LdapConstants.MODIFYDN_RESPONSE       : return "MODIFYDN_RESPONSE";
+    	    case LdapConstants.MODIFY_REQUEST          : return "MODIFY_REQUEST";
+    	    case LdapConstants.MODIFY_RESPONSE         : return "MODIFY_RESPONSE";
+    	    case LdapConstants.SEARCH_REQUEST          : return "SEARCH_REQUEST";
+    	    case LdapConstants.SEARCH_RESULT_DONE      : return "SEARCH_RESULT_DONE";
+    	    case LdapConstants.SEARCH_RESULT_ENTRY     : return "SEARCH_RESULT_ENTRY";
+    	    case LdapConstants.SEARCH_RESULT_REFERENCE : return "SEARCH_RESULT_REFERENCE";
+    	    case LdapConstants.UNBIND_REQUEST          : return "UNBIND_REQUEST";
+    	    default                      			   : return "UNKNOWN";
+    	}
+    }
+
+    /**
+     * Get the encapsulated Ldap response.
+     *
+     * @return Returns the Ldap response.
+     */
+    public LdapResponse getLdapResponse()
+    {
+        return ( LdapResponse )protocolOp;
+    }
+
+    /**
+     * Get a AbandonRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the AbandonRequest ldapObject.
+     */
+    public AbandonRequest getAbandonRequest()
+    {
+        return ( AbandonRequest ) protocolOp;
+    }
+
+    /**
+     * Get a AddRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the AddRequest ldapObject.
+     */
+    public AddRequest getAddRequest()
+    {
+        return ( AddRequest ) protocolOp;
+    }
+
+    /**
+     * Get a AddResponse ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the AddResponse ldapObject.
+     */
+    public AddResponse getAddResponse()
+    {
+        return ( AddResponse ) protocolOp;
+    }
+
+    /**
+     * Get a BindRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the BindRequest ldapObject.
+     */
+    public BindRequest getBindRequest()
+    {
+        return ( BindRequest ) protocolOp;
+    }
+
+    /**
+     * Get a BindResponse ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the BindResponse ldapObject.
+     */
+    public BindResponse getBindResponse()
+    {
+        return ( BindResponse ) protocolOp;
+    }
+
+    /**
+     * Get a CompareRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the CompareRequest ldapObject.
+     */
+    public CompareRequest getCompareRequest()
+    {
+        return ( CompareRequest ) protocolOp;
+    }
+
+    /**
+     * Get a CompareResponse ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the CompareResponse ldapObject.
+     */
+    public CompareResponse getCompareResponse()
+    {
+        return ( CompareResponse ) protocolOp;
+    }
+
+    /**
+     * Get a DelRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the DelRequest ldapObject.
+     */
+    public DelRequest getDelRequest()
+    {
+        return ( DelRequest ) protocolOp;
+    }
+
+    /**
+     * Get a DelResponse ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the DelResponse ldapObject.
+     */
+    public DelResponse getDelResponse()
+    {
+        return ( DelResponse ) protocolOp;
+    }
+
+    /**
+     * Get a ExtendedRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the ExtendedRequest ldapObject.
+     */
+    public ExtendedRequest getExtendedRequest()
+    {
+        return ( ExtendedRequest ) protocolOp;
+    }
+
+    /**
+     * Get a ExtendedResponse ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the ExtendedResponse ldapObject.
+     */
+    public ExtendedResponse getExtendedResponse()
+    {
+        return ( ExtendedResponse ) protocolOp;
+    }
+
+    /**
+     * Get a ModifyDNRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the ModifyDNRequest ldapObject.
+     */
+    public ModifyDNRequest getModifyDNRequest()
+    {
+        return ( ModifyDNRequest ) protocolOp;
+    }
+
+    /**
+     * Get a ModifyDNResponse ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the ModifyDNResponse ldapObject.
+     */
+    public ModifyDNResponse getModifyDNResponse()
+    {
+        return ( ModifyDNResponse ) protocolOp;
+    }
+
+    /**
+     * Get a ModifyRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the ModifyRequest ldapObject.
+     */
+    public ModifyRequest getModifyRequest()
+    {
+        return ( ModifyRequest ) protocolOp;
+    }
+
+    /**
+     * Get a ModifyResponse ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the ModifyResponse ldapObject.
+     */
+    public ModifyResponse getModifyResponse()
+    {
+        return ( ModifyResponse ) protocolOp;
+    }
+
+    /**
+     * Get a SearchRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the SearchRequest ldapObject.
+     */
+    public SearchRequest getSearchRequest()
+    {
+        return ( SearchRequest ) protocolOp;
+    }
+
+    /**
+     * Get a SearchResultDone ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the SearchRequestDone ldapObject.
+     */
+    public SearchResultDone getSearchResultDone()
+    {
+        return ( SearchResultDone ) protocolOp;
+    }
+
+    /**
+     * Get a SearchResultEntry ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the SearchResultEntry ldapObject.
+     */
+    public SearchResultEntry getSearchResultEntry()
+    {
+        return ( SearchResultEntry ) protocolOp;
+    }
+
+    /**
+     * Get a SearchResultReference ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the SearchResultReference ldapObject.
+     */
+    public SearchResultReference getSearchResultReference()
+    {
+        return ( SearchResultReference ) protocolOp;
+    }
+
+    /**
+     * Get a UnBindRequest ldapObject, assuming that the caller knows that
+     * it is the LdapMessage exact type.
+     *
+     * @return Returns the UnBindRequest ldapObject.
+     */
+    public UnBindRequest getUnBindRequest()
+    {
+        return ( UnBindRequest ) protocolOp;
+    }
+
+    /**
+     * Set the ProtocolOP
+     *
+     * @param protocolOp The protocolOp to set.
+     */
+    public void setProtocolOP( Asn1Object protocolOp )
+    {
+        this.protocolOp = protocolOp;
+    }
+
+    /**
+     * Compute the LdapMessage length
+     * 
+     * LdapMessage :
+     * 
+     * 0x30 L1
+     *  |
+     *  +--> 0x02 0x0(1-4) [0..2^31-1] (MessageId)
+     *  +--> protocolOp
+     * [+--> Controls]
+     * 
+     * MessageId length = Length(0x02) + length(MessageId) + MessageId.length
+     * L1 = length(ProtocolOp)
+     * LdapMessage length = Length(0x30) + Length(L1) + MessageId length + L1
+     */
+    public int computeLength()
+    {
+        // The length of the MessageId. It's the sum of
+        // - the tag (0x02), 1 byte
+        // - the length of the Id length, 1 byte
+        // - the Id length, 1 to 4 bytes
+        ldapMessageLength = 1 + 1 + Value.getNbBytes(messageId);
+        
+        // Get the protocolOp length
+        int protocolOpLength = protocolOp.computeLength();
+
+        // Add the protocol length to the message length
+        ldapMessageLength += protocolOpLength;
+
+        // Do the same thing for Controls, if any.
+        if (controls != null)
+        {
+            // Controls :
+            // 0x90 L3
+            //  |
+            //  +--> 0x30 L4
+            //        |
+            //        +--> 0x30 L5
+            //        +--> 0x30 L6
+            //        +--> ...
+            //        +--> 0x30 Li
+            //        +--> ...
+            //        +--> 0x30 Ln
+            //
+            // L3 = Length(0x30) + Length(L4) + L4
+            // L4 = Length(0x30) + Length(L5) + L5
+            //      + Length(0x30) + Length(L6) + L6
+            //      + ...
+            //      + Length(0x30) + Length(Li) + Li
+            //      + ...
+            //      + Length(0x30) + Length(Ln) + Ln
+            //
+            // LdapMessageLength = LdapMessageLength + Length(0x90) 
+            //                     + Length(L3) + L3 
+            controlsSequenceLength = 0;
+            
+            Iterator controlIterator = controls.iterator();
+            
+            // We may have more than one control. ControlsLength is L4.
+            while (controlIterator.hasNext())
+            {
+                controlsSequenceLength += ((Control)controlIterator.next()).computeLength();
+            }
+            
+            // Computes the controls length
+            controlsLength = 1 + Length.getNbBytes( controlsSequenceLength ) + controlsSequenceLength; 
+                
+            // Now, add the tag and the length of the controls length
+            ldapMessageLength += 1 + Length.getNbBytes( controlsLength ) + controlsLength;
+        }
+        
+        // finally, calculate the global message size :
+        // length(Tag) + Length(length) + length
+        
+        return 1 + ldapMessageLength + Length.getNbBytes(ldapMessageLength);
+    }
+
+    /**
+     * Generate the PDU which contains the encoded object.
+     * 
+     * The generation is done in two phases :
+     * - first, we compute the length of each part and the
+     *   global PDU length
+     * - second, we produce the PDU.
+     * 
+     * 0x30 L1
+     *   |
+     *   +--> 0x02 L2 MessageId (L2 = Length(MessageId)
+     *   +--> ProtocolOp
+     *   +--> Controls
+     *   
+     * L1 = Length(0x02) + Length(L2) + L2 
+     *      + Length(ProtocolOp) + Length(Controls)
+     * 
+     * LdapMessageLength = Length(0x30) + Length(L1) + L1
+     *   
+     * @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
+    {
+        // Allocate the bytes buffer.
+        ByteBuffer bb = ByteBuffer.allocate( computeLength() );
+
+        try 
+        {
+            // The LdapMessage Sequence
+            bb.put( UniversalTag.SEQUENCE_TAG );
+            
+            // The length has been calculated by the computeLength method
+            bb.put( Length.getBytes( ldapMessageLength ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+            
+        
+        // The message Id
+        Value.encode( bb, messageId);
+        
+        // Add the protocolOp part
+        protocolOp.encode(bb);
+        
+        // Do the same thing for Controls, if any.
+        if (controls != null)
+        {
+            // Encode the controls
+            bb.put( (byte)LdapConstants.CONTROLS_TAG );
+            bb.put( Length.getBytes( controlsLength ) );
+
+            // Encode the control's sequence
+            bb.put( UniversalTag.SEQUENCE_TAG );
+            bb.put( Length.getBytes( controlsSequenceLength ) );
+
+            // Encode each control
+            Iterator controlIterator = controls.iterator();
+            
+            while (controlIterator.hasNext())
+            {
+                ((Control)controlIterator.next()).encode( bb );
+            }
+        }
+
+        return bb;
+    }
+
+    /**
+     * Get a String representation of a LdapMessage
+     *
+     * @return A LdapMessage String 
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "LdapMessage\n" );
+        sb.append( "    message Id : " ).append( messageId ).append( '\n' );
+        sb.append( protocolOp.toString() );
+
+        if ( controls != null )
+        {
+	        for ( int i = 0; i < controls.size(); i++ )
+	        {
+	            sb.append( ( ( Control ) controls.get( i ) ).toString() );
+	        }
+        }
+
+        return sb.toString();
+    }
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResponse.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResponse.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResponse.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,122 @@
+/*
+ *   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.ByteBuffer;
+
+import org.apache.asn1.codec.EncoderException;
+
+
+/**
+ * A generic LdapResponse Object. It will contain the LdapResult.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapResponse extends LdapMessage
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The LdapResult element */
+    private LdapResult ldapResult;
+    
+    /** The response length */
+    private transient int ldapResponseLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new LdapResponse object.
+     */
+    public LdapResponse()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the LdapResult
+     *
+     * @return Returns the ldapResult.
+     */
+    public LdapResult getLdapResult()
+    {
+        return ldapResult;
+    }
+
+    /**
+     * Set the ldap result
+     * 
+     * @param ldapResult The ldapResult to set.
+     */
+    public void setLdapResult( LdapResult ldapResult )
+    {
+        this.ldapResult = ldapResult;
+    }
+    
+    /**
+     * @return Returns the ldapResponseLength.
+     */
+    public int getLdapResponseLength()
+    {
+        return ldapResponseLength;
+    }
+    
+    /**
+     * Compute the LdapResponse length
+     * 
+     * LdapResponse :
+     * 
+     * LdapResult
+     */
+    public int computeLength()
+    {
+        ldapResponseLength = ldapResult.computeLength();
+        
+        return 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 !");
+        }
+        
+        // The ldapResult
+        ldapResult.encode( buffer );
+        
+        // The ldapResult
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of an Response
+     *
+     * @return An Response String 
+     */
+    public String toString()
+    {
+        return ldapResult.toString();
+    }
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,584 @@
+/*
+ *   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.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.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.codec.primitives.LdapURL;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * A ldapObject to store the LdapResult
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapResult extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The result code. The different values are :
+     *  success                      (0),
+     *  operationsError              (1),
+     *  protocolError                (2),
+     *  timeLimitExceeded            (3),
+     *  sizeLimitExceeded            (4),
+     *  compareFalse                 (5),
+     *  compareTrue                  (6),
+     *  authMethodNotSupported       (7),
+     *  strongAuthRequired           (8),
+     *  -- 9 reserved --
+     *  referral                     (10),  -- new
+     *  adminLimitExceeded           (11),  -- new
+     *  unavailableCriticalExtension (12),  -- new
+     *  confidentialityRequired      (13),  -- new
+     *  saslBindInProgress           (14),  -- new
+     *  noSuchAttribute              (16),
+     *  undefinedAttributeType       (17),
+     *  inappropriateMatching        (18),
+     *  constraintViolation          (19),
+     *  attributeOrValueExists       (20),
+     *  invalidAttributeSyntax       (21),
+     *  -- 22-31 unused --
+     *  noSuchObject                 (32),
+     *  aliasProblem                 (33),
+     *  invalidDNSyntax              (34),
+     *  -- 35 reserved for undefined isLeaf --
+     *  aliasDereferencingProblem    (36),
+     *  -- 37-47 unused --
+     *  inappropriateAuthentication  (48),
+     *  invalidCredentials           (49),
+     *  insufficientAccessRights     (50),
+     *  busy                         (51),
+     *  unavailable                  (52),
+     *  unwillingToPerform           (53),
+     *  loopDetect                   (54),
+     *  -- 55-63 unused --
+     *  namingViolation              (64),
+     *  objectClassViolation         (65),
+     *  notAllowedOnNonLeaf          (66),
+     *  notAllowedOnRDN              (67),
+     *  entryAlreadyExists           (68),
+     *  objectClassModsProhibited    (69),
+     *  -- 70 reserved for CLDAP --
+     *  affectsMultipleDSAs          (71), -- new
+     *  -- 72-79 unused --
+     *  other                        (80) },
+     *  -- 81-90 reserved for APIs --
+     */
+    private int           resultCode;
+
+    /** The DN that is matched by the Bind */
+    private LdapDN        matchedDN;
+
+    /** The error message */
+    private LdapString    errorMessage;
+
+    /** The referrals, if any. This is an optional element */
+    private ArrayList     referrals;
+
+    /** The inner size of the referrals sequence */
+    private transient int referralsLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new BindResponse object.
+     */
+    public LdapResult()
+    {
+        referrals = new ArrayList();
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the error message
+     *
+     * @return Returns the errorMessage.
+     */
+    public String getErrorMessage()
+    {
+        return ( ( errorMessage == null ) ? null : errorMessage.toString() );
+    }
+
+    /**
+     * Set the error message
+     *
+     * @param errorMessage The errorMessage to set.
+     */
+    public void setErrorMessage( LdapString errorMessage )
+    {
+        this.errorMessage = errorMessage;
+    }
+
+    /**
+     * Get the matched DN
+     *
+     * @return Returns the matchedDN.
+     */
+    public String getMatchedDN()
+    {
+        return ( ( matchedDN == null ) ? null : matchedDN.toString() );
+    }
+
+    /**
+     * Set the Matched DN
+     * 
+     * @param matchedDN The matchedDN to set.
+     */
+    public void setMatchedDN( LdapDN matchedDN )
+    {
+        this.matchedDN = matchedDN;
+    }
+
+    /**
+     * Get the referrals
+     *
+     * @return Returns the referrals.
+     */
+    public ArrayList getReferrals()
+    {
+        return referrals;
+    }
+
+    /**
+     * Add a referral
+     *
+     * @param referral The referral to add.
+     */
+    public void addReferral( LdapURL referral )
+    {
+        referrals.add( referral );
+    }
+
+    /**
+     * Get the result code
+     *
+     * @return Returns the resultCode.
+     */
+    public int getResultCode()
+    {
+        return resultCode;
+    }
+
+    /**
+     * Set the result code
+     *
+     * @param resultCode The resultCode to set.
+     */
+    public void setResultCode( int resultCode )
+    {
+        this.resultCode = resultCode;
+    }
+
+    /**
+     * Compute the LdapResult length
+     * 
+     * LdapResult :
+     * 
+     * 0x0A 01 resultCode 	(0..80)
+     * 0x04 L1 matchedDN 	(L1 = Length(matchedDN))
+     * 0x04 L2 errorMessage (L2 = Length(errorMessage))
+     * [0x83 L3] referrals
+     *   |
+     *   +--> 0x04 L4 referral
+     *   +--> 0x04 L5 referral
+     *   +--> ...
+     *   +--> 0x04 Li referral
+     *   +--> ...
+     *   +--> 0x04 Ln referral
+     * 
+     * L1 = Length(matchedDN)
+     * L2 = Length(errorMessage)
+     * L3 = n*Length(0x04) + sum(Length(L4) .. Length(Ln)) + sum(L4..Ln)
+     * L4..n = Length(0x04) + Length(Li) + Li
+     * 
+     * Length(LdapResult) = Length(0x0x0A) + Length(0x01) + 1
+     *                      + Length(0x04) + Length(L1) + L1
+     *                      + Length(0x04) + Length(L2) + L2
+     *                      + Length(0x83) + Length(L3) + L3
+     */
+    public int computeLength()
+    {
+        int ldapResultLength = 0;
+
+        // The result code : always 3 bytes
+        ldapResultLength = 1 + 1 + 1;
+
+        // The matchedDN length
+        ldapResultLength += 1 + Length.getNbBytes( matchedDN.getLength() ) + matchedDN.getLength();
+
+        // The errorMessage length
+        ldapResultLength += 1 + Length.getNbBytes( errorMessage.getLength() ) + errorMessage.getLength();
+
+        if ( ( referrals != null ) && ( referrals.size() != 0 ) )
+        {
+            Iterator referralIterator = referrals.iterator();
+
+            referralsLength = 0;
+
+            // Each referral
+            while ( referralIterator.hasNext() )
+            {
+                LdapURL referral = ( LdapURL ) referralIterator.next();
+
+                referralsLength += 1 + Length.getNbBytes( referral.getLength() ) + referral.getLength();
+            }
+
+            // The referrals
+            ldapResultLength += 1 + Length.getNbBytes( referralsLength ) + referralsLength;
+        }
+
+        return ldapResultLength;
+    }
+
+    /**
+     * Encode the LdapResult 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 result code
+            buffer.put( UniversalTag.ENUMERATED_TAG );
+            buffer.put( ( byte ) 1 );
+            buffer.put( ( byte ) resultCode );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        // The matchedDN 
+        Value.encode( buffer, matchedDN);
+
+        // The error message
+        Value.encode( buffer, errorMessage);
+
+        // The referrals, if any
+        if ( ( referrals != null ) && ( referrals.size() != 0 ) )
+        {
+            // Encode the referrals sequence
+            // The referrals length MUST have been computed before !
+            buffer.put( (byte)LdapConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG );
+            buffer.put( Length.getBytes( referralsLength ) );
+
+            // Each referral
+            Iterator referralIterator = referrals.iterator();
+
+            while ( referralIterator.hasNext() )
+            {
+                LdapURL referral = ( LdapURL ) referralIterator.next();
+
+                // Ecode the current referral
+                Value.encode( buffer, referral);
+            }
+        }
+
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of a LdapResult
+     *
+     * @return A LdapResult String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "        Ldap Result\n" );
+        sb.append( "            Result code : (" ).append( resultCode ).append( ')' );
+
+        switch ( resultCode )
+        {
+
+            case 0 :
+                sb.append( " success\n" );
+                break;
+
+            case 1 :
+                sb.append( " operationsError\n" );
+                break;
+
+            case 2 :
+                sb.append( " protocolError\n" );
+                break;
+
+            case 3 :
+                sb.append( " timeLimitExceeded\n" );
+                break;
+
+            case 4 :
+                sb.append( " sizeLimitExceeded\n" );
+                break;
+
+            case 5 :
+                sb.append( " compareFalse\n" );
+                break;
+
+            case 6 :
+                sb.append( " compareTrue\n" );
+                break;
+
+            case 7 :
+                sb.append( " authMethodNotSupported\n" );
+                break;
+
+            case 8 :
+                sb.append( " strongAuthRequired\n" );
+                break;
+
+            case 9 :
+                sb.append( " -- 9 reserved --\n" );
+                break;
+
+            case 10 :
+                sb.append( " referral -- new\n" );
+                break;
+
+            case 11 :
+                sb.append( " adminLimitExceeded -- new\n" );
+                break;
+
+            case 12 :
+                sb.append( " unavailableCriticalExtension -- new\n" );
+                break;
+
+            case 13 :
+                sb.append( " confidentialityRequired -- new\n" );
+                break;
+
+            case 14 :
+                sb.append( " saslBindInProgress -- new\n" );
+                break;
+
+            case 15 :
+                sb.append( " !! Unknow error code\n" );
+                break;
+
+            case 16 :
+                sb.append( " noSuchAttribute\n" );
+                break;
+
+            case 17 :
+                sb.append( " undefinedAttributeType\n" );
+                break;
+
+            case 18 :
+                sb.append( " inappropriateMatching\n" );
+                break;
+
+            case 19 :
+                sb.append( " constraintViolation\n" );
+                break;
+
+            case 20 :
+                sb.append( " attributeOrValueExists\n" );
+                break;
+
+            case 21 :
+                sb.append( " invalidAttributeSyntax\n" );
+                break;
+
+            case 22 :
+            case 23 :
+            case 24 :
+            case 25 :
+            case 26 :
+            case 27 :
+            case 28 :
+            case 29 :
+            case 30 :
+            case 31 :
+                sb.append( " -- 22-31 unused --\n" );
+                break;
+
+            case 32 :
+                sb.append( " noSuchObject\n" );
+                break;
+
+            case 33 :
+                sb.append( " aliasProblem\n" );
+                break;
+
+            case 34 :
+                sb.append( " invalidDNSyntax\n" );
+                break;
+
+            case 35 :
+                sb.append( " -- 35 reserved for undefined isLeaf --\n" );
+                break;
+
+            case 36 :
+                sb.append( " aliasDereferencingProblem\n" );
+                break;
+
+            case 37 :
+            case 38 :
+            case 39 :
+            case 40 :
+            case 41 :
+            case 42 :
+            case 43 :
+            case 44 :
+            case 45 :
+            case 46 :
+            case 47 :
+                sb.append( " -- 37-47 unused --\n" );
+                break;
+
+            case 48 :
+                sb.append( " inappropriateAuthentication\n" );
+                break;
+
+            case 49 :
+                sb.append( " invalidCredentials\n" );
+                break;
+
+            case 50 :
+                sb.append( " insufficientAccessRights\n" );
+                break;
+
+            case 51 :
+                sb.append( " busy\n" );
+                break;
+
+            case 52 :
+                sb.append( " unavailable\n" );
+                break;
+
+            case 53 :
+                sb.append( " unwillingToPerform\n" );
+                break;
+
+            case 54 :
+                sb.append( " loopDetect\n" );
+                break;
+
+            case 55 :
+            case 56 :
+            case 57 :
+            case 58 :
+            case 59 :
+            case 60 :
+            case 61 :
+            case 62 :
+            case 63 :
+                sb.append( " -- 55-63 unused --\n" );
+                break;
+
+            case 64 :
+                sb.append( " namingViolation\n" );
+                break;
+
+            case 65 :
+                sb.append( " objectClassViolation\n" );
+                break;
+
+            case 66 :
+                sb.append( " notAllowedOnNonLeaf\n" );
+                break;
+
+            case 67 :
+                sb.append( " notAllowedOnRDN\n" );
+                break;
+
+            case 68 :
+                sb.append( " entryAlreadyExists\n" );
+                break;
+
+            case 69 :
+                sb.append( " objectClassModsProhibited\n" );
+                break;
+
+            case 70 :
+                sb.append( " -- 70 reserved for CLDAP --\n" );
+                break;
+
+            case 71 :
+                sb.append( " affectsMultipleDSAs -- new\n" );
+                break;
+
+            case 72 :
+            case 73 :
+            case 74 :
+            case 75 :
+            case 76 :
+            case 77 :
+            case 78 :
+            case 79 :
+                sb.append( " -- 72-79 unused --\n" );
+                break;
+
+            case 80 :
+                sb.append( " other\n" );
+                break;
+
+            case 81 :
+            case 82 :
+            case 83 :
+            case 84 :
+            case 85 :
+            case 86 :
+            case 87 :
+            case 88 :
+            case 89 :
+            case 90 :
+                sb.append( " -- 81-90 reserved for APIs --" );
+                break;
+        }
+
+        sb.append( "            Matched DN : '" ).append( matchedDN.toString() ).append( "'\n" );
+        sb.append( "            Error message : '" ).append( errorMessage.toString() ).append( "'\n" );
+
+        if ( referrals.size() != 0 )
+        {
+            sb.append( "            Referrals :\n" );
+
+            for ( int i = 0; i < referrals.size(); i++ )
+            {
+
+                LdapURL referral = ( LdapURL ) referrals.get( i );
+
+                sb.append( "                Referral[" ).append( i ).append( "] :" ).append( referral.toString() )
+                        .append( '\n' );
+            }
+        }
+
+        return sb.toString();
+    }
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,276 @@
+/*
+ *   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;
+import org.apache.asn1new.ldap.codec.primitives.RelativeLdapDN;
+
+
+/**
+ * A ModifyDNRequest Message. Its syntax is :
+ * ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+ *                 entry           LDAPDN,
+ *                 newrdn          RelativeLDAPDN,
+ *                 deleteoldrdn    BOOLEAN,
+ *                 newSuperior     [0] LDAPDN OPTIONAL }
+ *  
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModifyDNRequest extends LdapMessage
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The DN to be modified. */
+    private LdapDN entry;
+
+    /** The new RDN to be added to the RDN or to the new superior, if present */
+    private RelativeLdapDN newRDN;
+
+    /** If the previous RDN is to be deleted, this flag will be set to true */
+    private boolean deleteOldRDN;
+
+    /** The optional superior, which will be concatened to the newRdn */
+    private LdapDN newSuperior;
+    
+    /** The modify DN request length */
+    private transient int modifyDNRequestLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new ModifyDNRequest object.
+     */
+    public ModifyDNRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.MODIFYDN_REQUEST;
+    }
+
+    /**
+     * Get the modification's DN
+     * @return Returns the entry.
+     */
+    public String getEntry()
+    {
+        return ( ( entry == null ) ? "" : entry.toString() );
+    }
+
+    /**
+     * Set the modification DN.
+     * @param entry The entry to set.
+     */
+    public void setEntry( LdapDN entry )
+    {
+        this.entry = entry;
+    }
+
+    /**
+     * Tells if the old RDN is to be deleted
+     *
+     * @return Returns the deleteOldRDN.
+     */
+    public boolean isDeleteOldRDN()
+    {
+        return deleteOldRDN;
+    }
+
+    /**
+     * Set the flag to delete the old RDN
+     *
+     * @param deleteOldRDN The deleteOldRDN to set.
+     */
+    public void setDeleteOldRDN( boolean deleteOldRDN )
+    {
+        this.deleteOldRDN = deleteOldRDN;
+    }
+
+    /**
+     * Get the new RDN
+     *
+     * @return Returns the newRDN.
+     */
+    public String getNewRDN()
+    {
+        return ( ( newRDN == null ) ? "" : newRDN.toString() );
+    }
+
+    /**
+     * Set the new RDN
+     *
+     * @param newRDN The newRDN to set.
+     */
+    public void setNewRDN( RelativeLdapDN newRDN )
+    {
+        this.newRDN = newRDN;
+    }
+
+    /**
+     * Get the newSuperior
+     *
+     * @return Returns the newSuperior.
+     */
+    public String getNewSuperior()
+    {
+        return ( ( newSuperior == null ) ? "" : newSuperior.toString() );
+    }
+
+    /**
+     * Set the new superior
+     *
+     * @param newSuperior The newSuperior to set.
+     */
+    public void setNewSuperior( LdapDN newSuperior )
+    {
+        this.newSuperior = newSuperior;
+    }
+
+    /**
+     * Compute the ModifyDNRequest length
+     * 
+     * ModifyDNRequest :
+     * 
+     * 0x6C L1
+     *  |
+     *  +--> 0x04 L2 entry
+     *  +--> 0x04 L3 newRDN
+     *  +--> 0x01 0x01 (true/false) deleteOldRDN (3 bytes)
+     * [+--> 0x80 L4 newSuperior ] 
+     * 
+     * L2 = Length(0x04) + Length(Length(entry)) + Length(entry) 
+     * L3 = Length(0x04) + Length(Length(newRDN)) + Length(newRDN) 
+     * L4 = Length(0x80) + Length(Length(newSuperior)) + Length(newSuperior)
+     * L1 = L2 + L3 + 3 [+ L4] 
+     * 
+     * Length(ModifyDNRequest) = Length(0x6C) + Length(L1) + L1
+     * @return DOCUMENT ME!
+    */
+    public int computeLength()
+    {
+
+        modifyDNRequestLength =
+            1 + Length.getNbBytes( entry.getLength() ) + entry.getLength() +
+            1 + Length.getNbBytes( newRDN.getLength() ) + newRDN.getLength() +
+            1 + 1 + 1; // deleteOldRDN
+
+        if ( newSuperior != null )
+        {
+            modifyDNRequestLength += 1 + Length.getNbBytes( newSuperior.getLength() ) +
+                newSuperior.getLength();
+        }
+
+        return 1 + Length.getNbBytes( modifyDNRequestLength ) + modifyDNRequestLength;
+    }
+
+    /**
+     * Encode the ModifyDNRequest message to a PDU.
+     * 
+     * ModifyDNRequest :
+     * 
+     * 0x6C LL
+     *   0x04 LL entry
+     *   0x04 LL newRDN
+     *   0x01 0x01 deleteOldRDN
+     *   [0x80 LL newSuperior]
+     * 
+     * @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 ModifyDNRequest Tag
+            buffer.put( LdapConstants.MODIFY_DN_REQUEST_TAG );
+            buffer.put( Length.getBytes( modifyDNRequestLength ) ) ;
+
+            // The entry
+            Value.encode( buffer, entry );
+            
+            // The newRDN
+            Value.encode( buffer, newRDN );
+            
+            // The flag deleteOldRdn
+            Value.encode( buffer, deleteOldRDN );
+            
+            // The new superior, if any
+            if ( newSuperior != null )
+            {
+                // Encode the reference
+                buffer.put( (byte)LdapConstants.MODIFY_DN_REQUEST_NEW_SUPERIOR_TAG );
+                buffer.put( Length.getBytes( newSuperior.getLength() ) );
+                
+                if ( newSuperior.getLength() != 0 )
+                {
+                    buffer.put( newSuperior.getData() );
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of a ModifyDNRequest
+     *
+     * @return A ModifyDNRequest String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    ModifyDN Response\n" );
+        sb.append( "        Entry : '" ).append( entry ).append( "'\n" );
+        sb.append( "        New RDN : '" ).append( newRDN.toString() ).append( "'\n" );
+        sb.append( "        Delete old RDN : " ).append( deleteOldRDN ).append( "\n" );
+
+        if ( newSuperior != null )
+        {
+            sb.append( "        New superior : '" ).append( newSuperior.toString() ).append(
+                "'\n" );
+        }
+
+        return sb.toString();
+    }
+}

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

Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNResponse.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNResponse.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNResponse.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNResponse.java Fri Sep  9 14:41:22 2005
@@ -0,0 +1,117 @@
+/*
+ *   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 ModifyDNResponse Message. Its syntax is :
+ *   ModifyDNResponse ::= [APPLICATION 13] LDAPResult
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModifyDNResponse extends LdapResponse
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new ModifyDNResponse object.
+     */
+    public ModifyDNResponse()
+    {
+        super( );
+    }
+
+    /**
+     * Get the message type
+     *
+     * @return Returns the type.
+     */
+    public int getMessageType()
+    {
+        return LdapConstants.MODIFYDN_RESPONSE;
+    }
+
+    /**
+     * Compute the ModifyDNResponse length
+     * 
+     * ModifyDNResponse :
+     * 
+     * 0x6D L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(ModifyDNResponse) = Length(0x6D) + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        int ldapResponseLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+    }
+
+    /**
+     * Encode the ModifyDNResponse 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.MODIFY_DN_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 ModifyDNResponse
+     *
+     * @return A ModifyDNResponse String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Modify DN 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/ModifyDNResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native