Strong password check to consider underscore as a special character 05/1405/1
authorAlessandro Boch <aboch@cisco.com>
Tue, 24 Sep 2013 17:03:19 +0000 (10:03 -0700)
committerAlessandro Boch <aboch@cisco.com>
Tue, 24 Sep 2013 17:07:17 +0000 (10:07 -0700)
ISSUE:
Current strong password check regular expression does not consider '_' as a special character

Change-Id: Ib64fe2e94c1e6c76f24d42bd256f3e708f40d1cc
Signed-off-by: Alessandro Boch <aboch@cisco.com>
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));
     }
 }