directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1065899 [1/2] - in /directory: apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/ apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ apacheds/trunk/core/src/main/java/org/apac...
Date Tue, 01 Feb 2011 02:46:13 GMT
Author: akarasulu
Date: Tue Feb  1 02:46:12 2011
New Revision: 1065899

URL: http://svn.apache.org/viewvc?rev=1065899&view=rev
Log:
Working on password policy control:

  ISSUES:
    o Response and request controls have same OID, and according to new factory
      based creation and handling mechanism for controls in the server this 
      presented a problem with OID based lookups of factories. So we have to 
      have a single interface, Control implementation, and one factory to serve
      both request and response purposes.

  ACTIONS:
    o Consolidated request and response representations into a single Control 
      interface which has a response object contained within. 
    o Conditionally sets this object on decode operations and uses the response
      if present to encode as a response Control with all response parameters
      encoded.
    o Created and enabled factory in the default ILdapCodecService impl
    o Fixed shared tests, some server tests are still failing. We need to fix 
      these tomorrow.


Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicy.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicy.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyContainer.java
      - copied, changed from r1065842, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyFactory.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyGrammar.java
      - copied, changed from r1065842, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponse.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyStates.java
      - copied, changed from r1065842, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseStates.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTags.java
      - copied, changed from r1065842, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseTags.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTest.java
      - copied, changed from r1065842, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java
Removed:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicyRequest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyRequest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyRequestDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyRequestFactory.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseContainer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseStates.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseTags.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java
Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
    directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/PasswordPolicyException.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicyResponse.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreError.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreGraceAuthsRemaining.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java Tue Feb  1 02:46:12 2011
@@ -45,10 +45,9 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.codec.DefaultLdapCodecService;
 import org.apache.directory.shared.ldap.codec.ICodecControl;
 import org.apache.directory.shared.ldap.codec.ILdapCodecService;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.IPasswordPolicyResponse;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyRequest;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyRequestDecorator;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyResponseDecorator;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.IPasswordPolicy;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicy;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyDecorator;
 import org.apache.directory.shared.ldap.model.constants.LdapSecurityConstants;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
@@ -80,8 +79,8 @@ public class PasswordPolicyTest extends 
 
     private static final ILdapCodecService codec = new DefaultLdapCodecService();
     
-    private static final PasswordPolicyRequestDecorator PP_REQ_CTRL = 
-        new PasswordPolicyRequestDecorator( codec, new PasswordPolicyRequest() );
+    private static final PasswordPolicyDecorator PP_REQ_CTRL = 
+        new PasswordPolicyDecorator( codec, new PasswordPolicy() );
 
 
     @Before
@@ -134,9 +133,9 @@ public class PasswordPolicyTest extends 
         AddResponse addResp = connection.add( addRequest );
         assertEquals( ResultCodeEnum.CONSTRAINT_VIOLATION, addResp.getLdapResult().getResultCode() );
 
-        IPasswordPolicyResponse respCtrl = getPwdRespCtrl( addResp );
+        IPasswordPolicy respCtrl = getPwdRespCtrl( addResp );
         assertNotNull( respCtrl );
-        assertEquals( PASSWORD_TOO_SHORT, respCtrl.getPasswordPolicyError() );
+        assertEquals( PASSWORD_TOO_SHORT, respCtrl.getResponse().getPasswordPolicyError() );
 
         EntryAttribute pwdAt = userEntry.get( SchemaConstants.USER_PASSWORD_AT );
         pwdAt.clear();
@@ -174,9 +173,9 @@ public class PasswordPolicyTest extends 
         AddResponse addResp = connection.add( addRequest );
         assertEquals( ResultCodeEnum.CONSTRAINT_VIOLATION, addResp.getLdapResult().getResultCode() );
 
-        IPasswordPolicyResponse respCtrl = getPwdRespCtrl( addResp );
+        IPasswordPolicy respCtrl = getPwdRespCtrl( addResp );
         assertNotNull( respCtrl );
-        assertEquals( INSUFFICIENT_PASSWORD_QUALITY, respCtrl.getPasswordPolicyError() );
+        assertEquals( INSUFFICIENT_PASSWORD_QUALITY, respCtrl.getResponse().getPasswordPolicyError() );
 
         policyConfig.setPwdCheckQuality( 1 ); // allow the password if its quality can't be checked
         EntryAttribute pwdAt = userEntry.get( SchemaConstants.USER_PASSWORD_AT );
@@ -212,7 +211,7 @@ public class PasswordPolicyTest extends 
         AddResponse addResp = connection.add( addRequest );
         assertEquals( ResultCodeEnum.SUCCESS, addResp.getLdapResult().getResultCode() );
 
-        IPasswordPolicyResponse respCtrl = getPwdRespCtrl( addResp );
+        IPasswordPolicy respCtrl = getPwdRespCtrl( addResp );
         assertNull( respCtrl );
 
         ModifyRequest modReq = new ModifyRequestImpl();
@@ -224,7 +223,7 @@ public class PasswordPolicyTest extends 
         assertEquals( ResultCodeEnum.CONSTRAINT_VIOLATION, modResp.getLdapResult().getResultCode() );
 
         respCtrl = getPwdRespCtrl( modResp );
-        assertEquals( PASSWORD_TOO_YOUNG, respCtrl.getPasswordPolicyError() );
+        assertEquals( PASSWORD_TOO_YOUNG, respCtrl.getResponse().getPasswordPolicyError() );
 
         Thread.sleep( 5000 );
 
@@ -237,7 +236,7 @@ public class PasswordPolicyTest extends 
     }
 
 
-    private IPasswordPolicyResponse getPwdRespCtrl( Response resp ) throws Exception
+    private IPasswordPolicy getPwdRespCtrl( Response resp ) throws Exception
     {
         ICodecControl<? extends Control> ctrl = codec.decorate( resp.getControls().get( PP_REQ_CTRL.getOid() ) );
 
@@ -246,7 +245,7 @@ public class PasswordPolicyTest extends 
             return null;
         }
 
-        PasswordPolicyResponseDecorator respCtrl = new PasswordPolicyResponseDecorator( codec );
+        PasswordPolicyDecorator respCtrl = new PasswordPolicyDecorator( codec );
         respCtrl.setValue( ctrl.getValue() );
         return respCtrl;
     }

Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Tue Feb  1 02:46:12 2011
@@ -75,10 +75,12 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.ldap.codec.ICodecControl;
 import org.apache.directory.shared.ldap.codec.controls.CascadeDecorator;
 import org.apache.directory.shared.ldap.codec.controls.ManageDsaITDecorator;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.IPasswordPolicyRequest;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyRequest;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyRequestDecorator;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyResponseDecorator;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.IPasswordPolicy;
+
+// @TODO - all these controls should not be imported !!!! ALEX !!!
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicy;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyDecorator;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyResponse;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.ISyncDoneValue;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueDecorator;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.ISyncInfoValue;
@@ -179,7 +181,7 @@ public abstract class ServerContext impl
         ADS_CONTROLS.put( EntryChange.OID, ControlEnum.ENTRY_CHANGE_CONTROL );
         ADS_CONTROLS.put( ManageDsaIT.OID, ControlEnum.MANAGE_DSA_IT_CONTROL );
         ADS_CONTROLS.put( PagedResults.OID, ControlEnum.PAGED_RESULTS_CONTROL );
-        ADS_CONTROLS.put( IPasswordPolicyRequest.OID, ControlEnum.PASSWORD_POLICY_REQUEST_CONTROL );
+        ADS_CONTROLS.put( IPasswordPolicy.OID, ControlEnum.PASSWORD_POLICY_REQUEST_CONTROL );
         ADS_CONTROLS.put( PersistentSearch.OID, ControlEnum.PERSISTENT_SEARCH_CONTROL );
         ADS_CONTROLS.put( Subentries.OID, ControlEnum.SUBENTRIES_CONTROL );
         ADS_CONTROLS.put( ISyncDoneValue.OID, ControlEnum.SYNC_DONE_VALUE_CONTROL );
@@ -406,12 +408,13 @@ public abstract class ServerContext impl
             case PASSWORD_POLICY_REQUEST_CONTROL:
                 if ( isRequest )
                 {
-                    control = new PasswordPolicyRequestDecorator( getDirectoryService().getLdapCodecService(), 
-                        new PasswordPolicyRequest() );
+                    control = new PasswordPolicyDecorator( getDirectoryService().getLdapCodecService(), 
+                        new PasswordPolicy() );
                 }
                 else
                 {
-                    control = new PasswordPolicyResponseDecorator( getDirectoryService().getLdapCodecService() );
+                    control = new PasswordPolicyDecorator( getDirectoryService().getLdapCodecService(),
+                        new PasswordPolicy( new PasswordPolicyResponse() ) );
                 }
 
                 break;
@@ -526,7 +529,7 @@ public abstract class ServerContext impl
                 && ( searchControls.getReturningAttributes().length == 0 ) )
             && ( filter instanceof EqualityNode ) )
         {
-            CompareOperationContext compareContext = new CompareOperationContext( session, dn, ((EqualityNode)filter).getAttribute(), ((EqualityNode)filter).getValue() );
+            CompareOperationContext compareContext = new CompareOperationContext( session, dn, ((EqualityNode <?>)filter).getAttribute(), ((EqualityNode)filter).getValue() );
 
             // Inject the referral handling into the operation context
             injectReferralControl( compareContext );

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=1065899&r1=1065898&r2=1065899&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 Feb  1 02:46:12 2011
@@ -36,7 +36,6 @@ import static org.apache.directory.share
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.BitSet;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -83,9 +82,9 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.subtree.SubentryInterceptor;
 import org.apache.directory.server.core.trigger.TriggerInterceptor;
 import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.IPasswordPolicyRequest;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.IPasswordPolicy;
 import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyErrorEnum;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyResponseDecorator;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyDecorator;
 import org.apache.directory.shared.ldap.model.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.model.constants.LdapSecurityConstants;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
@@ -348,7 +347,7 @@ public class AuthenticationInterceptor e
         
         PasswordPolicyConfiguration policyConfig = directoryService.getPwdPolicy( entry );
 
-        boolean isPPolicyReqCtrlPresent = addContext.hasRequestControl( IPasswordPolicyRequest.OID );
+        boolean isPPolicyReqCtrlPresent = addContext.hasRequestControl( IPasswordPolicy.OID );
 
         checkPwdReset( addContext );
 
@@ -372,9 +371,9 @@ public class AuthenticationInterceptor e
             {
                 if ( isPPolicyReqCtrlPresent )
                 {
-                    PasswordPolicyResponseDecorator responseControl = 
-                        new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
-                    responseControl.setPasswordPolicyError( e.getErrorCode() );
+                    PasswordPolicyDecorator responseControl = 
+                        new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
+                    responseControl.getResponse().setPasswordPolicyError( e.getErrorCode() );
                     addContext.addResponseControl( responseControl );
                 }
 
@@ -512,7 +511,7 @@ public class AuthenticationInterceptor e
         // handle the case where pwdPolicySubentry AT is about to be deleted in thid modify()
         PasswordPolicyConfiguration policyConfig = directoryService.getPwdPolicy( modifyContext.getOriginalEntry() );
         
-        boolean isPPolicyReqCtrlPresent = modifyContext.hasRequestControl( IPasswordPolicyRequest.OID );
+        boolean isPPolicyReqCtrlPresent = modifyContext.hasRequestControl( IPasswordPolicy.OID );
         Dn userDn = modifyContext.getSession().getAuthenticatedPrincipal().getDN();
 
         PwdModDetailsHolder pwdModDetails = null;
@@ -529,9 +528,9 @@ public class AuthenticationInterceptor e
                 {
                     if ( isPPolicyReqCtrlPresent )
                     {
-                        PasswordPolicyResponseDecorator responseControl = 
-                            new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
-                        responseControl.setPasswordPolicyError( PasswordPolicyErrorEnum.CHANGE_AFTER_RESET );
+                        PasswordPolicyDecorator responseControl = 
+                            new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
+                        responseControl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.CHANGE_AFTER_RESET );
                         modifyContext.addResponseControl( responseControl );
                     }
 
@@ -546,9 +545,9 @@ public class AuthenticationInterceptor e
                     LOG.debug( "trying to update password attribute without the supplying the old password" );
                     if ( isPPolicyReqCtrlPresent )
                     {
-                        PasswordPolicyResponseDecorator responseControl = 
-                            new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
-                        responseControl.setPasswordPolicyError( PasswordPolicyErrorEnum.MUST_SUPPLY_OLD_PASSWORD );
+                        PasswordPolicyDecorator responseControl = 
+                            new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
+                        responseControl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.MUST_SUPPLY_OLD_PASSWORD );
                         modifyContext.addResponseControl( responseControl );
                     }
 
@@ -561,9 +560,9 @@ public class AuthenticationInterceptor e
 
                 if ( isPPolicyReqCtrlPresent )
                 {
-                    PasswordPolicyResponseDecorator responseControl = 
-                        new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
-                    responseControl.setPasswordPolicyError( PasswordPolicyErrorEnum.PASSWORD_MOD_NOT_ALLOWED );
+                    PasswordPolicyDecorator responseControl = 
+                        new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
+                    responseControl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.PASSWORD_MOD_NOT_ALLOWED );
                     modifyContext.addResponseControl( responseControl );
                 }
 
@@ -576,9 +575,9 @@ public class AuthenticationInterceptor e
             {
                 if ( isPPolicyReqCtrlPresent )
                 {
-                    PasswordPolicyResponseDecorator responseControl = 
-                        new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
-                    responseControl.setPasswordPolicyError( PasswordPolicyErrorEnum.PASSWORD_TOO_YOUNG );
+                    PasswordPolicyDecorator responseControl = 
+                        new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
+                    responseControl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.PASSWORD_TOO_YOUNG );
                     modifyContext.addResponseControl( responseControl );
                 }
 
@@ -605,9 +604,9 @@ public class AuthenticationInterceptor e
                 {
                     if ( isPPolicyReqCtrlPresent )
                     {
-                        PasswordPolicyResponseDecorator responseControl = 
-                            new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
-                        responseControl.setPasswordPolicyError( e.getErrorCode() );
+                        PasswordPolicyDecorator responseControl = 
+                            new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
+                        responseControl.getResponse().setPasswordPolicyError( e.getErrorCode() );
                         modifyContext.addResponseControl( responseControl );
                     }
 
@@ -638,9 +637,9 @@ public class AuthenticationInterceptor e
                     {
                         if ( isPPolicyReqCtrlPresent )
                         {
-                            PasswordPolicyResponseDecorator responseControl = 
-                                new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
-                            responseControl.setPasswordPolicyError( PasswordPolicyErrorEnum.PASSWORD_IN_HISTORY );
+                            PasswordPolicyDecorator responseControl = 
+                                new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
+                            responseControl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.PASSWORD_IN_HISTORY );
                             modifyContext.addResponseControl( responseControl );
                         }
 
@@ -880,9 +879,9 @@ public class AuthenticationInterceptor e
             return;
         }
 
-        boolean isPPolicyReqCtrlPresent = bindContext.hasRequestControl( IPasswordPolicyRequest.OID );
-        PasswordPolicyResponseDecorator pwdRespCtrl = 
-            new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
+        boolean isPPolicyReqCtrlPresent = bindContext.hasRequestControl( IPasswordPolicy.OID );
+        PasswordPolicyDecorator pwdRespCtrl = 
+            new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
 
         boolean authenticated = false;
         PasswordPolicyException ppe = null;
@@ -935,7 +934,7 @@ public class AuthenticationInterceptor e
         {
             if ( isPPolicyReqCtrlPresent )
             {
-                pwdRespCtrl.setPasswordPolicyError( ppe.getErrorCode() );
+                pwdRespCtrl.getResponse().setPasswordPolicyError( ppe.getErrorCode() );
                 bindContext.addResponseControl( pwdRespCtrl );
             }
 
@@ -989,7 +988,7 @@ public class AuthenticationInterceptor e
                     Modification pwdAccountLockedMod = new DefaultModification( ADD_ATTRIBUTE, pwdAccountLockedTimeAt );
                     mods.add( pwdAccountLockedMod );
 
-                    pwdRespCtrl.setPasswordPolicyError( PasswordPolicyErrorEnum.ACCOUNT_LOCKED );
+                    pwdRespCtrl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.ACCOUNT_LOCKED );
                 }
                 else if ( policyConfig.getPwdMinDelay() > 0 )
                 {
@@ -1062,7 +1061,7 @@ public class AuthenticationInterceptor e
                         EntryAttribute pwdGraceUseAttr = userEntry.get( PWD_GRACE_USE_TIME_AT );
                         if ( pwdGraceUseAttr != null )
                         {
-                            pwdRespCtrl.setGraceAuthNsRemaining( policyConfig.getPwdGraceAuthNLimit()
+                            pwdRespCtrl.getResponse().setGraceAuthNsRemaining( policyConfig.getPwdGraceAuthNLimit()
                                 - ( pwdGraceUseAttr.size() + 1 ) );
                         }
                         else
@@ -1092,12 +1091,12 @@ public class AuthenticationInterceptor e
                 int expiryWarnTime = getPwdTimeBeforeExpiry( userEntry, policyConfig );
                 if ( expiryWarnTime > 0 )
                 {
-                    pwdRespCtrl.setTimeBeforeExpiration( expiryWarnTime );
+                    pwdRespCtrl.getResponse().setTimeBeforeExpiration( expiryWarnTime );
                 }
 
                 if ( isPwdMustReset( userEntry ) )
                 {
-                    pwdRespCtrl.setPasswordPolicyError( PasswordPolicyErrorEnum.CHANGE_AFTER_RESET );
+                    pwdRespCtrl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.CHANGE_AFTER_RESET );
                     pwdResetSet.add( dn );
                 }
 
@@ -1221,57 +1220,6 @@ public class AuthenticationInterceptor e
 
 
     /**
-     * The password contains characters from at least three of the following four categories:
-     * English uppercase characters (A - Z)
-     * English lowercase characters (a - z)
-     * Base 10 digits (0 - 9)
-     * Any non-alphanumeric character (for example: !, $, #, or %)
-     */
-    private void checkPasswordChars( String password ) throws PasswordPolicyException
-    {
-        BitSet bitSet = new BitSet( 4 );
-
-        char[] characters = password.toCharArray();
-
-        for ( char character : characters )
-        {
-            if ( Character.isLowerCase( character ) )
-            {
-                bitSet.set( 0 );
-            }
-            else
-            {
-                if ( Character.isUpperCase( character ) )
-                {
-                    bitSet.set( 1 );
-                }
-                else
-                {
-                    if ( Character.isDigit( character ) )
-                    {
-                        bitSet.set( 2 );
-                    }
-                    else
-                    {
-                        if ( !Character.isLetterOrDigit( character ) )
-                        {
-                            bitSet.set( 3 );
-                        }
-                    }
-                }
-            }
-        }
-
-        if ( bitSet.cardinality() != bitSet.size() )
-        {
-            throw new PasswordPolicyException(
-                "Password should contain a mix of uppercase, lowercase, digits and non-alphanumeric characters",
-                INSUFFICIENT_PASSWORD_QUALITY );
-        }
-    }
-
-
-    /**
      * The password does not contain three letter (or more) tokens from the user's account name.
      *
      * If the account name is less than three characters long, this check is not performed
@@ -1437,12 +1385,12 @@ public class AuthenticationInterceptor e
             if ( pwdResetSet.contains( userDn ) )
             {
                 boolean isPPolicyReqCtrlPresent = opContext
-                    .hasRequestControl( IPasswordPolicyRequest.OID );
+                    .hasRequestControl( IPasswordPolicy.OID );
                 if ( isPPolicyReqCtrlPresent )
                 {
-                    PasswordPolicyResponseDecorator pwdRespCtrl = 
-                        new PasswordPolicyResponseDecorator( directoryService.getLdapCodecService() );
-                    pwdRespCtrl.setPasswordPolicyError( PasswordPolicyErrorEnum.CHANGE_AFTER_RESET );
+                    PasswordPolicyDecorator pwdRespCtrl = 
+                        new PasswordPolicyDecorator( directoryService.getLdapCodecService() );
+                    pwdRespCtrl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.CHANGE_AFTER_RESET );
                     opContext.addResponseControl( pwdRespCtrl );
                 }
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/PasswordPolicyException.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/PasswordPolicyException.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/PasswordPolicyException.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/PasswordPolicyException.java Tue Feb  1 02:46:12 2011
@@ -17,7 +17,6 @@
  *   under the License.
  *
  */
-
 package org.apache.directory.server.core.authn;
 
 
@@ -32,6 +31,7 @@ import org.apache.directory.shared.ldap.
  */
 public class PasswordPolicyException extends LdapException
 {
+    private static final long serialVersionUID = -9158126177779964262L;
 
     /** password policy error code */
     private PasswordPolicyErrorEnum errorCode;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java Tue Feb  1 02:46:12 2011
@@ -30,8 +30,8 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.controls.CascadeFactory;
 import org.apache.directory.shared.ldap.codec.controls.ManageDsaITFactory;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.IPasswordPolicyRequest;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyRequestFactory;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicy;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyFactory;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.ISyncDoneValue;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueFactory;
 import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.ISyncInfoValue;
@@ -113,9 +113,9 @@ public class DefaultLdapCodecService imp
 
         SyncStateValueFactory syncStateValueFactory = new SyncStateValueFactory( this );
         controlFactories.put( ISyncStateValue.OID, syncStateValueFactory );
-
-        PasswordPolicyRequestFactory passwordPolicyRequestFactory = new PasswordPolicyRequestFactory( this );
-        controlFactories.put( IPasswordPolicyRequest.OID, passwordPolicyRequestFactory );
+        
+        PasswordPolicyFactory passwordPolicyFactory = new PasswordPolicyFactory( this );
+        controlFactories.put( PasswordPolicy.OID, passwordPolicyFactory );
 }
     
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecorator.java Tue Feb  1 02:46:12 2011
@@ -48,9 +48,6 @@ public abstract class ControlDecorator<E
     /** The encoded value length */
     protected int valueLength;
 
-    /** The control length */
-    private int controlLength;
-
     /** The encoded value of the control. */
     protected byte[] value;
     

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicy.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicy.java?rev=1065899&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicy.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicy.java Tue Feb  1 02:46:12 2011
@@ -0,0 +1,82 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.controls.ppolicy;
+
+
+import org.apache.directory.shared.ldap.model.message.Control;
+
+
+/**
+ * The password policy {@link Control} interface.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface IPasswordPolicy extends Control
+{
+    /** the password policy request control */
+    public static final String OID = "1.3.6.1.4.1.42.2.27.8.5.1";
+
+
+    /**
+     * Checks whether this Control is the password policy request or the response
+     * by carrying with it an IPasswordPolicyResponse object. If it is a request, 
+     * then no response component will be associated with the control: getResponse()
+     * will return null.
+     *
+     * @return true if this Control carries a response, false if it is a request
+     */
+    boolean hasResponse();
+    
+    
+    /**
+     * Sets the response. If null hasResponse() will return null and this will be
+     * handled as a password policy request control rather than a response control.
+     *
+     * @param response a valid response object, or null to make this a request
+     */
+    void setResponse( IPasswordPolicyResponse response );
+    
+    
+    /**
+     * If true sets the response to a default newly initialized response object. 
+     * If this was previously a request, it automatically becomes a response. If it 
+     * was not a request with an already existing response object then that response
+     * is replace with a new one and the old is returned. If false then any response
+     * object set will be cleared to null. 
+     * 
+     * Effectively this will cause hasResponse() to return whatever you plug into it.
+     *
+     * @param hasResponse true to create default response, false to clear it
+     * @return the old response object, if one did not exist null is returned
+     */
+    IPasswordPolicyResponse setResponse( boolean hasResponse );
+    
+    
+    /**
+     * Get's the response component of this control if this control carries a 
+     * response. If {@link #hasResponse()} returns true, this will return a non-null
+     * policy response object. 
+     *
+     * @return a non-null policy response or null, if {@link #hasResponse()} 
+     * returns false
+     */
+    IPasswordPolicyResponse getResponse();
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicyResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicyResponse.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicyResponse.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/IPasswordPolicyResponse.java Tue Feb  1 02:46:12 2011
@@ -20,17 +20,8 @@
 package org.apache.directory.shared.ldap.codec.controls.ppolicy;
 
 
-import org.apache.directory.shared.ldap.model.message.Control;
-
-
-/**
- * PasswordPolicyResponseControl.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public interface IPasswordPolicyResponse extends Control
+public interface IPasswordPolicyResponse
 {
-
     int getTimeBeforeExpiration();
 
 
@@ -47,5 +38,4 @@ public interface IPasswordPolicyResponse
 
 
     void setPasswordPolicyError( PasswordPolicyErrorEnum ppolicyError );
-
 }
\ No newline at end of file

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicy.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicy.java?rev=1065899&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicy.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicy.java Tue Feb  1 02:46:12 2011
@@ -0,0 +1,152 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.controls.ppolicy;
+
+
+import org.apache.directory.shared.ldap.model.message.Control;
+
+
+/**
+ * A simple {@link IPasswordPolicy} {@link Control} implementation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PasswordPolicy implements IPasswordPolicy
+{
+    /** The criticality of this {@link Control} */
+    private boolean criticality;
+    
+    /** The password policy response component if this is a response control */
+    private IPasswordPolicyResponse response;
+    
+    
+    /**
+     * Creates a new instance of a PasswordPolicy request Control without any
+     * response data associated with it.
+     */
+    public PasswordPolicy()
+    {
+        response = null;
+    }
+
+
+    /**
+     * Creates a new instance of a PasswordPolicy request Control without any
+     * response data associated with it.
+     */
+    public PasswordPolicy( boolean hasResponse )
+    {
+        if ( hasResponse )
+        {
+            response = new PasswordPolicyResponse();
+        }
+        else
+        {
+            response = null;
+        }
+    }
+
+
+    /**
+     * Creates a new instance of PasswordPolicy response Control with response 
+     * information packaged into the control.
+     */
+    public PasswordPolicy( IPasswordPolicyResponse response )
+    {
+        this.response = response;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOid()
+    {
+        return IPasswordPolicy.OID;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isCritical()
+    {
+        return criticality;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setCritical( boolean isCritical )
+    {
+        this.criticality = isCritical;
+    }
+
+    
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public void setResponse( IPasswordPolicyResponse response )
+    {
+        this.response = response;
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean hasResponse()
+    {
+        return response != null;
+    }
+
+    
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public IPasswordPolicyResponse setResponse( boolean hasResponse )
+    {
+        IPasswordPolicyResponse old = this.response;
+        
+        if ( hasResponse )
+        {
+            this.response = new PasswordPolicyResponse();
+        }
+        else
+        {
+            this.response = null;
+        }
+        
+        return old;
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    public IPasswordPolicyResponse getResponse()
+    {
+        return response;
+    }
+}

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyContainer.java (from r1065842, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseContainer.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyContainer.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyContainer.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseContainer.java&r1=1065842&r2=1065899&rev=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyContainer.java Tue Feb  1 02:46:12 2011
@@ -30,38 +30,38 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PasswordPolicyResponseContainer extends AbstractContainer
+public class PasswordPolicyContainer extends AbstractContainer
 {
-    private PasswordPolicyResponseDecorator control;
+    private PasswordPolicyDecorator control;
 
 
-    public PasswordPolicyResponseContainer( ILdapCodecService codec )
+    public PasswordPolicyContainer( ILdapCodecService codec )
     {
         super();
-        control = new PasswordPolicyResponseDecorator( codec, new PasswordPolicyResponseDecorator( codec ) );
+        control = new PasswordPolicyDecorator( codec, new PasswordPolicy() );
         stateStack = new int[1];
-        grammar = PasswordPolicyResponseGrammar.getInstance();
-        setTransition( PasswordPolicyResponseStates.START_STATE );
+        grammar = PasswordPolicyGrammar.getInstance();
+        setTransition( PasswordPolicyStates.START_STATE );
     }
 
 
-    public PasswordPolicyResponseContainer( ILdapCodecService codec, IPasswordPolicyResponse ppolicyResponse )
+    public PasswordPolicyContainer( ILdapCodecService codec, IPasswordPolicy ppolicyResponse )
     {
         super();
-        control = new PasswordPolicyResponseDecorator( codec, ppolicyResponse );
+        control = new PasswordPolicyDecorator( codec, ppolicyResponse );
         stateStack = new int[1];
-        grammar = PasswordPolicyResponseGrammar.getInstance();
-        setTransition( PasswordPolicyResponseStates.START_STATE );
+        grammar = PasswordPolicyGrammar.getInstance();
+        setTransition( PasswordPolicyStates.START_STATE );
     }
 
 
-    public PasswordPolicyResponseDecorator getPasswordPolicyResponseControl()
+    public PasswordPolicyDecorator getPasswordPolicyResponseControl()
     {
         return control;
     }
 
 
-    public void setPasswordPolicyResponseControl( PasswordPolicyResponseDecorator control )
+    public void setPasswordPolicyResponseControl( PasswordPolicyDecorator control )
     {
         this.control = control;
     }

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyDecorator.java?rev=1065899&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyDecorator.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyDecorator.java Tue Feb  1 02:46:12 2011
@@ -0,0 +1,266 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.controls.ppolicy;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
+import org.apache.directory.shared.ldap.codec.controls.ControlDecorator;
+
+
+/**
+ * PasswordPolicyResponseControl.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PasswordPolicyDecorator extends ControlDecorator<IPasswordPolicy> implements IPasswordPolicy
+{
+    /** An instance of this decoder */
+    private static final Asn1Decoder decoder = new Asn1Decoder();
+    
+    // Storage for computed lengths
+    private transient int valueLength = 0;
+    private transient int ppolicySeqLength = 0;
+    private transient int warningLength = 0;
+    private transient int timeBeforeExpirationTagLength;
+    private transient int graceAuthNsRemainingTagLength;
+    
+    
+    public PasswordPolicyDecorator( ILdapCodecService codec )
+    {
+        super( codec, new PasswordPolicy() );
+    }
+    
+    
+    public PasswordPolicyDecorator( ILdapCodecService codec, boolean hasResponse )
+    {
+        super( codec, new PasswordPolicy( hasResponse ) );
+    }
+
+
+    public PasswordPolicyDecorator( ILdapCodecService codec, IPasswordPolicy policy )
+    {
+        super( codec, policy );
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setValue( byte[] value )
+    {
+        if ( value == null || value.length == 0 )
+        {
+            setResponse( null );
+        }
+        
+        if ( value != null && ! hasResponse() )
+        {
+            setResponse( true );
+        }
+        
+        super.setValue( value );
+    }
+
+
+    @Override
+    public int computeLength()
+    {
+        if ( ! hasResponse() )
+        {
+            return 0;
+        }
+        
+        if ( getResponse().getTimeBeforeExpiration() >= 0 )
+        {
+            timeBeforeExpirationTagLength = TLV.getNbBytes( getResponse().getTimeBeforeExpiration() );
+            warningLength = 1 + TLV.getNbBytes( timeBeforeExpirationTagLength ) + timeBeforeExpirationTagLength;
+        }
+        else if ( getResponse().getGraceAuthNsRemaining() >= 0 )
+        {
+            graceAuthNsRemainingTagLength = TLV.getNbBytes( getResponse().getGraceAuthNsRemaining() );
+            warningLength = 1 + TLV.getNbBytes( graceAuthNsRemainingTagLength ) + graceAuthNsRemainingTagLength;
+        }
+
+        if ( warningLength != 0 )
+        {
+            ppolicySeqLength = 1 + TLV.getNbBytes( warningLength ) + warningLength;
+        }
+
+        if ( getResponse().getPasswordPolicyError() != null )
+        {
+            ppolicySeqLength += 1 + 1 + 1;
+        }
+        
+        if ( ppolicySeqLength > 0 )
+        {
+            valueLength = 1 + TLV.getNbBytes( ppolicySeqLength ) + ppolicySeqLength;
+        }
+
+        return valueLength;
+    }
+
+
+    @Override
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( ! hasResponse() )
+        {
+            return buffer;
+        }
+        
+        if ( buffer == null )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
+        }
+
+        if ( ( getResponse().getTimeBeforeExpiration() < 0 ) && ( getResponse().getGraceAuthNsRemaining() < 0 ) && ( 
+            getResponse().getPasswordPolicyError() == null ) )
+        {
+            return buffer;
+        }
+        else
+        {
+            // Encode the Sequence tag
+            buffer.put( UniversalTag.SEQUENCE.getValue() );
+            buffer.put( TLV.getBytes( ppolicySeqLength ) );
+
+            if ( warningLength > 0 )
+            {
+                // Encode the Warning tag
+                buffer.put( ( byte )PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue() );
+                buffer.put( TLV.getBytes( warningLength ) );
+
+                if ( getResponse().getTimeBeforeExpiration() >= 0 )
+                {
+                    buffer.put( ( byte ) PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue() );
+                    buffer.put( TLV.getBytes( timeBeforeExpirationTagLength ) );
+                    buffer.put( Value.getBytes( getResponse().getTimeBeforeExpiration() ) );
+                }
+                else if ( getResponse().getGraceAuthNsRemaining() >= 0 )
+                {
+                    buffer.put( ( byte ) PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue() );
+                    buffer.put( TLV.getBytes( graceAuthNsRemainingTagLength ) );
+                    buffer.put( Value.getBytes( getResponse().getGraceAuthNsRemaining() ) );
+                }
+            }
+    
+            if ( getResponse().getPasswordPolicyError() != null )
+            {
+                buffer.put( (byte)PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue() );
+                buffer.put( ( byte ) 0x01 );
+                buffer.put( Value.getBytes( getResponse().getPasswordPolicyError().getValue() ) );
+            }
+        }
+
+        return buffer;
+    }
+
+    
+    @Override
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "  PasswordPolicyResponse control :\n" );
+        sb.append( "   oid          : '" ).append( getOid() ).append( '\n' );
+        
+        if ( getResponse().getTimeBeforeExpiration() >= 0 )
+        {
+            sb.append( "   timeBeforeExpiration          : '" ).append( getResponse().getTimeBeforeExpiration() ).append( '\n' );
+        }
+        else if ( getResponse().getGraceAuthNsRemaining() >= 0 )
+        {
+            sb.append( "   graceAuthNsRemaining          : '" ).append( getResponse().getGraceAuthNsRemaining() ).append( '\n' );
+        }
+
+        if ( getResponse().getPasswordPolicyError() != null )
+        {
+            sb.append( "   ppolicyError          : '" ).append( getResponse().getPasswordPolicyError().toString() ).append( '\n' );
+        }
+
+        return sb.toString();
+    }
+
+
+    @Override
+    public Asn1Object decode( byte[] controlBytes ) throws DecoderException
+    {
+        if ( ! hasResponse() )
+        {
+            return this;
+        }
+        
+        ByteBuffer bb = ByteBuffer.wrap( controlBytes );
+        PasswordPolicyContainer container = new PasswordPolicyContainer( getCodecService(), this );
+        decoder.decode( bb, container );
+        return this;
+    }
+
+
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public boolean hasResponse()
+    {
+        return getDecorated().hasResponse();
+    }
+    
+    
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public void setResponse( IPasswordPolicyResponse response )
+    {
+        getDecorated().setResponse( response );
+    }
+
+    
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public IPasswordPolicyResponse setResponse( boolean hasResponse )
+    {
+        return getDecorated().setResponse( hasResponse );
+    }
+    
+
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public IPasswordPolicyResponse getResponse()
+    {
+        return getDecorated().getResponse();
+    }
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyFactory.java?rev=1065899&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyFactory.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyFactory.java Tue Feb  1 02:46:12 2011
@@ -0,0 +1,129 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.controls.ppolicy;
+
+
+import java.nio.ByteBuffer;
+
+import javax.naming.ldap.BasicControl;
+import javax.naming.ldap.Control;
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.ldap.codec.IControlFactory;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
+
+
+/**
+ * A {@link IControlFactory} which creates {@link IPasswordPolicy} controls.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PasswordPolicyFactory implements IControlFactory<IPasswordPolicy, PasswordPolicyDecorator>
+{
+    
+    private ILdapCodecService codec;
+    
+
+    /**
+     * Creates a new instance of PasswordPolicyFactory.
+     *
+     */
+    public PasswordPolicyFactory( ILdapCodecService codec )
+    {
+        this.codec = codec;
+    }
+    
+
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public String getOid()
+    {
+        return IPasswordPolicy.OID;
+    }
+
+    
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public PasswordPolicyDecorator newCodecControl()
+    {
+        return new PasswordPolicyDecorator( codec );
+    }
+    
+
+    public PasswordPolicyDecorator decorate( IPasswordPolicy control )
+    {
+        PasswordPolicyDecorator decorator = null;
+        
+        // protect against double decoration
+        if ( control instanceof PasswordPolicyDecorator )
+        {
+            decorator = ( PasswordPolicyDecorator ) control;
+        }
+        else
+        {
+            decorator = new PasswordPolicyDecorator( codec, control );
+        }
+        
+        return decorator;
+    }
+
+    
+    public IPasswordPolicy newControl()
+    {
+        return new PasswordPolicy();
+    }
+    
+
+    public Control toJndiControl( IPasswordPolicy control ) throws EncoderException
+    {
+        PasswordPolicyDecorator decorator = decorate( control );
+        ByteBuffer bb = ByteBuffer.allocate( decorator.computeLength() );
+        decorator.encode( bb );
+        bb.flip();
+        return new BasicControl( control.getOid(), control.isCritical(), decorator.getValue() );
+    }
+
+    
+    public IPasswordPolicy fromJndiControl( Control jndi ) throws DecoderException
+    {
+        PasswordPolicyDecorator decorator = null;
+        
+        if ( jndi.getEncodedValue() == null || jndi.getEncodedValue().length == 0 )
+        {
+            decorator = new PasswordPolicyDecorator( codec, false );
+        }
+        else
+        {
+            decorator = new PasswordPolicyDecorator( codec, true );
+        }
+        
+        decorator.setCritical( jndi.isCritical() );
+        decorator.setValue( jndi.getEncodedValue() );
+        byte[] controlBytes = new byte[ decorator.computeLength() ];
+        decorator.decode( controlBytes );
+        return decorator.getDecorated();
+    }
+}

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyGrammar.java (from r1065842, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseGrammar.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyGrammar.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyGrammar.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseGrammar.java&r1=1065842&r2=1065899&rev=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyGrammar.java Tue Feb  1 02:46:12 2011
@@ -53,65 +53,65 @@ import org.apache.directory.shared.ldap.
  *          
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PasswordPolicyResponseGrammar extends AbstractGrammar
+public class PasswordPolicyGrammar extends AbstractGrammar
 {
     /** PasswordPolicyResponseControlGrammar singleton instance */
-    private static final PasswordPolicyResponseGrammar INSTANCE = new PasswordPolicyResponseGrammar();
+    private static final PasswordPolicyGrammar INSTANCE = new PasswordPolicyGrammar();
 
 
-    private PasswordPolicyResponseGrammar()
+    private PasswordPolicyGrammar()
     {
-        setName( PasswordPolicyResponseGrammar.class.getName() );
+        setName( PasswordPolicyGrammar.class.getName() );
 
-        super.transitions = new GrammarTransition[PasswordPolicyResponseStates.END_STATE.ordinal()][256];
+        super.transitions = new GrammarTransition[PasswordPolicyStates.END_STATE.ordinal()][256];
 
 
         // PasswordPolicyResponseValue ::= SEQUENCE {
         // ...
-        super.transitions[PasswordPolicyResponseStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
-            PasswordPolicyResponseStates.START_STATE, PasswordPolicyResponseStates.PPOLICY_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
+        super.transitions[PasswordPolicyStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+            PasswordPolicyStates.START_STATE, PasswordPolicyStates.PPOLICY_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
             new PPolicyInit());
         
         // PasswordPolicyResponseValue ::= SEQUENCE {
         //              warning [0] CHOICE {
-        super.transitions[PasswordPolicyResponseStates.PPOLICY_SEQ_STATE.ordinal()][PasswordPolicyResponseTags.PPOLICY_WARNING_TAG.getValue()] = new GrammarTransition(
-            PasswordPolicyResponseStates.PPOLICY_SEQ_STATE, PasswordPolicyResponseStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyResponseTags.PPOLICY_WARNING_TAG.getValue(),
+        super.transitions[PasswordPolicyStates.PPOLICY_SEQ_STATE.ordinal()][PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue()] = new GrammarTransition(
+            PasswordPolicyStates.PPOLICY_SEQ_STATE, PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue(),
             new CheckNotNullLength());
         
         // PasswordPolicyResponseValue ::= SEQUENCE {
         //              ...
         //              error   [1] ENUMERATED {
-        super.transitions[PasswordPolicyResponseStates.PPOLICY_SEQ_STATE.ordinal()][PasswordPolicyResponseTags.PPOLICY_ERROR_TAG.getValue()] = new GrammarTransition(
-            PasswordPolicyResponseStates.PPOLICY_SEQ_STATE, PasswordPolicyResponseStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyResponseTags.PPOLICY_ERROR_TAG.getValue(),
+        super.transitions[PasswordPolicyStates.PPOLICY_SEQ_STATE.ordinal()][PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue()] = new GrammarTransition(
+            PasswordPolicyStates.PPOLICY_SEQ_STATE, PasswordPolicyStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue(),
             new StoreError());
         
         // PasswordPolicyResponseValue ::= SEQUENCE {
         //              warning [0] CHOICE {
         //                      timeBeforeExpiration [0] INTEGER (0 .. maxInt),
-        super.transitions[PasswordPolicyResponseStates.PPOLICY_WARNING_TAG_STATE.ordinal()][PasswordPolicyResponseTags.TIME_BEFORE_EXPIRATION_TAG.getValue()] = new GrammarTransition(
-            PasswordPolicyResponseStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyResponseStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE, PasswordPolicyResponseTags.TIME_BEFORE_EXPIRATION_TAG.getValue(),
+        super.transitions[PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE.ordinal()][PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue()] = new GrammarTransition(
+            PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE, PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue(),
             new StoreTimeBeforeExpiration());
         
         // PasswordPolicyResponseValue ::= SEQUENCE {
         //              warning [0] CHOICE {
         //                      ...
         //                      graceAuthNsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL,
-        super.transitions[PasswordPolicyResponseStates.PPOLICY_WARNING_TAG_STATE.ordinal()][PasswordPolicyResponseTags.GRACE_AUTHNS_REMAINING_TAG.getValue()] = new GrammarTransition(
-            PasswordPolicyResponseStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyResponseStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE, PasswordPolicyResponseTags.GRACE_AUTHNS_REMAINING_TAG.getValue(),
+        super.transitions[PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE.ordinal()][PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue()] = new GrammarTransition(
+            PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE, PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue(),
             new StoreGraceAuthsRemaining());
         
         // PasswordPolicyResponseValue ::= SEQUENCE {
         //              ...
         //              error   [1] ENUMERATED {
-        super.transitions[PasswordPolicyResponseStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE.ordinal()][PasswordPolicyResponseTags.PPOLICY_ERROR_TAG.getValue()] = new GrammarTransition(
-            PasswordPolicyResponseStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE, PasswordPolicyResponseStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyResponseTags.PPOLICY_ERROR_TAG.getValue(),
+        super.transitions[PasswordPolicyStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE.ordinal()][PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue()] = new GrammarTransition(
+            PasswordPolicyStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE, PasswordPolicyStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue(),
             new StoreError());
         
         // PasswordPolicyResponseValue ::= SEQUENCE {
         //              ...
         //              error   [1] ENUMERATED {
-        super.transitions[PasswordPolicyResponseStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE.ordinal()][PasswordPolicyResponseTags.GRACE_AUTHNS_REMAINING_TAG.getValue()] = new GrammarTransition(
-            PasswordPolicyResponseStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE, PasswordPolicyResponseStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyResponseTags.GRACE_AUTHNS_REMAINING_TAG.getValue(),
+        super.transitions[PasswordPolicyStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE.ordinal()][PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue()] = new GrammarTransition(
+            PasswordPolicyStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE, PasswordPolicyStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue(),
             new StoreError());
     }
 

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponse.java?rev=1065899&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponse.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponse.java Tue Feb  1 02:46:12 2011
@@ -0,0 +1,93 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.controls.ppolicy;
+
+
+/**
+ * A PasswordPolicyResponse.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PasswordPolicyResponse implements IPasswordPolicyResponse
+{
+    /** time before expiration of the password */
+    private int timeBeforeExpiration = -1;
+
+    /** number of remaining grace authentications */
+    private int graceAuthNsRemaining = -1;
+
+    /** number representing the password policy error */
+    private PasswordPolicyErrorEnum ppolicyError;
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int getTimeBeforeExpiration()
+    {
+        return timeBeforeExpiration;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setTimeBeforeExpiration( int timeBeforeExpiration )
+    {
+        this.timeBeforeExpiration = timeBeforeExpiration;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getGraceAuthNsRemaining()
+    {
+        return graceAuthNsRemaining;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setGraceAuthNsRemaining( int graceAuthNsRemaining )
+    {
+        this.graceAuthNsRemaining = graceAuthNsRemaining;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public PasswordPolicyErrorEnum getPasswordPolicyError()
+    {
+        return ppolicyError;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setPasswordPolicyError( PasswordPolicyErrorEnum ppolicyError )
+    {
+        this.ppolicyError = ppolicyError;
+    }
+}

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyStates.java (from r1065842, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseStates.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyStates.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyStates.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseStates.java&r1=1065842&r2=1065899&rev=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseStates.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyStates.java Tue Feb  1 02:46:12 2011
@@ -26,11 +26,11 @@ import org.apache.directory.shared.asn1.
 
 
 /**
- * various states used in {@link PasswordPolicyResponseGrammar}.
+ * various states used in {@link PasswordPolicyGrammar}.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public enum PasswordPolicyResponseStates implements States
+public enum PasswordPolicyStates implements States
 {
 
     START_STATE,                            // 0
@@ -52,7 +52,7 @@ public enum PasswordPolicyResponseStates
      */
     public String getGrammarName( Grammar grammar )
     {
-        if( grammar instanceof PasswordPolicyResponseGrammar )
+        if( grammar instanceof PasswordPolicyGrammar )
         {
             return "PASSWORD_POLICY_RESPONSE_CONTROL_GRAMMAR";
         }
@@ -90,7 +90,7 @@ public enum PasswordPolicyResponseStates
     /**
      * {@inheritDoc}
      */
-    public PasswordPolicyResponseStates getStartState()
+    public PasswordPolicyStates getStartState()
     {
         return START_STATE;
     }

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTags.java (from r1065842, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseTags.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTags.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTags.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseTags.java&r1=1065842&r2=1065899&rev=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseTags.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTags.java Tue Feb  1 02:46:12 2011
@@ -25,7 +25,7 @@ package org.apache.directory.shared.ldap
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public enum PasswordPolicyResponseTags
+public enum PasswordPolicyTags
 {
     PPOLICY_WARNING_TAG(0xA0),          // warning [0]
     PPOLICY_ERROR_TAG(0x81),            // error [1]
@@ -36,7 +36,7 @@ public enum PasswordPolicyResponseTags
     private int value;
 
 
-    private PasswordPolicyResponseTags( int value )
+    private PasswordPolicyTags( int value )
     {
         this.value = value;
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreError.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreError.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreError.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreError.java Tue Feb  1 02:46:12 2011
@@ -23,7 +23,7 @@ package org.apache.directory.shared.ldap
 import org.apache.directory.shared.asn1.actions.AbstractReadInteger;
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyErrorEnum;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyResponseContainer;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyContainer;
 
 
 /**
@@ -49,10 +49,10 @@ public class StoreError extends Abstract
     @Override
     protected void setIntegerValue( int value, Asn1Container container )
     {
-        PasswordPolicyResponseContainer ppolicyContainer = ( PasswordPolicyResponseContainer ) container;
+        PasswordPolicyContainer ppolicyContainer = ( PasswordPolicyContainer ) container;
         
         PasswordPolicyErrorEnum error = PasswordPolicyErrorEnum.get( value );
-        ppolicyContainer.getPasswordPolicyResponseControl().setPasswordPolicyError( error );
+        ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setPasswordPolicyError( error );
 
         ppolicyContainer.setGrammarEndAllowed( true );
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreGraceAuthsRemaining.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreGraceAuthsRemaining.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreGraceAuthsRemaining.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreGraceAuthsRemaining.java Tue Feb  1 02:46:12 2011
@@ -22,7 +22,7 @@ package org.apache.directory.shared.ldap
 
 import org.apache.directory.shared.asn1.actions.AbstractReadInteger;
 import org.apache.directory.shared.asn1.ber.Asn1Container;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyResponseContainer;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyContainer;
 
 
 /**
@@ -48,9 +48,9 @@ public class StoreGraceAuthsRemaining ex
     @Override
     protected void setIntegerValue( int value, Asn1Container container )
     {
-        PasswordPolicyResponseContainer ppolicyContainer = ( PasswordPolicyResponseContainer ) container;
+        PasswordPolicyContainer ppolicyContainer = ( PasswordPolicyContainer ) container;
         
-        ppolicyContainer.getPasswordPolicyResponseControl().setGraceAuthNsRemaining( value );
+        ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setGraceAuthNsRemaining( value );
 
         ppolicyContainer.setGrammarEndAllowed( true );
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java?rev=1065899&r1=1065898&r2=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java Tue Feb  1 02:46:12 2011
@@ -22,7 +22,7 @@ package org.apache.directory.shared.ldap
 
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.actions.AbstractReadInteger;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyResponseContainer;
+import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyContainer;
 
 
 /**
@@ -48,9 +48,9 @@ public class StoreTimeBeforeExpiration e
     @Override
     protected void setIntegerValue( int value, Asn1Container container )
     {
-        PasswordPolicyResponseContainer ppolicyContainer = ( PasswordPolicyResponseContainer ) container;
+        PasswordPolicyContainer ppolicyContainer = ( PasswordPolicyContainer ) container;
         
-        ppolicyContainer.getPasswordPolicyResponseControl().setTimeBeforeExpiration( value );
+        ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setTimeBeforeExpiration( value );
         
         container.setGrammarEndAllowed( true );
     }



Mime
View raw message