directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1549764 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/ interceptors/authn/src/main/java/org/apache/directory/server/core/authn/
Date Tue, 10 Dec 2013 06:20:29 GMT
Author: kayyagari
Date: Tue Dec 10 06:20:29 2013
New Revision: 1549764

URL: http://svn.apache.org/r1549764
Log:
allow access to Entry object for more control in custom validators (DIRSERVER-1926)

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/DefaultPasswordValidator.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordValidator.java
    directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/DefaultPasswordValidator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/DefaultPasswordValidator.java?rev=1549764&r1=1549763&r2=1549764&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/DefaultPasswordValidator.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/DefaultPasswordValidator.java
Tue Dec 10 06:20:29 2013
@@ -20,6 +20,8 @@
 
 package org.apache.directory.server.core.api.authn.ppolicy;
 
+import org.apache.directory.api.ldap.model.entry.Entry;
+
 
 /**
  * The default password validator.
@@ -44,9 +46,9 @@ public class DefaultPasswordValidator im
     /**
      * {@inheritDoc}
      */
-    public void validate( String password, String entryRdnVal ) throws PasswordPolicyException
+    public void validate( String password, Entry entry ) throws PasswordPolicyException
     {
-        checkUsernameSubstring( password, entryRdnVal );
+        checkUsernameSubstring( password, entry );
         //TODO add more checks
     }
 
@@ -63,8 +65,10 @@ public class DefaultPasswordValidator im
      * "first" or "last" as a substring anywhere in the password. All of these checks are
      * case-insensitive.
      */
-    private void checkUsernameSubstring( String password, String username ) throws PasswordPolicyException
+    private void checkUsernameSubstring( String password, Entry entry ) throws PasswordPolicyException
     {
+        String username = entry.getDn().getRdn().getValue().getString();
+        
         if ( username == null || username.trim().length() == 0 )
         {
             return;

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordValidator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordValidator.java?rev=1549764&r1=1549763&r2=1549764&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordValidator.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordValidator.java
Tue Dec 10 06:20:29 2013
@@ -20,6 +20,8 @@
 
 package org.apache.directory.server.core.api.authn.ppolicy;
 
+import org.apache.directory.api.ldap.model.entry.Entry;
+
 
 /**
  * An interface for implementing password quality verifiers.
@@ -29,14 +31,14 @@ package org.apache.directory.server.core
 public interface PasswordValidator
 {
     /**
-     * checks if the given password meets the required quality contraints.<br>
+     * checks if the given password meets the required quality constraints.<br>
      * <p>Note: the length based validations are already done before calling this method<br>
      *       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      *       so the implementor should concentrate on the content checking.</p>
      *  
      * @param password the password value
-     * @param userId user's ID (it is the value of entry's RDN e.x 'admin' if the entry's
DN is {uid/cn/etc..}=admin,ou=system)
+     * @param entry user entry
      * @throws PasswordPolicyException if the password doesn't meet the quality contraints
      */
-    void validate( String password, String userId ) throws PasswordPolicyException;
+    void validate( String password, Entry entry ) throws PasswordPolicyException;
 }

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=1549764&r1=1549763&r2=1549764&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
Tue Dec 10 06:20:29 2013
@@ -354,14 +354,11 @@ public class AuthenticationInterceptor e
 
         if ( userPasswordAttribute != null )
         {
-            String username = null;
-
             BinaryValue userPassword = ( BinaryValue ) userPasswordAttribute.get();
 
             try
             {
-                username = entry.getDn().getRdn().getValue().getString();
-                check( username, userPassword.getValue(), policyConfig );
+                check( entry, userPassword.getValue(), policyConfig );
             }
             catch ( PasswordPolicyException e )
             {
@@ -939,8 +936,7 @@ public class AuthenticationInterceptor e
 
                 try
                 {
-                    String userName = entry.getDn().getRdn().getValue().getString();
-                    check( userName, newPassword, policyConfig );
+                    check( entry, newPassword, policyConfig );
                 }
                 catch ( PasswordPolicyException e )
                 {
@@ -1256,7 +1252,7 @@ public class AuthenticationInterceptor e
 
 
     // ---------- private methods ----------------
-    private void check( String username, byte[] password, PasswordPolicyConfiguration policyConfig
)
+    private void check( Entry entry, byte[] password, PasswordPolicyConfiguration policyConfig
)
         throws LdapException
     {
         final CheckQualityEnum qualityVal = policyConfig.getPwdCheckQuality();
@@ -1288,7 +1284,7 @@ public class AuthenticationInterceptor e
         // perform the length validation
         validatePasswordLength( strPassword, policyConfig );
 
-        policyConfig.getPwdValidator().validate( strPassword, username );
+        policyConfig.getPwdValidator().validate( strPassword, entry );
     }
 
 



Mime
View raw message