You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2014/03/16 10:13:20 UTC

svn commit: r1578006 - /directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java

Author: elecharny
Date: Sun Mar 16 09:13:20 2014
New Revision: 1578006

URL: http://svn.apache.org/r1578006
Log:
Used the BetValue.encode method instead of doing it by hand.

Modified:
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.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=1578006&r1=1578005&r2=1578006&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 Sun Mar 16 09:13:20 2014
@@ -165,23 +165,26 @@ public class PasswordPolicyDecorator ext
 
                 if ( getResponse().getTimeBeforeExpiration() >= 0 )
                 {
-                    buffer.put( ( byte ) PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue() );
-                    buffer.put( TLV.getBytes( timeBeforeExpirationValueLength ) );
-                    buffer.put( BerValue.getBytes( getResponse().getTimeBeforeExpiration() ) );
+                    BerValue.encode(
+                        buffer,
+                        ( byte ) PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue(),
+                        getResponse().getTimeBeforeExpiration() );
                 }
                 else if ( getResponse().getGraceAuthNRemaining() >= 0 )
                 {
-                    buffer.put( ( byte ) PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue() );
-                    buffer.put( TLV.getBytes( graceAuthNsRemainingValueLength ) );
-                    buffer.put( BerValue.getBytes( getResponse().getGraceAuthNRemaining() ) );
+                    BerValue.encode(
+                        buffer,
+                        ( byte ) PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue(),
+                        getResponse().getGraceAuthNRemaining() );
                 }
             }
 
             if ( getResponse().getPasswordPolicyError() != null )
             {
-                buffer.put( ( byte ) PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue() );
-                buffer.put( ( byte ) 0x01 );
-                buffer.put( BerValue.getBytes( getResponse().getPasswordPolicyError().getValue() ) );
+                BerValue.encode(
+                    buffer,
+                    ( byte ) PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue(),
+                    getResponse().getPasswordPolicyError().getValue() );
             }
         }
 
@@ -236,7 +239,7 @@ public class PasswordPolicyDecorator ext
 
 
     /**
-     * 
+     *
      * {@inheritDoc}
      */
     public boolean hasResponse()
@@ -246,7 +249,7 @@ public class PasswordPolicyDecorator ext
 
 
     /**
-     * 
+     *
      * {@inheritDoc}
      */
     public void setResponse( PasswordPolicyResponse response )
@@ -256,7 +259,7 @@ public class PasswordPolicyDecorator ext
 
 
     /**
-     * 
+     *
      * {@inheritDoc}
      */
     public PasswordPolicyResponse setResponse( boolean hasResponse )
@@ -266,7 +269,7 @@ public class PasswordPolicyDecorator ext
 
 
     /**
-     * 
+     *
      * {@inheritDoc}
      */
     public PasswordPolicyResponse getResponse()