directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1470331 - in /directory/shared/trunk/ldap: client/api/ client/api/src/main/java/org/apache/directory/ldap/client/api/ codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/ codec/core/src/main/java/org/apach...
Date Sun, 21 Apr 2013 18:51:32 GMT
Author: elecharny
Date: Sun Apr 21 18:51:31 2013
New Revision: 1470331

URL: http://svn.apache.org/r1470331
Log:
o Initialized the 
o Added a reference to ldap-codec-standalone nto the ldap-client-api pom
o Changed the way we handle the extended request in the client api
o Get back the extendedResponse from the standalone codec service
o Some fixes for the passwordModify extended request

Modified:
    directory/shared/trunk/ldap/client/api/pom.xml
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
    directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java
    directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecoder.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java
    directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/PasswordModifyResponseTest.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java

Modified: directory/shared/trunk/ldap/client/api/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/pom.xml?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/pom.xml (original)
+++ directory/shared/trunk/ldap/client/api/pom.xml Sun Apr 21 18:51:31 2013
@@ -59,6 +59,11 @@
     </dependency>
 
     <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>api-ldap-codec-standalone</artifactId>
+    </dependency>
+
+    <dependency>
       <groupId>commons-pool</groupId>
       <artifactId>commons-pool</artifactId>
       <version>${commons.pool.version}</version>

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Sun Apr 21 18:51:31 2013
@@ -52,6 +52,7 @@ import org.apache.directory.api.asn1.Dec
 import org.apache.directory.api.asn1.util.Oid;
 import org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector;
 import org.apache.directory.api.ldap.codec.api.DefaultConfigurableBinaryAttributeDetector;
+import org.apache.directory.api.ldap.codec.api.ExtendedResponseDecorator;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
 import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
 import org.apache.directory.api.ldap.codec.api.LdapDecoder;
@@ -59,6 +60,7 @@ import org.apache.directory.api.ldap.cod
 import org.apache.directory.api.ldap.codec.api.MessageDecorator;
 import org.apache.directory.api.ldap.codec.api.MessageEncoderException;
 import org.apache.directory.api.ldap.codec.api.SchemaBinaryAttributeDetector;
+import org.apache.directory.api.ldap.codec.standalone.StandaloneLdapApiService;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.cursor.Cursor;
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
@@ -105,6 +107,7 @@ import org.apache.directory.api.ldap.mod
 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;
+import org.apache.directory.api.ldap.model.message.ResultResponse;
 import org.apache.directory.api.ldap.model.message.SearchRequest;
 import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
 import org.apache.directory.api.ldap.model.message.SearchResultDone;
@@ -196,6 +199,9 @@ public class LdapNetworkConnection exten
      */
     private IoSession ldapSession;
 
+    /** The LDAP Api Service instance */
+    LdapApiService ldapApiService;
+
     /** a map to hold the ResponseFutures for all operations */
     private Map<Integer, ResponseFuture<? extends Response>> futureMap = new
ConcurrentHashMap<Integer, ResponseFuture<? extends Response>>();
 
@@ -336,12 +342,7 @@ public class LdapNetworkConnection exten
      */
     public LdapNetworkConnection()
     {
-        super();
-        config = new LdapConnectionConfig();
-        config.setUseSsl( false );
-        config.setLdapPort( config.getDefaultLdapPort() );
-        config.setLdapHost( config.getDefaultLdapHost() );
-        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
+        this( null, -1, false );
     }
 
 
@@ -360,6 +361,16 @@ public class LdapNetworkConnection exten
         {
             config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector()
);
         }
+
+        // Load the LdapApiService now
+        try
+        {
+            ldapApiService = new StandaloneLdapApiService();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
     }
 
 
@@ -371,12 +382,7 @@ public class LdapNetworkConnection exten
      */
     public LdapNetworkConnection( boolean useSsl )
     {
-        super();
-        config = new LdapConnectionConfig();
-        config.setUseSsl( useSsl );
-        config.setLdapPort( useSsl ? config.getDefaultLdapsPort() : config.getDefaultLdapPort()
);
-        config.setLdapHost( config.getDefaultLdapHost() );
-        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
+        this( null, -1, useSsl );
     }
 
 
@@ -389,22 +395,7 @@ public class LdapNetworkConnection exten
      */
     public LdapNetworkConnection( String server )
     {
-        super();
-        config = new LdapConnectionConfig();
-        config.setUseSsl( false );
-        config.setLdapPort( config.getDefaultLdapPort() );
-
-        // Default to localhost if null
-        if ( Strings.isEmpty( server ) )
-        {
-            config.setLdapHost( "localhost" );
-        }
-        else
-        {
-            config.setLdapHost( server );
-        }
-
-        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
+        this( server, -1, false );
     }
 
 
@@ -419,22 +410,7 @@ public class LdapNetworkConnection exten
      */
     public LdapNetworkConnection( String server, boolean useSsl )
     {
-        super();
-        config = new LdapConnectionConfig();
-        config.setUseSsl( useSsl );
-        config.setLdapPort( useSsl ? config.getDefaultLdapsPort() : config.getDefaultLdapPort()
);
-
-        // Default to localhost if null
-        if ( Strings.isEmpty( server ) )
-        {
-            config.setLdapHost( "localhost" );
-        }
-        else
-        {
-            config.setLdapHost( server );
-        }
-
-        config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
+        this( server, -1, useSsl );
     }
 
 
@@ -466,7 +442,22 @@ public class LdapNetworkConnection exten
         super();
         config = new LdapConnectionConfig();
         config.setUseSsl( useSsl );
-        config.setLdapPort( port );
+
+        if ( port != -1 )
+        {
+            config.setLdapPort( port );
+        }
+        else
+        {
+            if ( useSsl )
+            {
+                config.setLdapPort( config.getDefaultLdapsPort() );
+            }
+            else
+            {
+                config.setLdapPort( config.getDefaultLdapPort() );
+            }
+        }
 
         // Default to localhost if null
         if ( Strings.isEmpty( server ) )
@@ -479,6 +470,16 @@ public class LdapNetworkConnection exten
         }
 
         config.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
+
+        // Load the LdapApiService now
+        try
+        {
+            ldapApiService = new StandaloneLdapApiService();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
     }
 
 
@@ -3085,28 +3086,36 @@ public class LdapNetworkConnection exten
         {
             // Read the response, waiting for it if not available immediately
             // Get the response, blocking
-            ExtendedResponse extendedResponse = ( ExtendedResponse ) extendedFuture
+            ExtendedResponse response = ( ExtendedResponse ) extendedFuture
                 .get( timeout, TimeUnit.MILLISECONDS );
 
-            if ( extendedResponse == null )
+            if ( response == null )
             {
                 // We didn't received anything : this is an error
                 LOG.error( "Extended failed : timeout occurred" );
                 throw new LdapException( TIME_OUT_ERROR );
             }
 
-            if ( extendedResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS
)
+            if ( response.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
             {
                 // Everything is fine, return the response
-                LOG.debug( "Extended successful : {}", extendedResponse );
+                LOG.debug( "Extended successful : {}", response );
             }
             else
             {
                 // We have had an error
-                LOG.debug( "Extended failed : {}", extendedResponse );
+                LOG.debug( "Extended failed : {}", response );
             }
 
-            return extendedResponse;
+            // Get back the response. It's still an opaque response
+            ResultResponse resultResponse = extendedRequest.getResultResponse();
+
+            // Decode the payload now
+            resultResponse.getMessageId();
+
+            ExtendedResponseDecorator decoratedResponse = ldapApiService.decorate( ( ExtendedResponse
) resultResponse );
+
+            return decoratedResponse;
         }
         catch ( TimeoutException te )
         {

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/extendedResponse/StoreExtendedResponseName.java
Sun Apr 21 18:51:31 2013
@@ -26,6 +26,7 @@ import org.apache.directory.api.asn1.ber
 import org.apache.directory.api.asn1.util.Oid;
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.codec.api.ExtendedResponseDecorator;
+import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
 import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
 import org.apache.directory.api.ldap.model.message.ExtendedResponse;
 import org.apache.directory.api.util.Strings;
@@ -68,7 +69,7 @@ public class StoreExtendedResponseName e
     public void action( LdapMessageContainer<ExtendedResponseDecorator<?>> container
) throws DecoderException
     {
         // We can allocate the ExtendedResponse Object
-        ExtendedResponse extendedResponse = container.getMessage();
+        ExtendedResponse extendedResponse = null;
 
         // Get the Value and store it in the ExtendedResponse
         TLV tlv = container.getCurrentTLV();
@@ -83,8 +84,12 @@ public class StoreExtendedResponseName e
         }
         else
         {
-            extendedResponse.setResponseName( new Oid( Strings.asciiBytesToString( tlv.getValue().getData()
) )
-                .toString() );
+            String responseName = new Oid( Strings.asciiBytesToString( tlv.getValue().getData()
) )
+                .toString();
+
+            extendedResponse = LdapApiServiceFactory.getSingleton().newExtendedResponse(
responseName,
+                container.getMessageId(), null );
+            container.setMessage( LdapApiServiceFactory.getSingleton().decorate( extendedResponse
) );
         }
 
         // We can have an END transition

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
Sun Apr 21 18:51:31 2013
@@ -265,7 +265,18 @@ public interface LdapApiService
     Asn1Container newMessageContainer();
 
 
-    <E extends ExtendedResponse> E newExtendedResponse( ExtendedRequest<E> req,
byte[] serializedResponse )
+    /**
+     * Create an instance of a ExtendedResponse, knowing its OID. Inject the payload
+     * into it.
+     * 
+     * @param responseName The extendedRespose OID
+     * @param messageId The original message ID
+     * @param serializedResponse The serialized response payload
+     * @return The extendedResponse instance
+     * 
+     * @throws DecoderException If the payload is incorrect
+     */
+    <E extends ExtendedResponse> E newExtendedResponse( String responseName, int messageId,
byte[] serializedResponse )
         throws DecoderException;
 
 

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
Sun Apr 21 18:51:31 2013
@@ -20,6 +20,14 @@
 package org.apache.directory.api.ldap.codec.osgi;
 
 
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.naming.NamingException;
+
 import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.EncoderException;
 import org.apache.directory.api.asn1.ber.Asn1Container;
@@ -52,14 +60,6 @@ import org.apache.mina.filter.codec.Prot
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.naming.NamingException;
-
 
 /**
  * The default {@link LdapApiService} implementation.
@@ -485,12 +485,13 @@ public class DefaultLdapCodecService imp
      * @throws DecoderException 
      */
     @SuppressWarnings("unchecked")
-    public <E extends ExtendedResponse> E newExtendedResponse( ExtendedRequest<E>
req, byte[] serializedResponse )
+    public <E extends ExtendedResponse> E newExtendedResponse( String responseName,
int messageId,
+        byte[] serializedResponse )
         throws DecoderException
     {
         ExtendedResponseDecorator<ExtendedResponse> resp;
 
-        ExtendedRequestFactory<?, ?> extendedRequestFactory = extReqFactories.get(
req.getRequestName() );
+        ExtendedRequestFactory<?, ?> extendedRequestFactory = extReqFactories.get(
responseName );
         if ( extendedRequestFactory != null )
         {
             resp = ( ExtendedResponseDecorator<ExtendedResponse> ) extendedRequestFactory
@@ -499,12 +500,12 @@ public class DefaultLdapCodecService imp
         else
         {
             resp = new ExtendedResponseDecorator<ExtendedResponse>( this,
-                new ExtendedResponseImpl( req.getRequestName() ) );
+                new ExtendedResponseImpl( responseName ) );
             resp.setResponseValue( serializedResponse );
-            resp.setResponseName( req.getRequestName() );
+            resp.setResponseName( responseName );
         }
 
-        resp.setMessageId( req.getMessageId() );
+        resp.setMessageId( messageId );
         return ( E ) resp;
     }
 

Modified: directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java
Sun Apr 21 18:51:31 2013
@@ -21,6 +21,7 @@ package org.apache.directory.api.ldap.co
 
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -132,10 +133,10 @@ public class ExtendedResponseTest extend
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
-        assertEquals( "", extendedResponse.getLdapResult().getDiagnosticMessage() );
+        assertNull( extendedResponse.getLdapResult().getMatchedDn() );
+        assertNull( extendedResponse.getLdapResult().getDiagnosticMessage() );
         assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "value", Strings.utf8ToString( ( byte[] ) extendedResponse.getResponseValue()
) );
+        assertEquals( "value", Strings.utf8ToString( extendedResponse.getResponseValue()
) );
 
         // Check the encoding
         try
@@ -267,10 +268,10 @@ public class ExtendedResponseTest extend
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
-        assertEquals( "", extendedResponse.getLdapResult().getDiagnosticMessage() );
+        assertNull( extendedResponse.getLdapResult().getMatchedDn() );
+        assertNull( extendedResponse.getLdapResult().getDiagnosticMessage() );
         assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "value", Strings.utf8ToString( ( byte[] ) extendedResponse.getResponseValue()
) );
+        assertEquals( "value", Strings.utf8ToString( extendedResponse.getResponseValue()
) );
 
         // Check the Control
         Map<String, Control> controls = extendedResponse.getControls();
@@ -281,7 +282,7 @@ public class ExtendedResponseTest extend
         CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control>
) controls
             .get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
-        assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
+        assertEquals( "", Strings.dumpBytes( control.getValue() ) );
 
         // Check the encoding
         try
@@ -478,7 +479,7 @@ public class ExtendedResponseTest extend
         CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control>
) controls
             .get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
-        assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
+        assertEquals( "", Strings.dumpBytes( control.getValue() ) );
 
         // Check the encoding
         try
@@ -717,10 +718,10 @@ public class ExtendedResponseTest extend
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
-        assertEquals( "", extendedResponse.getLdapResult().getDiagnosticMessage() );
+        assertNull( extendedResponse.getLdapResult().getMatchedDn() );
+        assertNull( extendedResponse.getLdapResult().getDiagnosticMessage() );
         assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "", Strings.utf8ToString( ( byte[] ) extendedResponse.getResponseValue()
) );
+        assertEquals( "", Strings.utf8ToString( extendedResponse.getResponseValue() ) );
 
         // Check the encoding
         try
@@ -843,10 +844,10 @@ public class ExtendedResponseTest extend
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
-        assertEquals( "", extendedResponse.getLdapResult().getDiagnosticMessage() );
+        assertNull( extendedResponse.getLdapResult().getMatchedDn() );
+        assertNull( extendedResponse.getLdapResult().getDiagnosticMessage() );
         assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "", Strings.utf8ToString( ( byte[] ) extendedResponse.getResponseValue()
) );
+        assertEquals( "", Strings.utf8ToString( extendedResponse.getResponseValue() ) );
 
         // Check the Control
         Map<String, Control> controls = extendedResponse.getControls();
@@ -857,7 +858,7 @@ public class ExtendedResponseTest extend
         CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control>
) controls
             .get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
-        assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
+        assertEquals( "", Strings.dumpBytes( control.getValue() ) );
 
         // Check the encoding
         try
@@ -952,10 +953,10 @@ public class ExtendedResponseTest extend
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
-        assertEquals( "", extendedResponse.getLdapResult().getDiagnosticMessage() );
+        assertNull( extendedResponse.getLdapResult().getMatchedDn() );
+        assertNull( extendedResponse.getLdapResult().getDiagnosticMessage() );
         assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "", Strings.utf8ToString( ( byte[] ) extendedResponse.getResponseValue()
) );
+        assertEquals( "", Strings.utf8ToString( extendedResponse.getResponseValue() ) );
 
         // Check the encoding
         try
@@ -1081,10 +1082,10 @@ public class ExtendedResponseTest extend
 
         assertEquals( 1, extendedResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", extendedResponse.getLdapResult().getMatchedDn().getName() );
-        assertEquals( "", extendedResponse.getLdapResult().getDiagnosticMessage() );
+        assertNull( extendedResponse.getLdapResult().getMatchedDn() );
+        assertNull( extendedResponse.getLdapResult().getDiagnosticMessage() );
         assertEquals( "1.3.6.1.5.5.2", extendedResponse.getResponseName() );
-        assertEquals( "", Strings.utf8ToString( ( byte[] ) extendedResponse.getResponseValue()
) );
+        assertEquals( "", Strings.utf8ToString( extendedResponse.getResponseValue() ) );
 
         // Check the Control
         Map<String, Control> controls = extendedResponse.getControls();
@@ -1095,7 +1096,7 @@ public class ExtendedResponseTest extend
         CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control>
) controls
             .get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
-        assertEquals( "", Strings.dumpBytes( ( byte[] ) control.getValue() ) );
+        assertEquals( "", Strings.dumpBytes( control.getValue() ) );
 
         // Check the encoding
         try

Modified: directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
(original)
+++ directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
Sun Apr 21 18:51:31 2013
@@ -669,12 +669,13 @@ public class StandaloneLdapApiService im
      * @throws DecoderException 
      */
     @SuppressWarnings("unchecked")
-    public <E extends ExtendedResponse> E newExtendedResponse( ExtendedRequest<E>
req, byte[] serializedResponse )
+    public <E extends ExtendedResponse> E newExtendedResponse( String responseName,
int messageId,
+        byte[] serializedResponse )
         throws DecoderException
     {
         ExtendedResponseDecorator<ExtendedResponse> resp;
 
-        ExtendedRequestFactory<?, ?> extendedRequestFactory = extReqFactories.get(
req.getRequestName() );
+        ExtendedRequestFactory<?, ?> extendedRequestFactory = extReqFactories.get(
responseName );
 
         if ( extendedRequestFactory != null )
         {
@@ -684,12 +685,12 @@ public class StandaloneLdapApiService im
         else
         {
             resp = new ExtendedResponseDecorator<ExtendedResponse>( this,
-                new ExtendedResponseImpl( req.getRequestName() ) );
+                new ExtendedResponseImpl( responseName ) );
             resp.setResponseValue( serializedResponse );
-            resp.setResponseName( req.getRequestName() );
+            resp.setResponseName( responseName );
         }
 
-        resp.setMessageId( req.getMessageId() );
+        resp.setMessageId( messageId );
 
         return ( E ) resp;
     }

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyRequestContainer.java
Sun Apr 21 18:51:31 2013
@@ -61,7 +61,7 @@ public class PasswordModifyRequestContai
      * Set a PasswordModifyRequest Object into the container. It will be completed by
      * the ldapDecoder.
      * 
-     * @param pwdModifyRequest the PasswordModifyRequest to set.
+     * @param passwordModifyRequestDecorator the PasswordModifyRequest to set.
      */
     public void setPasswordModifyRequest( PasswordModifyRequestDecorator passwordModifyRequestDecorator
)
     {

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseContainer.java
Sun Apr 21 18:51:31 2013
@@ -21,6 +21,7 @@ package org.apache.directory.api.ldap.ex
 
 
 import org.apache.directory.api.asn1.ber.AbstractContainer;
+import org.apache.directory.api.ldap.extras.extended.PwdModifyResponse;
 
 
 /**
@@ -31,7 +32,7 @@ import org.apache.directory.api.asn1.ber
 public class PasswordModifyResponseContainer extends AbstractContainer
 {
     /** PasswordModifyResponse decorator*/
-    private PasswordModifyResponseDecorator pwdModifyResponse;
+    private PasswordModifyResponseDecorator passwordModifyResponseDecorator;
 
 
     /**
@@ -50,9 +51,9 @@ public class PasswordModifyResponseConta
     /**
      * @return Returns the PwdModifyResponset instance.
      */
-    public PasswordModifyResponseDecorator getPasswordModifyResponse()
+    public PwdModifyResponse getPwdModifyResponse()
     {
-        return pwdModifyResponse;
+        return passwordModifyResponseDecorator;
     }
 
 
@@ -60,11 +61,11 @@ public class PasswordModifyResponseConta
      * Set a PasswordModifyResponse Object into the container. It will be completed by
      * the ldapDecoder.
      * 
-     * @param pwdModifyResponse the PasswordModifyResponse to set.
+     * @param passwordModifyResponseDecorator the PasswordModifyResponse to set.
      */
-    public void setPasswordModifyResponse( PasswordModifyResponseDecorator pwdModifyResponse
)
+    public void setPasswordModifyResponse( PasswordModifyResponseDecorator passwordModifyResponseDecorator
)
     {
-        this.pwdModifyResponse = pwdModifyResponse;
+        this.passwordModifyResponseDecorator = passwordModifyResponseDecorator;
     }
 
 
@@ -74,6 +75,6 @@ public class PasswordModifyResponseConta
     public void clean()
     {
         super.clean();
-        pwdModifyResponse = null;
+        passwordModifyResponseDecorator = null;
     }
 }

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecoder.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecoder.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecoder.java
Sun Apr 21 18:51:31 2013
@@ -25,6 +25,7 @@ import java.nio.ByteBuffer;
 import org.apache.directory.api.asn1.Asn1Object;
 import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.ber.Asn1Decoder;
+import org.apache.directory.api.ldap.extras.extended.PwdModifyResponse;
 
 
 /**
@@ -50,12 +51,13 @@ public class PasswordModifyResponseDecod
     public Asn1Object decode( byte[] stream ) throws DecoderException
     {
         ByteBuffer bb = ByteBuffer.wrap( stream );
-        PasswordModifyRequestContainer container = new PasswordModifyRequestContainer();
+        PasswordModifyResponseContainer container = new PasswordModifyResponseContainer();
         decoder.decode( bb, container );
+        PwdModifyResponse pwdModifyResponse = container.getPwdModifyResponse();
 
         // Clean the container for the next decoding
         container.clean();
 
-        return ( ( PasswordModifyRequestDecorator ) container.getPwdModifyRequest() ).getPasswordModifyRequest();
+        return ( ( PasswordModifyResponseDecorator ) pwdModifyResponse ).getPasswordModifyResponse();
     }
 }

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java
Sun Apr 21 18:51:31 2013
@@ -26,6 +26,7 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.codec.api.ExtendedResponseDecorator;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
 import org.apache.directory.api.ldap.extras.extended.PwdModifyResponse;
+import org.apache.directory.api.ldap.extras.extended.PwdModifyResponseImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,6 +51,9 @@ public class PasswordModifyResponseDecor
     }
 
 
+    /**
+     * @return The ASN1 object containing the PwdModifyResponse instance
+     */
     public PasswordModifyResponse getPasswordModifyResponse()
     {
         return passwordModifyResponse;
@@ -67,6 +71,8 @@ public class PasswordModifyResponseDecor
         try
         {
             passwordModifyResponse = ( PasswordModifyResponse ) decoder.decode( responseValue
);
+            ( ( PwdModifyResponseImpl ) getDecorated() ).setGenPassword( passwordModifyResponse.getPwdModifyResponse()
+                .getGenPassword() );
 
             if ( responseValue != null )
             {
@@ -124,4 +130,23 @@ public class PasswordModifyResponseDecor
     {
         return getDecorated().getGenPassword();
     }
+
+
+    /**
+     * @param genPassword the genPassword to set
+     */
+    public void setGenPassword( byte[] genPassword )
+    {
+        ( ( PwdModifyResponseImpl ) getDecorated() ).setGenPassword( genPassword );
+    }
+
+
+    /**
+     * Overload the parent's getResponseName method, as the pwdModify response should not
+     * contain the responseName.
+     */
+    public String getResponseName()
+    {
+        return null;
+    }
 }

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseGrammar.java
Sun Apr 21 18:51:31 2013
@@ -127,7 +127,7 @@ public class PasswordModifyResponseGramm
                             genPassword = Strings.EMPTY_BYTES;
                         }
 
-                        ( ( PwdModifyResponseImpl ) container.getPasswordModifyResponse().getDecorated()
)
+                        ( ( PasswordModifyResponseDecorator ) container.getPwdModifyResponse()
)
                             .setGenPassword( genPassword );
 
                         // We may have nothing left

Modified: directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/PasswordModifyResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/PasswordModifyResponseTest.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/PasswordModifyResponseTest.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/PasswordModifyResponseTest.java
Sun Apr 21 18:51:31 2013
@@ -77,7 +77,7 @@ public class PasswordModifyResponseTest
             fail( de.getMessage() );
         }
 
-        PwdModifyResponse pwdModifyResponse = container.getPasswordModifyResponse();
+        PwdModifyResponse pwdModifyResponse = container.getPwdModifyResponse();
         assertNull( pwdModifyResponse.getGenPassword() );
 
         // Check the length
@@ -131,7 +131,7 @@ public class PasswordModifyResponseTest
             fail( de.getMessage() );
         }
 
-        PwdModifyResponse pwdModifyResponse = container.getPasswordModifyResponse();
+        PwdModifyResponse pwdModifyResponse = container.getPwdModifyResponse();
         assertNotNull( pwdModifyResponse.getGenPassword() );
         assertEquals( 0, pwdModifyResponse.getGenPassword().length );
 
@@ -190,7 +190,7 @@ public class PasswordModifyResponseTest
             fail( de.getMessage() );
         }
 
-        PwdModifyResponse pwdModifyResponse = container.getPasswordModifyResponse();
+        PwdModifyResponse pwdModifyResponse = container.getPwdModifyResponse();
         assertNotNull( pwdModifyResponse.getGenPassword() );
         assertEquals( "abcd", Strings.utf8ToString( pwdModifyResponse.getGenPassword() )
);
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java?rev=1470331&r1=1470330&r2=1470331&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ExtendedRequestImpl.java
Sun Apr 21 18:51:31 2013
@@ -137,7 +137,7 @@ public class ExtendedRequestImpl extends
      * 
      * @return the result containing response for this request
      */
-    public ExtendedResponseImpl getResultResponse()
+    public ExtendedResponse getExtendedResponse()
     {
         if ( response == null )
         {
@@ -151,6 +151,15 @@ public class ExtendedRequestImpl extends
     /**
      * {@inheritDoc}
      */
+    public ExtendedResponse getResultResponse()
+    {
+        return getExtendedResponse();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public int hashCode()
     {



Mime
View raw message