Merge "Strong password check to consider underscore as a special character"
authorGiovanni Meo <gmeo@cisco.com>
Wed, 25 Sep 2013 10:03:18 +0000 (10:03 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 25 Sep 2013 10:03:18 +0000 (10:03 +0000)
opendaylight/usermanager/api/src/main/java/org/opendaylight/controller/usermanager/UserConfig.java
opendaylight/usermanager/api/src/test/java/org/opendaylight/controller/usermanager/AuthorizationUserConfigTest.java

index 07c814adf14c7b2d35f9991a9bd3e5875296f922..2e03db16558ad61ad90b428fb9fd76116682a074 100644 (file)
@@ -38,7 +38,7 @@ public class UserConfig implements Serializable {
     private static final boolean strongPasswordCheck = Boolean.getBoolean("enableStrongPasswordCheck");
     private static final String BAD_PASSWORD = "Bad Password";
     private static final int USERNAME_MAXLENGTH = 32;
-    protected static final String PASSWORD_REGEX = "(?=.*[^\\w])(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,256}$";
+    protected static final String PASSWORD_REGEX = "(?=.*[^a-zA-Z0-9])(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,256}$";
     private static final Pattern INVALID_USERNAME_CHARACTERS = Pattern.compile("([/\\s\\.\\?#%;\\\\]+)");
     private static MessageDigest oneWayFunction = null;
     static {
index 8c029a7488361b778b2749fe327a48a812d675c0..4c377271dc1c9098ac46248513f10b4191b631b2 100644 (file)
@@ -153,5 +153,9 @@ public class AuthorizationUserConfigTest {
         // No special characters
         password = "aBc4ef7H8";
         assertFalse(password.matches(regex));
+
+        // Underscore is a special character
+        password = "Azmb_123 ";
+        assertTrue(password.matches(regex));
     }
 }