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/10/25 21:54:25 UTC
svn commit: r1634249 - in /directory/apacheds/trunk:
interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
Author: lucastheisen
Date: Sat Oct 25 19:54:25 2014
New Revision: 1634249
URL: http://svn.apache.org/r1634249
Log:
DIRSERVER-1978: Unable to import ldif when operational attribute pwdChangedTime is present
Modified:
directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.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=1634249&r1=1634248&r2=1634249&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 Sat Oct 25 19:54:25 2014
@@ -381,9 +381,14 @@ public class AuthenticationInterceptor e
if ( ( policyConfig.getPwdMinAge() > 0 ) || ( policyConfig.getPwdMaxAge() > 0 ) )
{
- Attribute pwdChangedTimeAt = new DefaultAttribute( AT_PWD_CHANGED_TIME );
- pwdChangedTimeAt.add( pwdChangedTime );
- entry.add( pwdChangedTimeAt );
+ // https://issues.apache.org/jira/browse/DIRSERVER-1978
+ if ( !addContext.getSession().isAnAdministrator()
+ || entry.get( AT_PWD_CHANGED_TIME ) == null )
+ {
+ Attribute pwdChangedTimeAt = new DefaultAttribute( AT_PWD_CHANGED_TIME );
+ pwdChangedTimeAt.add( pwdChangedTime );
+ entry.add( pwdChangedTimeAt );
+ }
}
if ( policyConfig.isPwdMustChange() && addContext.getSession().isAnAdministrator() )
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java?rev=1634249&r1=1634248&r2=1634249&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java Sat Oct 25 19:54:25 2014
@@ -332,6 +332,45 @@ public class PasswordPolicyIT extends Ab
adminConnection.close();
}
+
+ /**
+ * Test that we can add a user with a pwdChangedTime as would be the case
+ * when importing from an ldif that already contained ppolicy information.
+ *
+ * Tests the resolution to
+ * <a href="https://issues.apache.org/jira/browse/DIRSERVER-1978">DIRSERVER-1978</a>
+ */
+ @Test
+ public void testAddUserWithPwdChangedTime() throws Exception
+ {
+ LdapConnection adminConnection = getAdminNetworkConnection( getLdapServer() );
+
+ String userDn = "cn=hashedpwd,ou=system";
+ String pwdChangedTime = "20130913012307.296Z";
+ Entry userEntry = new DefaultEntry(
+ "cn=hashedpwd,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: person",
+ "cn: hashedpwd",
+ "sn: hashedpwd_sn",
+ "userPassword: set4now",
+ PasswordPolicySchemaConstants.PWD_CHANGED_TIME_AT, pwdChangedTime );
+
+ AddRequest addRequest = new AddRequestImpl();
+ addRequest.setEntry( userEntry );
+ addRequest.addControl( PP_REQ_CTRL );
+
+ AddResponse addResp = adminConnection.add( addRequest );
+ assertEquals( ResultCodeEnum.SUCCESS, addResp.getLdapResult().getResultCode() );
+
+ userEntry = adminConnection.lookup( userDn, SchemaConstants.ALL_ATTRIBUTES_ARRAY );
+ Attribute pwdChangedTimeAt = userEntry.get( PasswordPolicySchemaConstants.PWD_CHANGED_TIME_AT );
+ assertNotNull( pwdChangedTimeAt );
+ assertEquals( pwdChangedTime, pwdChangedTimeAt.getString() );
+
+ adminConnection.close();
+ }
+
@Test
public void testModifyUserWithHashedPwd() throws Exception