You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by lu...@apache.org on 2014/01/24 23:03:11 UTC

svn commit: r1561208 - /directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java

Author: lucastheisen
Date: Fri Jan 24 22:03:10 2014
New Revision: 1561208

URL: http://svn.apache.org/r1561208
Log:
DIRSERVER-1948: NPE in AuthenticationInterceptor when password policy is in place and user does not have a pwdChangedTime

Modified:
    directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java

Modified: directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java?rev=1561208&r1=1561207&r2=1561208&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java Fri Jan 24 22:03:10 2014
@@ -142,6 +142,8 @@ public class AuthenticationInterceptor e
     private AttributeType AT_PWD_LAST_SUCCESS;
 
     private AttributeType AT_PWD_GRACE_USE_TIME;
+    
+    private AttributeType AT_CREATE_TIMESTAMP;
 
     /** a container to hold all the ppolicies */
     private PpolicyConfigContainer pwdPolicyContainer;
@@ -1325,6 +1327,16 @@ public class AuthenticationInterceptor e
     }
 
 
+    private AttributeType getCreateTimestampAttributeType() throws LdapException 
+    {
+        if ( AT_CREATE_TIMESTAMP == null ) 
+        {
+            AT_CREATE_TIMESTAMP = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CREATE_TIMESTAMP_AT );
+        }
+        return AT_CREATE_TIMESTAMP;
+    }
+
+
     private int getPwdTimeBeforeExpiry( Entry userEntry, PasswordPolicyConfiguration policyConfig )
         throws LdapException
     {
@@ -1341,6 +1353,10 @@ public class AuthenticationInterceptor e
         }
 
         Attribute pwdChangedTimeAt = userEntry.get( AT_PWD_CHANGED_TIME );
+        if ( pwdChangedTimeAt == null ) 
+        {
+            pwdChangedTimeAt = userEntry.get( getCreateTimestampAttributeType() );
+        }
         long changedTime = DateUtils.getDate( pwdChangedTimeAt.getString() ).getTime();
 
         long currentTime = DateUtils.getDate( DateUtils.getGeneralizedTime() ).getTime();