directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1763220 - in /directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify: PasswordModifyFactory.java PasswordModifyResponseDecorator.java
Date Mon, 03 Oct 2016 22:14:35 GMT
Author: elecharny
Date: Mon Oct  3 22:14:35 2016
New Revision: 1763220

URL: http://svn.apache.org/viewvc?rev=1763220&view=rev
Log:
Fixed a wrong PwModify response when we don't have any value

Modified:
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyResponseDecorator.java

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.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/PasswordModifyFactory.java?rev=1763220&r1=1763219&r2=1763220&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
Mon Oct  3 22:14:35 2016
@@ -131,35 +131,48 @@ public class PasswordModifyFactory imple
         Asn1Decoder decoder = new Asn1Decoder();
 
         byte[] value = response.getResponseValue();
-        ByteBuffer buffer = ByteBuffer.wrap( value );
-
         PasswordModifyResponseContainer container = new PasswordModifyResponseContainer();
+        
         PasswordModifyResponse pwdModifyResponse = null;
-
-        try
+        
+        if ( value != null )
         {
-            decoder.decode( buffer, container );
-
-            pwdModifyResponse = container.getPwdModifyResponse();
-
+            ByteBuffer buffer = ByteBuffer.wrap( value );
+    
+            try
+            {
+                decoder.decode( buffer, container );
+                pwdModifyResponse = container.getPwdModifyResponse();
+
+                // Now, update the created response with what we got from the extendedResponse
+                pwdModifyResponse.getLdapResult().setResultCode( response.getLdapResult().getResultCode()
);
+                pwdModifyResponse.getLdapResult().setDiagnosticMessage( response.getLdapResult().getDiagnosticMessage()
);
+                pwdModifyResponse.getLdapResult().setMatchedDn( response.getLdapResult().getMatchedDn()
);
+                pwdModifyResponse.getLdapResult().setReferral( response.getLdapResult().getReferral()
);
+            }
+            catch ( DecoderException de )
+            {
+                StringWriter sw = new StringWriter();
+                de.printStackTrace( new PrintWriter( sw ) );
+                String stackTrace = sw.toString();
+    
+                // Error while decoding the value. 
+                pwdModifyResponse = new PasswordModifyResponseImpl(
+                    decoratedResponse.getMessageId(),
+                    ResultCodeEnum.OPERATIONS_ERROR,
+                    stackTrace );
+            }
+        }
+        else
+        {
+            pwdModifyResponse = new PasswordModifyResponseImpl();
+    
             // Now, update the created response with what we got from the extendedResponse
             pwdModifyResponse.getLdapResult().setResultCode( response.getLdapResult().getResultCode()
);
             pwdModifyResponse.getLdapResult().setDiagnosticMessage( response.getLdapResult().getDiagnosticMessage()
);
             pwdModifyResponse.getLdapResult().setMatchedDn( response.getLdapResult().getMatchedDn()
);
             pwdModifyResponse.getLdapResult().setReferral( response.getLdapResult().getReferral()
);
         }
-        catch ( DecoderException de )
-        {
-            StringWriter sw = new StringWriter();
-            de.printStackTrace( new PrintWriter( sw ) );
-            String stackTrace = sw.toString();
-
-            // Error while decoding the value. 
-            pwdModifyResponse = new PasswordModifyResponseImpl(
-                decoratedResponse.getMessageId(),
-                ResultCodeEnum.OPERATIONS_ERROR,
-                stackTrace );
-        }
 
         PasswordModifyResponseDecorator decorated = new PasswordModifyResponseDecorator(
codec, pwdModifyResponse );
 

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=1763220&r1=1763219&r2=1763220&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
Mon Oct  3 22:14:35 2016
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- * A Decorator for PasswordModifyResponse extended request.
+ * A Decorator for PasswordModifyResponse extended response.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -47,8 +47,8 @@ public class PasswordModifyResponseDecor
 
     private PasswordModifyResponse passwordModifyResponse;
 
-    /** stores the length of the request*/
-    private int requestLength = 0;
+    /** stores the length of the response*/
+    private int responseLength = 0;
 
 
     /**
@@ -156,15 +156,15 @@ public class PasswordModifyResponseDecor
      */
     /* no qualifier */int computeLengthInternal()
     {
-        requestLength = 0;
+        responseLength = 0;
 
         if ( passwordModifyResponse.getGenPassword() != null )
         {
             int len = passwordModifyResponse.getGenPassword().length;
-            requestLength = 1 + TLV.getNbBytes( len ) + len;
+            responseLength = 1 + TLV.getNbBytes( len ) + len;
         }
 
-        return 1 + TLV.getNbBytes( requestLength ) + requestLength;
+        return 1 + TLV.getNbBytes( responseLength ) + responseLength;
     }
 
 
@@ -180,7 +180,7 @@ public class PasswordModifyResponseDecor
         ByteBuffer bb = ByteBuffer.allocate( computeLengthInternal() );
 
         bb.put( UniversalTag.SEQUENCE.getValue() );
-        bb.put( TLV.getBytes( requestLength ) );
+        bb.put( TLV.getBytes( responseLength ) );
 
         if ( passwordModifyResponse.getGenPassword() != null )
         {



Mime
View raw message