directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1178922 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
Date Tue, 04 Oct 2011 19:29:19 GMT
Author: kayyagari
Date: Tue Oct  4 19:29:18 2011
New Revision: 1178922

URL: http://svn.apache.org/viewvc?rev=1178922&view=rev
Log:
o fixed the issue with modify operation(DIRSERVER-1665) (the getOriginalEntry() is returning
null value on modify 
operation context)
o fixed another NPE arising while checking the pasword's age

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

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java?rev=1178922&r1=1178921&r2=1178922&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
Tue Oct  4 19:29:18 2011
@@ -511,19 +511,16 @@ public class AuthenticationInterceptor e
         }
 
         // handle the case where pwdPolicySubentry AT is about to be deleted in thid modify()
-        PasswordPolicyConfiguration policyConfig = getPwdPolicy( modifyContext.getOriginalEntry()
);
+        PasswordPolicyConfiguration policyConfig = getPwdPolicy( modifyContext.getEntry()
);
         
         boolean isPPolicyReqCtrlPresent = modifyContext.hasRequestControl( PasswordPolicy.OID
);
         Dn userDn = modifyContext.getSession().getAuthenticatedPrincipal().getDn();
 
         PwdModDetailsHolder pwdModDetails = null;
         
-        if ( policyConfig.isPwdSafeModify() || pwdResetSet.contains( userDn ) || ( policyConfig.getPwdMinAge()
> 0 ) )
-        {
-            pwdModDetails = getPwdModDetails( modifyContext, policyConfig );
-        }
+        pwdModDetails = getPwdModDetails( modifyContext, policyConfig );
 
-        if ( ( pwdModDetails != null ) && pwdModDetails.isPwdModPresent() )
+        if ( pwdModDetails.isPwdModPresent() )
         {
             if ( pwdResetSet.contains( userDn ) )
             {
@@ -622,6 +619,11 @@ public class AuthenticationInterceptor e
             if ( histSize > 0 )
             {
                 Attribute pwdHistoryAt = entry.get( PWD_HISTORY_AT );
+                if ( pwdHistoryAt == null )
+                {
+                	pwdHistoryAt = new DefaultAttribute( AT_PWD_HISTORY );
+                }
+                
                 Set<PasswordHistory> pwdHistSet = new TreeSet<PasswordHistory>();
 
                 for ( Value<?> value : pwdHistoryAt  )
@@ -650,13 +652,12 @@ public class AuthenticationInterceptor e
                 PasswordHistory newPwdHist = new PasswordHistory( pwdChangedTime, newPassword
);
                 pwdHistSet.add( newPwdHist );
 
-                pwdHistoryAt = new DefaultAttribute( pwdHistoryAt.getAttributeType() );
+                pwdHistoryAt.clear();
                 pwdHistoryAt.add( newPwdHist.getHistoryValue() );
                 pwdAddHistMod = new DefaultModification( ADD_ATTRIBUTE, pwdHistoryAt );
 
                 if ( pwdHistSet.size() > histSize )
                 {
-                    pwdHistoryAt = new DefaultAttribute( pwdHistoryAt.getAttributeType()
);
                     PasswordHistory remPwdHist = ( PasswordHistory ) pwdHistSet.toArray()[histSize
- 1];
                     pwdHistoryAt.add( remPwdHist.getHistoryValue() );
                     pwdRemHistMod = new DefaultModification( REMOVE_ATTRIBUTE, pwdHistoryAt
);
@@ -1285,12 +1286,15 @@ public class AuthenticationInterceptor e
         }
 
         Attribute pwdChangedTimeAt = userEntry.get( PWD_CHANGED_TIME_AT );
-        long changedTime = DateUtils.getDate( pwdChangedTimeAt.getString() ).getTime();
-        changedTime += policyConfig.getPwdMinAge() * 1000;
-
-        if ( changedTime > System.currentTimeMillis() )
+        if ( pwdChangedTimeAt != null )
         {
-            return true;
+        	long changedTime = DateUtils.getDate( pwdChangedTimeAt.getString() ).getTime();
+        	changedTime += policyConfig.getPwdMinAge() * 1000;
+        	
+        	if ( changedTime > System.currentTimeMillis() )
+        	{
+        		return true;
+        	}
         }
 
         return false;



Mime
View raw message