directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1564279 - in /directory/shared/trunk/ldap/extras/codec/src: main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/ test/java/org/apache/directory/api/ldap/extras/controls/ppolicy/
Date Tue, 04 Feb 2014 13:02:47 GMT
Author: kayyagari
Date: Tue Feb  4 13:02:47 2014
New Revision: 1564279

URL: http://svn.apache.org/r1564279
Log:
send empty sequence when no error or warning is present (DIRSERVER-1955)

Modified:
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
    directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyTest.java

Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java?rev=1564279&r1=1564278&r2=1564279&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
Tue Feb  4 13:02:47 2014
@@ -78,12 +78,11 @@ public class PasswordPolicyDecorator ext
     @Override
     public void setValue( byte[] value )
     {
-        if ( value == null || value.length == 0 )
+        if ( value == null || value.length <= 2 )
         {
             setResponse( null );
         }
-
-        if ( value != null && !hasResponse() )
+        else if ( value != null && !hasResponse() )
         {
             setResponse( true );
         }
@@ -128,10 +127,7 @@ public class PasswordPolicyDecorator ext
             ppolicySeqLength += 1 + 1 + 1;
         }
 
-        if ( ppolicySeqLength > 0 )
-        {
-            valueLength = 1 + TLV.getNbBytes( ppolicySeqLength ) + ppolicySeqLength;
-        }
+        valueLength = 1 + TLV.getNbBytes( ppolicySeqLength ) + ppolicySeqLength;
 
         return valueLength;
     }
@@ -150,6 +146,10 @@ public class PasswordPolicyDecorator ext
             throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
         }
 
+        // Encode the Sequence tag
+        buffer.put( UniversalTag.SEQUENCE.getValue() );
+        buffer.put( TLV.getBytes( ppolicySeqLength ) );
+
         if ( ( getResponse().getTimeBeforeExpiration() < 0 ) && ( getResponse().getGraceAuthNRemaining()
< 0 ) && (
             getResponse().getPasswordPolicyError() == null ) )
         {
@@ -157,10 +157,6 @@ public class PasswordPolicyDecorator ext
         }
         else
         {
-            // Encode the Sequence tag
-            buffer.put( UniversalTag.SEQUENCE.getValue() );
-            buffer.put( TLV.getBytes( ppolicySeqLength ) );
-
             if ( warningLength > 0 )
             {
                 // Encode the Warning tag

Modified: directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyTest.java?rev=1564279&r1=1564278&r2=1564279&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyTest.java
(original)
+++ directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ppolicy/PasswordPolicyTest.java
Tue Feb  4 13:02:47 2014
@@ -201,6 +201,6 @@ public class PasswordPolicyTest extends 
 
         ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
             ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength()
) );
-        assertEquals( "", Strings.dumpBytes( encoded.array() ) );
+        assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array()
) );
     }
 }



Mime
View raw message