directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [directory-ldap-api] 04/05: o Added a NoD factory o Renamed the ExtendedResponseImpl to AbstractyExtendedResponse o Fixed the StartTransaction encoding and decoding o Passed the OID for extended response that don't have one. It's removed while encoding the response o Handled OpaqueExtendedResponse properly in the LdapNetworkConnection class (copying controls and LdapResult) o The ExtendedFuture now hold the extendedRequest to be able to matrch the response when it has no OID o Fixed the API<->JNDI conversions o Regis [...]
Date Tue, 01 Jan 2019 11:17:28 GMT
This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git

commit 8c30eec2ef1be5a553e45a234011616e8541774e
Author: Emmanuel Lecharny <elecharny@apache.org>
AuthorDate: Mon Dec 31 19:21:27 2018 +0100

    o Added a NoD factory
    o Renamed the ExtendedResponseImpl to AbstractyExtendedResponse
    o Fixed the StartTransaction encoding and decoding
    o Passed the OID for extended response that don't have one. It's removed
    while encoding the response
    o Handled OpaqueExtendedResponse properly in the LdapNetworkConnection
    class (copying controls and LdapResult)
    o The ExtendedFuture now hold the extendedRequest to be able to matrch
    the response when it has no OID
    o Fixed the API<->JNDI conversions
    o Registered the NoDFactory in the LdapApiService
---
 .../api/dsmlv2/response/Dsmlv2ResponseGrammar.java |   6 +-
 .../api/dsmlv2/response/ExtendedResponseDsml.java  |   4 +-
 .../ldap/client/api/LdapNetworkConnection.java     |  66 +++++++---
 .../ldap/client/api/future/ExtendedFuture.java     |  43 ++++++
 .../extended/StoreExtendedResponseName.java        |   2 +-
 .../api/AbstractExtendedOperationFactory.java      |   5 +
 .../ldap/codec/osgi/DefaultLdapCodecService.java   |  23 +++-
 .../ldap/codec/standalone/CodecFactoryUtil.java    |  10 ++
 .../extras/extended/cancel/CancelResponseImpl.java |   4 +-
 .../certGeneration/CertGenerationResponseImpl.java |  17 +--
 .../endTransaction/EndTransactionResponseImpl.java |  17 +--
 .../GracefulDisconnectResponseImpl.java            |  17 +--
 .../GracefulShutdownResponseImpl.java              |  16 +--
 .../pwdModify/PasswordModifyResponseImpl.java      |  12 +-
 .../extended/startTls/StartTlsResponseImpl.java    |   4 +-
 .../StartTransactionResponseImpl.java              |   4 +-
 .../StoredProcedureResponseImpl.java               |   4 +-
 .../extras/extended/whoAmI/WhoAmIResponseImpl.java |   4 +-
 .../endTransaction/EndTransactionFactory.java      |   5 +
 .../StartTlsFactory.java => nod/NoDFactory.java}   |  40 ++----
 .../ads_impl/pwdModify/PasswordModifyFactory.java  |   5 +
 .../ads_impl/startTls/StartTlsFactory.java         |  10 --
 .../startTransaction/StartTransactionFactory.java  |  28 ++++
 ...onseImpl.java => AbstractExtendedResponse.java} |  10 +-
 .../api/ldap/model/message/ExtendedResponse.java   |   8 --
 .../ldap/model/message/OpaqueExtendedRequest.java  |   4 +-
 .../ldap/model/message/OpaqueExtendedResponse.java |  87 ++++--------
 .../message/extended/ExtendedNoDResponse.java      |  17 +--
 .../model/message/extended/NoticeOfDisconnect.java |  50 ++++---
 ...plTest.java => OpaqueExtendedResponseTest.java} | 146 ++++-----------------
 30 files changed, 299 insertions(+), 369 deletions(-)

diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/Dsmlv2ResponseGrammar.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/Dsmlv2ResponseGrammar.java
index cd52f10..e96dd28 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/Dsmlv2ResponseGrammar.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/Dsmlv2ResponseGrammar.java
@@ -51,11 +51,11 @@ import org.apache.directory.api.ldap.model.message.CompareResponseImpl;
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.message.DeleteResponseImpl;
 import org.apache.directory.api.ldap.model.message.ExtendedResponse;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
 import org.apache.directory.api.ldap.model.message.LdapResult;
 import org.apache.directory.api.ldap.model.message.Message;
 import org.apache.directory.api.ldap.model.message.ModifyDnResponseImpl;
 import org.apache.directory.api.ldap.model.message.ModifyResponseImpl;
+import org.apache.directory.api.ldap.model.message.OpaqueExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ReferralImpl;
 import org.apache.directory.api.ldap.model.message.Response;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
@@ -459,13 +459,13 @@ public final class Dsmlv2ResponseGrammar extends AbstractGrammar implements Gram
             if ( attributeValue != null )
             {
                 extendedResponse = new ExtendedResponseDsml(
-                    container.getLdapCodecService(), new ExtendedResponseImpl(
+                    container.getLdapCodecService(), new OpaqueExtendedResponse(
                         ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ) );
             }
             else
             {
                 extendedResponse = new ExtendedResponseDsml(
-                    container.getLdapCodecService(), new ExtendedResponseImpl( -1 ) );
+                    container.getLdapCodecService(), new OpaqueExtendedResponse( -1 ) );
             }
 
             container.getBatchResponse().addResponse( extendedResponse );
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ExtendedResponseDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ExtendedResponseDsml.java
index 479ac47..63cdbc7 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ExtendedResponseDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ExtendedResponseDsml.java
@@ -24,8 +24,8 @@ import org.apache.directory.api.asn1.util.Oid;
 import org.apache.directory.api.dsmlv2.ParserUtils;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
 import org.apache.directory.api.ldap.model.message.ExtendedResponse;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
 import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
+import org.apache.directory.api.ldap.model.message.OpaqueExtendedResponse;
 import org.apache.directory.api.util.Strings;
 import org.dom4j.Element;
 import org.dom4j.Namespace;
@@ -52,7 +52,7 @@ public class ExtendedResponseDsml extends AbstractResultResponseDsml<ExtendedRes
      */
     public ExtendedResponseDsml( LdapApiService codec )
     {
-        super( codec, new ExtendedResponseImpl( "" ) );
+        super( codec, new OpaqueExtendedResponse( "" ) );
     }
 
 
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
index c37e269..44cf8eb 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
@@ -113,6 +113,7 @@ import org.apache.directory.api.ldap.model.message.ModifyRequest;
 import org.apache.directory.api.ldap.model.message.ModifyRequestImpl;
 import org.apache.directory.api.ldap.model.message.ModifyResponse;
 import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;
+import org.apache.directory.api.ldap.model.message.OpaqueExtendedResponse;
 import org.apache.directory.api.ldap.model.message.Request;
 import org.apache.directory.api.ldap.model.message.Response;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
@@ -1482,6 +1483,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
         {
             // Catch all other exceptions
             LOG.error( NO_RESPONSE_ERROR, ie );
+            
             throw new LdapException( NO_RESPONSE_ERROR, ie );
         }
     }
@@ -2644,6 +2646,8 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
                         LOG.debug( I18n.msg( I18n.MSG_04117_EXTENDED_FAILED, extendedResponse ) );
                     }
                 }
+                
+                extendedResponse = handleOpaqueResponse( extendedResponse, extendedFuture );
 
                 // Store the response into the future
                 extendedFuture.set( extendedResponse );
@@ -2808,6 +2812,37 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
         }
     }
 
+    
+    private ExtendedResponse handleOpaqueResponse( ExtendedResponse extendedResponse, ExtendedFuture extendedFuture ) 
+        throws DecoderException
+    {
+        if ( ( extendedResponse instanceof OpaqueExtendedResponse ) 
+            && ( Strings.isEmpty( extendedResponse.getResponseName() ) ) ) 
+        {
+            ExtendedOperationFactory factory = codec.getExtendedResponseFactories().
+                get( extendedFuture.getExtendedRequest().getRequestName() );
+            
+            ExtendedResponse response = factory.newResponse( ( ( OpaqueExtendedResponse ) extendedResponse ).getResponseValue() );
+            
+            // Copy the controls
+            for ( Control control : extendedResponse.getControls().values() )
+            {
+                response.addControl( control );
+            }
+            
+            // copy the LDAPResult
+            response.getLdapResult().setDiagnosticMessage( extendedResponse.getLdapResult().getDiagnosticMessage() );
+            response.getLdapResult().setMatchedDn( extendedResponse.getLdapResult().getMatchedDn() );
+            response.getLdapResult().setReferral( extendedResponse.getLdapResult().getReferral() );
+            response.getLdapResult().setResultCode( extendedResponse.getLdapResult().getResultCode() );
+            
+            return response;
+        }
+        else
+        {
+            return extendedResponse;
+        }
+    }
 
     /**
      * {@inheritDoc}
@@ -3901,8 +3936,15 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
         if ( factory != null )
         {
             try
-            {            
-                return extended( factory.newRequest( value ) );
+            {
+                if ( value == null )
+                {
+                    return extended( factory.newRequest() );
+                }
+                else
+                {
+                    return extended( factory.newRequest( value ) );
+                }
             }
             catch ( DecoderException de )
             {
@@ -4024,6 +4066,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
 
         extendedRequest.setMessageId( newId );
         ExtendedFuture extendedFuture = new ExtendedFuture( this, newId );
+        extendedFuture.setExtendedRequest( extendedRequest );
         addToFutureMap( newId, extendedFuture );
 
         // Send the request to the server
@@ -4453,25 +4496,6 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
     }
 
 
-    private void addControls( Message codec, Message message )
-    {
-        Map<String, Control> controls = codec.getControls();
-
-        if ( controls != null )
-        {
-            for ( Control cc : controls.values() )
-            {
-                if ( cc == null )
-                {
-                    continue;
-                }
-
-                message.addControl( cc );
-            }
-        }
-    }
-
-
     /**
      * removes the Objects associated with the given message ID
      * from future and response queue maps
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java
index 0feacee..229f470 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ExtendedFuture.java
@@ -20,6 +20,8 @@
 package org.apache.directory.ldap.client.api.future;
 
 
+import org.apache.directory.api.ldap.model.message.ExtendedRequest;
+import org.apache.directory.api.ldap.model.message.ExtendedResponse;
 import org.apache.directory.api.ldap.model.message.Response;
 import org.apache.directory.ldap.client.api.LdapConnection;
 
@@ -31,6 +33,11 @@ import org.apache.directory.ldap.client.api.LdapConnection;
  */
 public class ExtendedFuture extends MultipleResponseFuture<Response>
 {
+    /** 
+     * The extendedRequest : we need it to find which request is associated 
+     * with a response, when this response has no name */
+    ExtendedRequest extendedRequest;
+    
     /**
      * Creates a new instance of ExtendedFuture.
      *
@@ -44,6 +51,42 @@ public class ExtendedFuture extends MultipleResponseFuture<Response>
 
 
     /**
+     * @return the extendedRequest
+     */
+    public ExtendedRequest getExtendedRequest()
+    {
+        return extendedRequest;
+    }
+
+
+    /**
+     * @param extendedRequest the extendedRequest to set
+     */
+    public void setExtendedRequest( ExtendedRequest extendedRequest )
+    {
+        this.extendedRequest = extendedRequest;
+    }
+
+
+    /**
+     * Set the associated Response in this Future
+     * 
+     * @param response The response to add into the Future
+     * @throws InterruptedException if the operation has been cancelled by client
+     */
+    public void set( ExtendedResponse response ) throws InterruptedException
+    {
+        if ( response.getResponseName() == null )
+        {
+            // Feed the response with the request's OID 
+            response.setResponseName( extendedRequest.getRequestName() );
+        }
+        
+        queue.add( response );
+    }
+
+
+    /**
      * {@inheritDoc}
      */
     @Override
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/response/extended/StoreExtendedResponseName.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/response/extended/StoreExtendedResponseName.java
index 1bd94b5..6ab6a30 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/response/extended/StoreExtendedResponseName.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/response/extended/StoreExtendedResponseName.java
@@ -103,7 +103,7 @@ public class StoreExtendedResponseName extends GrammarAction<LdapMessageContaine
                 
                 if ( factory != null )
                 {
-                    // Create the extended request
+                    // Create the extended response
                     extendedResponse = factory.newResponse();
 
                     // Move the LDAPResult in the newly created response
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/AbstractExtendedOperationFactory.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/AbstractExtendedOperationFactory.java
index 74ec8db..d1a9fd2 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/AbstractExtendedOperationFactory.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/AbstractExtendedOperationFactory.java
@@ -23,6 +23,8 @@ import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.util.Asn1Buffer;
 import org.apache.directory.api.ldap.model.message.ExtendedRequest;
 import org.apache.directory.api.ldap.model.message.ExtendedResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A Factory to encode Extended Request and Response messages
@@ -31,6 +33,9 @@ import org.apache.directory.api.ldap.model.message.ExtendedResponse;
  */
 public abstract class AbstractExtendedOperationFactory implements ExtendedOperationFactory
 {
+    /** logger for reporting errors that might not be handled properly upstream */
+    protected  static final Logger LOG = LoggerFactory.getLogger( AbstractExtendedOperationFactory.class );
+    
     /** The LDAP codec responsible for encoding and decoding */
     protected LdapApiService codec;
     
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
index 1e419fb..e4371f6 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
@@ -349,10 +349,25 @@ public class DefaultLdapCodecService implements LdapApiService
     {
         // We don't know if it's a request or a response control. Test with request contriols
         ControlFactory<?> factory = requestControlFactories.get( control.getOid() );
-        Asn1Buffer asn1Buffer = new Asn1Buffer();
-        factory.encodeValue( asn1Buffer, control );
-
-        return new BasicControl( control.getOid(), control.isCritical(), asn1Buffer.getBytes().array() );
+        
+        if ( factory == null )
+        {
+            if ( control instanceof OpaqueControl )
+            {
+                return new BasicControl( control.getOid(), control.isCritical(), ( ( OpaqueControl ) control ).getEncodedValue() );
+            }
+            else
+            {
+                return new BasicControl( control.getOid(), control.isCritical(), null );
+            }
+        }
+        else
+        {
+            Asn1Buffer asn1Buffer = new Asn1Buffer();
+            factory.encodeValue( asn1Buffer, control );
+    
+            return new BasicControl( control.getOid(), control.isCritical(), asn1Buffer.getBytes().array() );
+        }
     }
 
 
diff --git a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
index 21bdd3a..bbe7d16 100644
--- a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
+++ b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
@@ -69,6 +69,7 @@ import org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.Cer
 import org.apache.directory.api.ldap.extras.extended.ads_impl.endTransaction.EndTransactionFactory;
 import org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory;
 import org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown.GracefulShutdownFactory;
+import org.apache.directory.api.ldap.extras.extended.ads_impl.nod.NoDFactory;
 import org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify.PasswordModifyFactory;
 import org.apache.directory.api.ldap.extras.extended.ads_impl.startTls.StartTlsFactory;
 import org.apache.directory.api.ldap.extras.extended.ads_impl.startTransaction.StartTransactionFactory;
@@ -388,11 +389,20 @@ public final class CodecFactoryUtil
         extendendRequestFactories.put( gracefulShutdownFactory.getOid(), gracefulShutdownFactory );
         extendendResponseFactories.put( gracefulShutdownFactory.getOid(), gracefulShutdownFactory );
 
+        
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, gracefulShutdownFactory.getOid() ) );
         }
 
+        NoDFactory noticeOfDisconnectFactory = new NoDFactory( apiService );
+        extendendResponseFactories.put( noticeOfDisconnectFactory.getOid(), noticeOfDisconnectFactory );
+
+        if ( LOG.isInfoEnabled() )
+        {
+            LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, noticeOfDisconnectFactory.getOid() ) );
+        }
+
         PasswordModifyFactory passwordModifyFactory = new PasswordModifyFactory( apiService );
         extendendRequestFactories.put( passwordModifyFactory.getOid(), passwordModifyFactory );
         extendendResponseFactories.put( passwordModifyFactory.getOid(), passwordModifyFactory );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelResponseImpl.java
index 605410c..631a0d3 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/cancel/CancelResponseImpl.java
@@ -21,7 +21,7 @@ package org.apache.directory.api.ldap.extras.extended.cancel;
 
 
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 
 
@@ -31,7 +31,7 @@ import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CancelResponseImpl extends ExtendedResponseImpl implements CancelResponse
+public class CancelResponseImpl extends AbstractExtendedResponse implements CancelResponse
 {
     /**
      * Create a new CancelResponse object
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationResponseImpl.java
index 6e65d94..d51e8bc 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/certGeneration/CertGenerationResponseImpl.java
@@ -21,7 +21,7 @@ package org.apache.directory.api.ldap.extras.extended.certGeneration;
 
 
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 
 
@@ -31,7 +31,7 @@ import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CertGenerationResponseImpl extends ExtendedResponseImpl implements CertGenerationResponse
+public class CertGenerationResponseImpl extends AbstractExtendedResponse implements CertGenerationResponse
 {
     /**
      * Create a new CertGenerationResponseImpl instance
@@ -85,19 +85,6 @@ public class CertGenerationResponseImpl extends ExtendedResponseImpl implements
 
 
     /**
-     * Gets the OID uniquely identifying this extended response (a.k.a. its
-     * name).
-     * 
-     * @return the OID of the extended response type.
-     */
-    @Override
-    public String getResponseName()
-    {
-        return EXTENSION_OID;
-    }
-
-
-    /**
      * Sets the OID uniquely identifying this extended response (a.k.a. its
      * name).
      * 
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/endTransaction/EndTransactionResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/endTransaction/EndTransactionResponseImpl.java
index b037b2f..d74fbf3 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/endTransaction/EndTransactionResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/endTransaction/EndTransactionResponseImpl.java
@@ -23,7 +23,7 @@ package org.apache.directory.api.ldap.extras.extended.endTransaction;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 
 
@@ -54,7 +54,7 @@ import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class EndTransactionResponseImpl extends ExtendedResponseImpl implements EndTransactionResponse
+public class EndTransactionResponseImpl extends AbstractExtendedResponse implements EndTransactionResponse
 {
     /** The faulty Message ID, if any */
     private int failedMessageId = -1;
@@ -108,19 +108,6 @@ public class EndTransactionResponseImpl extends ExtendedResponseImpl implements
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
     }
-
-
-    /**
-     * Gets the OID uniquely identifying this extended response (a.k.a. its
-     * name). It's a null value for the Cancel response
-     * 
-     * @return the OID of the extended response type.
-     */
-    @Override
-    public String getResponseName()
-    {
-        return "";
-    }
     
     
     /**
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulDisconnect/GracefulDisconnectResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulDisconnect/GracefulDisconnectResponseImpl.java
index af0004a..703833b 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulDisconnect/GracefulDisconnectResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulDisconnect/GracefulDisconnectResponseImpl.java
@@ -21,7 +21,7 @@ package org.apache.directory.api.ldap.extras.extended.gracefulDisconnect;
 
 
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.Referral;
 import org.apache.directory.api.ldap.model.message.ReferralImpl;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
@@ -36,7 +36,7 @@ import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class GracefulDisconnectResponseImpl extends ExtendedResponseImpl implements GracefulDisconnectResponse
+public class GracefulDisconnectResponseImpl extends AbstractExtendedResponse implements GracefulDisconnectResponse
 {
     /** Offline time after disconnection */
     private int timeOffline;
@@ -81,19 +81,6 @@ public class GracefulDisconnectResponseImpl extends ExtendedResponseImpl impleme
 
 
     /**
-     * Gets the OID uniquely identifying this extended response (a.k.a. its
-     * name).
-     * 
-     * @return the OID of the extended response type.
-     */
-    @Override
-    public String getResponseName()
-    {
-        return EXTENSION_OID;
-    }
-
-
-    /**
      * Sets the OID uniquely identifying this extended response (a.k.a. its
      * name).
      * 
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownResponseImpl.java
index 2a4ea41..5bfc0fe 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/gracefulShutdown/GracefulShutdownResponseImpl.java
@@ -21,7 +21,7 @@ package org.apache.directory.api.ldap.extras.extended.gracefulShutdown;
 
 
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 
 
@@ -32,7 +32,7 @@ import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class GracefulShutdownResponseImpl extends ExtendedResponseImpl implements GracefulShutdownResponse
+public class GracefulShutdownResponseImpl extends AbstractExtendedResponse implements GracefulShutdownResponse
 {
     /**
      * Instantiates a new graceful shutdown response.
@@ -93,18 +93,6 @@ public class GracefulShutdownResponseImpl extends ExtendedResponseImpl implement
     // ExtendedResponse Interface Method Implementations
     // ------------------------------------------------------------------------
 
-    /**
-     * Gets the OID uniquely identifying this extended response (a.k.a. its
-     * name).
-     * 
-     * @return the OID of the extended response type.
-     */
-    @Override
-    public String getResponseName()
-    {
-        return EXTENSION_OID;
-    }
-
 
     /**
      * Sets the OID uniquely identifying this extended response (a.k.a. its
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyResponseImpl.java
index acc7be4..75db6c9 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/pwdModify/PasswordModifyResponseImpl.java
@@ -20,7 +20,7 @@
 package org.apache.directory.api.ldap.extras.extended.pwdModify;
 
 
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.util.Strings;
 
@@ -35,7 +35,7 @@ import org.apache.directory.api.util.Strings;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PasswordModifyResponseImpl extends ExtendedResponseImpl implements PasswordModifyResponse
+public class PasswordModifyResponseImpl extends AbstractExtendedResponse implements PasswordModifyResponse
 {
     /** The generated password */
     private byte[] genPassword;
@@ -49,7 +49,7 @@ public class PasswordModifyResponseImpl extends ExtendedResponseImpl implements
      */
     public PasswordModifyResponseImpl( int messageId, ResultCodeEnum rcode, String diagnosticMessage )
     {
-        super( messageId, null );
+        super( messageId, PasswordModifyResponse.EXTENSION_OID );
 
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( rcode );
@@ -64,7 +64,7 @@ public class PasswordModifyResponseImpl extends ExtendedResponseImpl implements
      */
     public PasswordModifyResponseImpl( int messageId, ResultCodeEnum rcode )
     {
-        super( messageId, null );
+        super( messageId, PasswordModifyResponse.EXTENSION_OID );
 
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( rcode );
@@ -78,7 +78,7 @@ public class PasswordModifyResponseImpl extends ExtendedResponseImpl implements
      */
     public PasswordModifyResponseImpl( int messageId )
     {
-        super( messageId, null );
+        super( messageId, PasswordModifyResponse.EXTENSION_OID );
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
     }
@@ -89,7 +89,7 @@ public class PasswordModifyResponseImpl extends ExtendedResponseImpl implements
      */
     public PasswordModifyResponseImpl()
     {
-        super( null );
+        super( PasswordModifyResponse.EXTENSION_OID );
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
     }
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsResponseImpl.java
index a2f7294..40f17ca 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTls/StartTlsResponseImpl.java
@@ -20,7 +20,7 @@
 package org.apache.directory.api.ldap.extras.extended.startTls;
 
 
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 
 
@@ -29,7 +29,7 @@ import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StartTlsResponseImpl extends ExtendedResponseImpl implements StartTlsResponse
+public class StartTlsResponseImpl extends AbstractExtendedResponse implements StartTlsResponse
 {
     /**
      * Create a new instance for the StartTls response
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTransaction/StartTransactionResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTransaction/StartTransactionResponseImpl.java
index f0d36a9..1176c5d 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTransaction/StartTransactionResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTransaction/StartTransactionResponseImpl.java
@@ -23,7 +23,7 @@ package org.apache.directory.api.ldap.extras.extended.startTransaction;
 import java.util.Arrays;
 
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.util.Strings;
 
@@ -43,7 +43,7 @@ import org.apache.directory.api.util.Strings;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StartTransactionResponseImpl extends ExtendedResponseImpl implements StartTransactionResponse
+public class StartTransactionResponseImpl extends AbstractExtendedResponse implements StartTransactionResponse
 {
     /** The transaction ID if the request was successful */
     private byte[] transactionId;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureResponseImpl.java
index bcd1d0c..b8b6939 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/storedProcedure/StoredProcedureResponseImpl.java
@@ -20,7 +20,7 @@
 package org.apache.directory.api.ldap.extras.extended.storedProcedure;
 
 
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 
 
 /**
@@ -29,7 +29,7 @@ import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoredProcedureResponseImpl extends ExtendedResponseImpl implements StoredProcedureResponse
+public class StoredProcedureResponseImpl extends AbstractExtendedResponse implements StoredProcedureResponse
 {
     /**
      * Instantiates a new stored procedure response.
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIResponseImpl.java
index 580155a..da7ff6f 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/whoAmI/WhoAmIResponseImpl.java
@@ -20,7 +20,7 @@
 package org.apache.directory.api.ldap.extras.extended.whoAmI;
 
 
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.util.Strings;
@@ -35,7 +35,7 @@ import org.apache.directory.api.util.Strings;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class WhoAmIResponseImpl extends ExtendedResponseImpl implements WhoAmIResponse
+public class WhoAmIResponseImpl extends AbstractExtendedResponse implements WhoAmIResponse
 {
     /** The authzid */
     private byte[] authzId;
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/endTransaction/EndTransactionFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/endTransaction/EndTransactionFactory.java
index 29d9792..dfe7616 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/endTransaction/EndTransactionFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/endTransaction/EndTransactionFactory.java
@@ -229,6 +229,11 @@ public class EndTransactionFactory extends AbstractExtendedOperationFactory
     @Override
     public void encodeValue( Asn1Buffer buffer, ExtendedResponse extendedResponse )
     {
+        // This is a hack !!! We remove the response name from the response
+        // because it has only be added to find the factory, but we don't want it
+        // top be injected in the encoded PDU...
+        extendedResponse.setResponseName( null );
+
         int start  = buffer.getPos();
         EndTransactionResponse endTransactionResponse = ( EndTransactionResponse ) extendedResponse;
         
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/nod/NoDFactory.java
similarity index 56%
copy from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
copy to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/nod/NoDFactory.java
index eef250b..2a86c00 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/nod/NoDFactory.java
@@ -17,34 +17,33 @@
  *   under the License.
  *
  */
-package org.apache.directory.api.ldap.extras.extended.ads_impl.startTls;
+package org.apache.directory.api.ldap.extras.extended.ads_impl.nod;
 
 
 import org.apache.directory.api.ldap.codec.api.AbstractExtendedOperationFactory;
 import org.apache.directory.api.ldap.codec.api.ExtendedOperationFactory;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequest;
-import org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequestImpl;
-import org.apache.directory.api.ldap.extras.extended.startTls.StartTlsResponse;
-import org.apache.directory.api.ldap.extras.extended.startTls.StartTlsResponseImpl;
+import org.apache.directory.api.ldap.model.message.ExtendedRequest;
+import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.api.ldap.model.message.extended.NoticeOfDisconnect;
 
 
 /**
- * An {@link ExtendedOperationFactory} for creating SartTls extended reques/response 
+ * An {@link ExtendedOperationFactory} for creating NoticeOfDisconnect extended response 
  * pairs.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StartTlsFactory extends AbstractExtendedOperationFactory
+public class NoDFactory extends AbstractExtendedOperationFactory
 {
     /**
-     * Creates a new instance of StartTlsFactory.
+     * Creates a new instance of NoDFactory.
      *
      * @param codec The codec for this factory.
      */
-    public StartTlsFactory( LdapApiService codec )
+    public NoDFactory( LdapApiService codec )
     {
-        super( codec, StartTlsRequest.EXTENSION_OID );
+        super( codec, NoticeOfDisconnect.EXTENSION_OID );
     }
 
 
@@ -52,28 +51,15 @@ public class StartTlsFactory extends AbstractExtendedOperationFactory
      * {@inheritDoc}
      */
     @Override
-    public String getOid()
+    public NoticeOfDisconnect newResponse()
     {
-        return StartTlsRequest.EXTENSION_OID;
+        return NoticeOfDisconnect.createNoticeOfDisconnect( ResultCodeEnum.PROTOCOL_ERROR );
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public StartTlsRequest newRequest()
-    {
-        return new StartTlsRequestImpl();
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     @Override
-    public StartTlsResponse newResponse()
+    public ExtendedRequest newRequest()
     {
-        return new StartTlsResponseImpl();
+        return null;
     }
 }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
index 43f3df8..15acc70 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
@@ -176,6 +176,11 @@ public class PasswordModifyFactory extends AbstractExtendedOperationFactory
     @Override
     public void encodeValue( Asn1Buffer buffer, ExtendedResponse extendedResponse )
     {
+        // This is a hack !!! We remove the response name from the response
+        // because it has only be added to find the factory, but we don't want it
+        // top be injected in the encoded PDU...
+        extendedResponse.setResponseName( null );
+
         int start  = buffer.getPos();
         
         // The gen password
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
index eef250b..2051864 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
@@ -52,16 +52,6 @@ public class StartTlsFactory extends AbstractExtendedOperationFactory
      * {@inheritDoc}
      */
     @Override
-    public String getOid()
-    {
-        return StartTlsRequest.EXTENSION_OID;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public StartTlsRequest newRequest()
     {
         return new StartTlsRequestImpl();
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTransaction/StartTransactionFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTransaction/StartTransactionFactory.java
index f657e52..f5a626b 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTransaction/StartTransactionFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTransaction/StartTransactionFactory.java
@@ -20,6 +20,7 @@
 package org.apache.directory.api.ldap.extras.extended.ads_impl.startTransaction;
 
 
+import org.apache.directory.api.asn1.util.Asn1Buffer;
 import org.apache.directory.api.ldap.codec.api.AbstractExtendedOperationFactory;
 import org.apache.directory.api.ldap.codec.api.ExtendedOperationFactory;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
@@ -27,6 +28,7 @@ import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTrans
 import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionRequestImpl;
 import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionResponse;
 import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionResponseImpl;
+import org.apache.directory.api.ldap.model.message.ExtendedResponse;
 
 
 /**
@@ -66,4 +68,30 @@ public class StartTransactionFactory extends AbstractExtendedOperationFactory
     {
         return new StartTransactionResponseImpl();
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public StartTransactionResponse newResponse( byte[] encodedValue )
+    {
+        return new StartTransactionResponseImpl( encodedValue );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void encodeValue( Asn1Buffer buffer, ExtendedResponse extendedResponse )
+    {
+        // This is a hack !!! We remove the response name from the response
+        // because it has only be added to find the factory, but we don't want it
+        // top be injected in the encoded PDU...
+        extendedResponse.setResponseName( null );
+        
+        // Now, encode the TransactiuonID
+        buffer.put( ( ( StartTransactionResponse ) extendedResponse  ).getTransactionId() );
+    }
 }
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractExtendedResponse.java
similarity index 93%
rename from ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImpl.java
rename to ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractExtendedResponse.java
index 6be87cf..c56ecb2 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/AbstractExtendedResponse.java
@@ -21,11 +21,11 @@ package org.apache.directory.api.ldap.model.message;
 
 
 /**
- * A simple ExtendedResponse implementation.
+ * An Abstract ExtendedResponse implementation.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ExtendedResponseImpl extends AbstractResultResponse implements ExtendedResponse
+public abstract class AbstractExtendedResponse extends AbstractResultResponse implements ExtendedResponse
 {
     static final long serialVersionUID = -6646752766410531060L;
 
@@ -40,7 +40,7 @@ public class ExtendedResponseImpl extends AbstractResultResponse implements Exte
      * 
      * @param responseName the ExtendedResponse's name
      */
-    public ExtendedResponseImpl( String responseName )
+    public AbstractExtendedResponse( String responseName )
     {
         super( -1, TYPE );
         this.responseName = responseName;
@@ -53,7 +53,7 @@ public class ExtendedResponseImpl extends AbstractResultResponse implements Exte
      * @param id the session unique message id
      * @param responseName the ExtendedResponse's name
      */
-    public ExtendedResponseImpl( final int id, String responseName )
+    public AbstractExtendedResponse( final int id, String responseName )
     {
         super( id, TYPE );
         this.responseName = responseName;
@@ -65,7 +65,7 @@ public class ExtendedResponseImpl extends AbstractResultResponse implements Exte
      * 
      * @param id the session unique message id
      */
-    public ExtendedResponseImpl( int id )
+    public AbstractExtendedResponse( int id )
     {
         super( id, TYPE );
     }
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponse.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponse.java
index 49c5db2..49a6983 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponse.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedResponse.java
@@ -44,12 +44,4 @@ public interface ExtendedResponse extends ResultResponse
      * @param oid the OID of the extended response type.
      */
     void setResponseName( String oid );
-    
-    
-    /**
-     * Gets the response value, if any.
-     * 
-     * @return The byte[] containing the value, or null if we have none. 
-     */
-    //byte[] getResponseValue();
 }
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedRequest.java
index 5de3bf4..63cdea7 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedRequest.java
@@ -39,7 +39,7 @@ public class OpaqueExtendedRequest extends AbstractRequest implements ExtendedRe
     private byte[] requestValue;
 
     /** The associated response */
-    protected ExtendedResponseImpl response;
+    protected ExtendedResponse response;
 
 
     /**
@@ -191,7 +191,7 @@ public class OpaqueExtendedRequest extends AbstractRequest implements ExtendedRe
     {
         if ( response == null )
         {
-            response = new ExtendedResponseImpl( getMessageId() );
+            response = new OpaqueExtendedResponse( getMessageId() );
         }
 
         return response;
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedResponse.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedResponse.java
index b7eeeef..29733bd 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedResponse.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedResponse.java
@@ -28,13 +28,10 @@ import org.apache.directory.api.util.Strings;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class OpaqueExtendedResponse extends AbstractResultResponse implements ExtendedResponse
+public class OpaqueExtendedResponse extends AbstractExtendedResponse
 {
     static final long serialVersionUID = 7916990159044177480L;
 
-    /** Extended response's Object Identifier or <b>responseName</b> */
-    private String oid;
-    
     /** Extended response value as an opaque byte array */
     private byte[] responseValue;
 
@@ -45,81 +42,47 @@ public class OpaqueExtendedResponse extends AbstractResultResponse implements Ex
      */
     public OpaqueExtendedResponse()
     {
-        super( -1, MessageTypeEnum.EXTENDED_RESPONSE );
+        super( -1 );
     }
 
 
-    // -----------------------------------------------------------------------
-    // ExtendedRequest Interface Method Implementations
-    // -----------------------------------------------------------------------
-
     /**
-     * Gets the Object Identifier corresponding to the extended response type.
-     * This is the <b>responseName</b> portion of the ext. req. PDU.
+     * Creates an ExtendedResponse implementing object used to perform
+     * extended protocol operation on the server.
      * 
-     * @return the dotted-decimal representation as a String of the OID
+     * @param messageId the messageID
      */
-    @Override
-    public String getResponseName()
+    public OpaqueExtendedResponse( int messageId )
     {
-        return oid;
+        super( messageId );
     }
 
 
     /**
-     * Sets the Object Identifier corresponding to the extended response type.
+     * Creates an ExtendedResponse implementing object used to perform
+     * extended protocol operation on the server.
      * 
-     * @param newOid the dotted-decimal representation as a String of the OID
-     */
-    @Override
-    public void setResponseName( String newOid )
-    {
-        this.oid = newOid;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public ExtendedResponse setMessageId( int messageId )
-    {
-        super.setMessageId( messageId );
-
-        return this;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public ExtendedResponse addControl( Control control )
-    {
-        return ( ExtendedResponse ) super.addControl( control );
-    }
-
-
-    /**
-     * {@inheritDoc}
+     * @param responseName The extended response OID
      */
-    @Override
-    public ExtendedResponse addAllControls( Control[] controls )
+    public OpaqueExtendedResponse( String responseName )
     {
-        return ( ExtendedResponse ) super.addAllControls( controls );
+        super( -1, responseName );
     }
 
 
     /**
-     * {@inheritDoc}
+     * Creates an ExtendedResponse implementing object used to perform
+     * extended protocol operation on the server.
+     * 
+     * @param messageId the messageID
+     * @param responseName The extended response OID
      */
-    @Override
-    public ExtendedResponse removeControl( Control control )
+    public OpaqueExtendedResponse( int messageId, String responseName )
     {
-        return ( ExtendedResponse ) super.removeControl( control );
+        super( messageId, responseName );
     }
 
-
+    
     // ------------------------------------------------------------------------
     // SingleReplyRequest Interface Method Implementations
     // ------------------------------------------------------------------------
@@ -152,9 +115,9 @@ public class OpaqueExtendedResponse extends AbstractResultResponse implements Ex
         
         hash = hash * 17 + super.hashCode();
 
-        if ( oid != null )
+        if ( responseName != null )
         {
-            hash = hash * 17 + oid.hashCode();
+            hash = hash * 17 + responseName.hashCode();
         }
         
         if ( responseValue != null )
@@ -195,8 +158,8 @@ public class OpaqueExtendedResponse extends AbstractResultResponse implements Ex
 
         OpaqueExtendedResponse extendedRequest = ( OpaqueExtendedResponse ) obj;
 
-        if ( ( ( oid != null ) && !oid.equals( extendedRequest.oid ) )
-            || ( ( oid == null ) && ( extendedRequest.oid != null ) ) )
+        if ( ( ( responseName != null ) && !responseName.equals( extendedRequest.responseName ) )
+            || ( ( responseName == null ) && ( extendedRequest.responseName != null ) ) )
         {
             return false;
         }
@@ -216,7 +179,7 @@ public class OpaqueExtendedResponse extends AbstractResultResponse implements Ex
         StringBuilder sb = new StringBuilder();
 
         sb.append( "    Extended response\n" );
-        sb.append( "        Response name :  '" ).append( oid ).append( "'\n" );
+        sb.append( "        Response name :  '" ).append( responseName ).append( "'\n" );
         sb.append( "        Response value : '" ).append( Strings.dumpBytes( responseValue ) ).append( "'\n" );
 
         return super.toString( sb.toString() );
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/ExtendedNoDResponse.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/ExtendedNoDResponse.java
index 2c3f467..b77cb6e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/ExtendedNoDResponse.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/ExtendedNoDResponse.java
@@ -21,7 +21,7 @@ package org.apache.directory.api.ldap.model.message.extended;
 
 
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.util.Strings;
 
@@ -31,7 +31,7 @@ import org.apache.directory.api.util.Strings;
  * disconnection for the Extended response. 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class ExtendedNoDResponse extends ExtendedResponseImpl
+public final class ExtendedNoDResponse extends AbstractExtendedResponse
 {
     /** The serial version UID */
     static final long serialVersionUID = 2L;
@@ -93,17 +93,4 @@ public final class ExtendedNoDResponse extends ExtendedResponseImpl
     {
         return Strings.EMPTY_BYTES;
     }
-
-
-    /**
-     * Gets the OID uniquely identifying this extended response (a.k.a. its
-     * name).
-     * 
-     * @return the OID of the extended response type.
-     */
-    @Override
-    public String getResponseName()
-    {
-        return EXTENSION_OID;
-    }
 }
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/NoticeOfDisconnect.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/NoticeOfDisconnect.java
index 96afb84..e75ef1e 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/NoticeOfDisconnect.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/extended/NoticeOfDisconnect.java
@@ -21,7 +21,7 @@ package org.apache.directory.api.ldap.model.message.extended;
 
 
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
+import org.apache.directory.api.ldap.model.message.AbstractExtendedResponse;
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.util.Strings;
 
@@ -102,7 +102,7 @@ import org.apache.directory.api.util.Strings;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class NoticeOfDisconnect extends ExtendedResponseImpl
+public final class NoticeOfDisconnect extends AbstractExtendedResponse
 {
     /** The OID of the NotiveOfDisconnect extended operation. */
     public static final String EXTENSION_OID = "1.3.6.1.4.1.1466.20036";
@@ -147,6 +147,39 @@ public final class NoticeOfDisconnect extends ExtendedResponseImpl
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( rcode );
     }
+    
+    
+    /**
+     * Create a NoD associated with a result code enum
+     *
+     * @param rcode The result code
+     * @return The created NoticeOfDisconnect
+     */
+    public static NoticeOfDisconnect createNoticeOfDisconnect( ResultCodeEnum rcode )
+    {
+        NoticeOfDisconnect nod;
+        
+        switch ( rcode )
+        {
+            case UNAVAILABLE:
+                nod = UNAVAILABLE;
+                
+            case PROTOCOL_ERROR:
+                nod = PROTOCOLERROR;
+                
+            case STRONG_AUTH_REQUIRED:
+                nod = STRONGAUTHREQUIRED;
+                
+            default:
+                nod = new NoticeOfDisconnect( rcode );
+        }
+        
+        nod.getLdapResult().setDiagnosticMessage( rcode.toString() + ": The server will disconnect!" );
+        nod.getLdapResult().setMatchedDn( null );
+        nod.getLdapResult().setResultCode( rcode );
+        
+        return nod;
+    }
 
 
     // ------------------------------------------------------------------------
@@ -176,19 +209,6 @@ public final class NoticeOfDisconnect extends ExtendedResponseImpl
 
 
     /**
-     * Gets the OID uniquely identifying this extended response (a.k.a. its
-     * name).
-     * 
-     * @return the OID of the extended response type.
-     */
-    @Override
-    public String getResponseName()
-    {
-        return EXTENSION_OID;
-    }
-
-
-    /**
      * Sets the OID uniquely identifying this extended response (a.k.a. its
      * name).
      * 
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImplTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedResponseTest.java
similarity index 54%
rename from ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImplTest.java
rename to ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedResponseTest.java
index 531b154..016b689 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/ExtendedResponseImplTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/message/OpaqueExtendedResponseTest.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -36,13 +37,13 @@ import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 
 
 /**
- * TestCase for the ExtendedResponseImpl class.
+ * TestCase for the ExtendedResponse class.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(ConcurrentJunitRunner.class)
 @Concurrency()
-public class ExtendedResponseImplTest
+public class OpaqueExtendedResponseTest
 {
     private static final Map<String, Control> EMPTY_CONTROL_MAP = new HashMap<String, Control>();
 
@@ -52,10 +53,10 @@ public class ExtendedResponseImplTest
      * 
      * @return a populated ExtendedResponseImpl stub
      */
-    private ExtendedResponseImpl createStub()
+    private ExtendedResponse createStub()
     {
         // Construct the Search response to test with results and referrals
-        ExtendedResponseImpl response = new ExtendedResponseImpl( 45 );
+        ExtendedResponse response = new OpaqueExtendedResponse( 45 );
         response.setResponseName( "1.1.1.1" );
         LdapResult result = response.getLdapResult();
 
@@ -84,7 +85,7 @@ public class ExtendedResponseImplTest
     @Test
     public void testEqualsSameObj()
     {
-        ExtendedResponseImpl resp = createStub();
+        ExtendedResponse resp = createStub();
         assertTrue( resp.equals( resp ) );
     }
 
@@ -95,8 +96,8 @@ public class ExtendedResponseImplTest
     @Test
     public void testEqualsExactCopy()
     {
-        ExtendedResponseImpl resp0 = createStub();
-        ExtendedResponseImpl resp1 = createStub();
+        ExtendedResponse resp0 = createStub();
+        ExtendedResponse resp1 = createStub();
         assertTrue( resp0.equals( resp1 ) );
         assertTrue( resp1.equals( resp0 ) );
     }
@@ -104,116 +105,23 @@ public class ExtendedResponseImplTest
 
     /**
      * Tests for equality using different stub implementations.
+     * @throws LdapInvalidDnException 
      */
     @Test
-    public void testEqualsDiffImpl()
+    public void testEqualsDiffImpl() throws LdapInvalidDnException
     {
-        ExtendedResponseImpl resp0 = createStub();
-        ExtendedResponse resp1 = new ExtendedResponse()
-        {
-            public String getResponseName()
-            {
-                return "1.1.1.1";
-            }
-
-
-            public void setResponseName( String oid )
-            {
-            }
-
-
-            public LdapResult getLdapResult()
-            {
-                LdapResultImpl result = new LdapResultImpl();
-
-                try
-                {
-                    result.setMatchedDn( new Dn( "dc=example,dc=com" ) );
-                }
-                catch ( LdapException ine )
-                {
-                    // do nothing
-                }
-
-                result.setResultCode( ResultCodeEnum.SUCCESS );
-                ReferralImpl refs = new ReferralImpl();
-                refs.addLdapUrl( "ldap://someserver.com" );
-                refs.addLdapUrl( "ldap://apache.org" );
-                refs.addLdapUrl( "ldap://another.net" );
-                result.setReferral( refs );
-
-                return result;
-            }
-
-
-            public MessageTypeEnum getType()
-            {
-                return MessageTypeEnum.EXTENDED_RESPONSE;
-            }
-
-
-            public Map<String, Control> getControls()
-            {
-                return EMPTY_CONTROL_MAP;
-            }
-
-
-            public ExtendedResponse addControl( Control control )
-            {
-                return this;
-            }
-
-
-            public ExtendedResponse removeControl( Control control )
-            {
-                return this;
-            }
-
-
-            public int getMessageId()
-            {
-                return 45;
-            }
-
-
-            public Object get( Object a_key )
-            {
-                return null;
-            }
-
-
-            public Object put( Object a_key, Object a_value )
-            {
-                return null;
-            }
-
-
-            public ExtendedResponse addAllControls( Control[] controls )
-            {
-                return this;
-            }
-
-
-            public boolean hasControl( String oid )
-            {
-                return false;
-            }
-
-
-            public Control getControl( String oid )
-            {
-                return null;
-            }
-
-
-            public ExtendedResponse setMessageId( int messageId )
-            {
-                return this;
-            }
-        };
+        ExtendedResponse resp0 = createStub();
+        ExtendedResponse resp1 = new OpaqueExtendedResponse( 45, "1.1.1.1" );
+        resp1.getLdapResult().setMatchedDn( new Dn( "dc=example,dc=com" ) );
+        resp1.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
+        ReferralImpl refs = new ReferralImpl();
+        refs.addLdapUrl( "ldap://someserver.com" );
+        refs.addLdapUrl( "ldap://apache.org" );
+        refs.addLdapUrl( "ldap://another.net" );
+        resp1.getLdapResult().setReferral( refs );
 
         assertTrue( resp0.equals( resp1 ) );
-        assertFalse( resp1.equals( resp0 ) );
+        assertTrue( resp1.equals( resp0 ) );
     }
 
 
@@ -223,7 +131,7 @@ public class ExtendedResponseImplTest
     @Test
     public void testHashCodeSameObj()
     {
-        ExtendedResponseImpl resp = createStub();
+        ExtendedResponse resp = createStub();
         assertTrue( resp.hashCode() == resp.hashCode() );
     }
 
@@ -234,8 +142,8 @@ public class ExtendedResponseImplTest
     @Test
     public void testHashCodeExactCopy()
     {
-        ExtendedResponseImpl resp0 = createStub();
-        ExtendedResponseImpl resp1 = createStub();
+        ExtendedResponse resp0 = createStub();
+        ExtendedResponse resp1 = createStub();
         assertTrue( resp0.hashCode() == resp1.hashCode() );
     }
 
@@ -246,8 +154,8 @@ public class ExtendedResponseImplTest
     @Test
     public void testNotEqualsDiffIds()
     {
-        ExtendedResponseImpl resp0 = new ExtendedResponseImpl( 3 );
-        ExtendedResponseImpl resp1 = new ExtendedResponseImpl( 4 );
+        ExtendedResponse resp0 = new OpaqueExtendedResponse( 3 );
+        ExtendedResponse resp1 = new OpaqueExtendedResponse( 4 );
 
         assertFalse( resp0.equals( resp1 ) );
         assertFalse( resp1.equals( resp0 ) );
@@ -260,9 +168,9 @@ public class ExtendedResponseImplTest
     @Test
     public void testNotEqualsDiffNames()
     {
-        ExtendedResponseImpl resp0 = createStub();
+        ExtendedResponse resp0 = createStub();
         resp0.setResponseName( "1.2.3.4" );
-        ExtendedResponseImpl resp1 = createStub();
+        ExtendedResponse resp1 = createStub();
         resp1.setResponseName( "1.2.3.4.5" );
 
         assertFalse( resp0.equals( resp1 ) );


Mime
View raw message