directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lucasthei...@apache.org
Subject svn commit: r1562313 - in /directory/shared/trunk: asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java
Date Tue, 28 Jan 2014 23:45:13 GMT
Author: lucastheisen
Date: Tue Jan 28 23:45:12 2014
New Revision: 1562313

URL: http://svn.apache.org/r1562313
Log:
DIRSERVER-1950: Unsafe cast to int in getPwdTimeBeforeExpiry calculation of AuthenticationInterceptor

Modified:
    directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java
    directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java

Modified: directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java?rev=1562313&r1=1562312&r2=1562313&view=diff
==============================================================================
--- directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java
(original)
+++ directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java
Tue Jan 28 23:45:12 2014
@@ -222,6 +222,7 @@ public class TLV
      * 
      * @param length The length to store in a byte array
      * @return The number of bytes necessary to store the length.
+     * @see <a href="http://en.wikipedia.org/wiki/X.690#Length_Octets">X.690</a>
      */
     public static int getNbBytes( int length )
     {

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=1562313&r1=1562312&r2=1562313&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 Jan 28 23:45:12 2014
@@ -27,6 +27,7 @@ import org.apache.directory.api.asn1.Dec
 import org.apache.directory.api.asn1.EncoderException;
 import org.apache.directory.api.asn1.ber.Asn1Decoder;
 import org.apache.directory.api.asn1.ber.tlv.BerValue;
+import org.apache.directory.api.asn1.ber.tlv.TLV;
 import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.codec.api.ControlDecorator;
@@ -49,8 +50,8 @@ public class PasswordPolicyDecorator ext
     // Storage for computed lengths
     private int ppolicySeqLength = 0;
     private int warningLength = 0;
-    private int timeBeforeExpirationTagLength;
-    private int graceAuthNsRemainingTagLength;
+    private int timeBeforeExpirationValueLength;
+    private int graceAuthNsRemainingValueLength;
 
 
     public PasswordPolicyDecorator( LdapApiService codec )
@@ -98,8 +99,8 @@ public class PasswordPolicyDecorator ext
         valueLength = 0;
         ppolicySeqLength = 0;
         warningLength = 0;
-        timeBeforeExpirationTagLength = 0;
-        graceAuthNsRemainingTagLength = 0;
+        timeBeforeExpirationValueLength = 0;
+        graceAuthNsRemainingValueLength = 0;
 
         if ( !hasResponse() )
         {
@@ -108,18 +109,18 @@ public class PasswordPolicyDecorator ext
 
         if ( getResponse().getTimeBeforeExpiration() >= 0 )
         {
-            timeBeforeExpirationTagLength = BerValue.getNbBytes( getResponse().getTimeBeforeExpiration()
);
-            warningLength = 1 + BerValue.getNbBytes( timeBeforeExpirationTagLength ) + timeBeforeExpirationTagLength;
+            timeBeforeExpirationValueLength = BerValue.getNbBytes( getResponse().getTimeBeforeExpiration()
);
+            warningLength = 1 + TLV.getNbBytes( timeBeforeExpirationValueLength ) + timeBeforeExpirationValueLength;
         }
         else if ( getResponse().getGraceAuthNRemaining() >= 0 )
         {
-            graceAuthNsRemainingTagLength = BerValue.getNbBytes( getResponse().getGraceAuthNRemaining()
);
-            warningLength = 1 + BerValue.getNbBytes( graceAuthNsRemainingTagLength ) + graceAuthNsRemainingTagLength;
+            graceAuthNsRemainingValueLength = BerValue.getNbBytes( getResponse().getGraceAuthNRemaining()
);
+            warningLength = 1 + TLV.getNbBytes( graceAuthNsRemainingValueLength ) + graceAuthNsRemainingValueLength;
         }
 
         if ( warningLength != 0 )
         {
-            ppolicySeqLength = 1 + BerValue.getNbBytes( warningLength ) + warningLength;
+            ppolicySeqLength = 1 + TLV.getNbBytes( warningLength ) + warningLength;
         }
 
         if ( getResponse().getPasswordPolicyError() != null )
@@ -129,7 +130,7 @@ public class PasswordPolicyDecorator ext
 
         if ( ppolicySeqLength > 0 )
         {
-            valueLength = 1 + BerValue.getNbBytes( ppolicySeqLength ) + ppolicySeqLength;
+            valueLength = 1 + TLV.getNbBytes( ppolicySeqLength ) + ppolicySeqLength;
         }
 
         return valueLength;
@@ -158,24 +159,24 @@ public class PasswordPolicyDecorator ext
         {
             // Encode the Sequence tag
             buffer.put( UniversalTag.SEQUENCE.getValue() );
-            buffer.put( BerValue.getBytes( ppolicySeqLength ) );
+            buffer.put( TLV.getBytes( ppolicySeqLength ) );
 
             if ( warningLength > 0 )
             {
                 // Encode the Warning tag
                 buffer.put( ( byte ) PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue() );
-                buffer.put( BerValue.getBytes( warningLength ) );
+                buffer.put( TLV.getBytes( warningLength ) );
 
                 if ( getResponse().getTimeBeforeExpiration() >= 0 )
                 {
                     buffer.put( ( byte ) PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue()
);
-                    buffer.put( BerValue.getBytes( timeBeforeExpirationTagLength ) );
+                    buffer.put( TLV.getBytes( timeBeforeExpirationValueLength ) );
                     buffer.put( BerValue.getBytes( getResponse().getTimeBeforeExpiration()
) );
                 }
                 else if ( getResponse().getGraceAuthNRemaining() >= 0 )
                 {
                     buffer.put( ( byte ) PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue()
);
-                    buffer.put( BerValue.getBytes( graceAuthNsRemainingTagLength ) );
+                    buffer.put( TLV.getBytes( graceAuthNsRemainingValueLength ) );
                     buffer.put( BerValue.getBytes( getResponse().getGraceAuthNRemaining()
) );
                 }
             }



Mime
View raw message