directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1467520 - 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/ service-builder/src/main/java/org/apache/directory/...
Date Fri, 12 Apr 2013 23:57:36 GMT
Author: elecharny
Date: Fri Apr 12 23:57:36 2013
New Revision: 1467520

URL: http://svn.apache.org/r1467520
Log:
Added an enum for the CheckQuality password

Added:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/CheckQualityEnum.java
Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordPolicyConfiguration.java
    directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
    directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java

Added: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/CheckQualityEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/CheckQualityEnum.java?rev=1467520&view=auto
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/CheckQualityEnum.java
(added)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/CheckQualityEnum.java
Fri Apr 12 23:57:36 2013
@@ -0,0 +1,92 @@
+/*
+ *   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.server.core.api.authn.ppolicy;
+
+
+/**
+ * The 3 possible values for the password check quality : </br>
+ * <ul>
+ * <li>NO_CHECK (0) : No check will be done</li>
+ * <li>CHECK_ACCEPT (1) : Check the password and accept hashed passwords</li>
+ * <li>CHECK_REJECT (2) : Check the password but reject hashed passwords</li>
+ * </ul>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum CheckQualityEnum
+{
+    /** Don't check the password */
+    NO_CHECK(0),
+
+    /** Check the password and accept passwords that can't be checked (hashed passwords)
*/
+    CHECK_ACCEPT(1),
+
+    /** Check the password but reject passwords that can't be checked (hashed passwords)
*/
+    CHECK_REJECT(2),
+
+    /** An unknown value */
+    UNKNOW(-1);
+
+    /** The stored value */
+    private int value;
+
+
+    /**
+     * Create a new instance of this enum
+     */
+    private CheckQualityEnum( int value )
+    {
+        this.value = value;
+    }
+
+
+    /**
+     * @return The internal value
+     */
+    public int getValue()
+    {
+        return value;
+    }
+
+
+    /**
+     * Get back the CheckQualityEnum instance associated with a given value
+     * 
+     * @param value The value we are looking for
+     * @return The associated CheckQualityEnum
+     */
+    public static CheckQualityEnum getCheckQuality( int value )
+    {
+        switch ( value )
+        {
+            case 0:
+                return NO_CHECK;
+
+            case 1:
+                return CHECK_ACCEPT;
+
+            case 2:
+                return CHECK_REJECT;
+
+            default:
+                return UNKNOW;
+        }
+    }
+}

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordPolicyConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordPolicyConfiguration.java?rev=1467520&r1=1467519&r2=1467520&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordPolicyConfiguration.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/PasswordPolicyConfiguration.java
Fri Apr 12 23:57:36 2013
@@ -58,9 +58,9 @@ public class PasswordPolicyConfiguration
     private int pwdInHistory = 0;
 
     /** indicates how the password quality will be verified while being modified or added.
-     *  Default value 0, do not check 
+     *  Default value NO_CHECK, do not check 
      */
-    private int pwdCheckQuality = 0;
+    private CheckQualityEnum pwdCheckQuality = CheckQualityEnum.NO_CHECK;
 
     /** this attribute holds the minimum number of characters that must be used in a password.

      *  Default value 0, no minimum length enforced
@@ -204,13 +204,16 @@ public class PasswordPolicyConfiguration
     }
 
 
-    public int getPwdCheckQuality()
+    /**
+     * @return The Password Check Quality 
+     */
+    public CheckQualityEnum getPwdCheckQuality()
     {
         return pwdCheckQuality;
     }
 
 
-    public void setPwdCheckQuality( int pwdCheckQuality )
+    public void setPwdCheckQuality( CheckQualityEnum pwdCheckQuality )
     {
         this.pwdCheckQuality = pwdCheckQuality;
     }
@@ -445,7 +448,7 @@ public class PasswordPolicyConfiguration
             sb.append( ++errCount ).append( ". password history count cannot be negative\n"
);
         }
 
-        if ( ( pwdCheckQuality < 0 ) || ( pwdCheckQuality > 2 ) )
+        if ( pwdCheckQuality == CheckQualityEnum.UNKNOW )
         {
             sb.append( ++errCount ).append( ". invalid password quality check value, valid
values are 0, 1 and 2 \n" );
         }

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=1467520&r1=1467519&r2=1467520&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
(original)
+++ directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
Fri Apr 12 23:57:36 2013
@@ -77,6 +77,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.InterceptorEnum;
 import org.apache.directory.server.core.api.LdapPrincipal;
+import org.apache.directory.server.core.api.authn.ppolicy.CheckQualityEnum;
 import org.apache.directory.server.core.api.authn.ppolicy.PasswordPolicyConfiguration;
 import org.apache.directory.server.core.api.authn.ppolicy.PasswordPolicyException;
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
@@ -1231,9 +1232,9 @@ public class AuthenticationInterceptor e
     private void check( String username, byte[] password, PasswordPolicyConfiguration policyConfig
)
         throws LdapException
     {
-        final int qualityVal = policyConfig.getPwdCheckQuality();
+        final CheckQualityEnum qualityVal = policyConfig.getPwdCheckQuality();
 
-        if ( qualityVal == 0 )
+        if ( qualityVal == CheckQualityEnum.NO_CHECK )
         {
             return;
         }
@@ -1244,7 +1245,7 @@ public class AuthenticationInterceptor e
         // pwdCheckQuality value is set to 1
         if ( secConst != null )
         {
-            if ( qualityVal == 1 )
+            if ( qualityVal == CheckQualityEnum.CHECK_ACCEPT )
             {
                 return;
             }

Modified: directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java?rev=1467520&r1=1467519&r2=1467520&view=diff
==============================================================================
--- directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
(original)
+++ directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
Fri Apr 12 23:57:36 2013
@@ -74,6 +74,7 @@ import org.apache.directory.server.const
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.InstanceLayout;
+import org.apache.directory.server.core.api.authn.ppolicy.CheckQualityEnum;
 import org.apache.directory.server.core.api.authn.ppolicy.PasswordPolicyConfiguration;
 import org.apache.directory.server.core.api.changelog.ChangeLog;
 import org.apache.directory.server.core.api.interceptor.Interceptor;
@@ -240,7 +241,7 @@ public class ServiceBuilder
 
         passwordPolicy.setPwdAllowUserChange( passwordPolicyBean.isPwdAllowUserChange() );
         passwordPolicy.setPwdAttribute( passwordPolicyBean.getPwdAttribute() );
-        passwordPolicy.setPwdCheckQuality( passwordPolicyBean.getPwdCheckQuality() );
+        passwordPolicy.setPwdCheckQuality( CheckQualityEnum.getCheckQuality( passwordPolicyBean.getPwdCheckQuality()
) );
         passwordPolicy.setPwdExpireWarning( passwordPolicyBean.getPwdExpireWarning() );
         passwordPolicy.setPwdFailureCountInterval( passwordPolicyBean.getPwdFailureCountInterval()
);
         passwordPolicy.setPwdGraceAuthNLimit( passwordPolicyBean.getPwdGraceAuthNLimit()
);



Mime
View raw message