@Test public void testPasswordStrengthen() { assertEquals(PasswordStrengthen.LOW, PasswordUtils.checkStrengthen(null)); assertEquals(PasswordStrengthen.LOW, PasswordUtils.checkStrengthen("")); assertEquals(PasswordStrengthen.LOW, PasswordUtils.checkStrengthen(" ")); assertEquals(PasswordStrengthen.LOW, PasswordUtils.checkStrengthen("abcd")); assertEquals(PasswordStrengthen.LOW, PasswordUtils.checkStrengthen("abcdefghij")); assertEquals(PasswordStrengthen.LOW, PasswordUtils.checkStrengthen("ABCD")); assertEquals(PasswordStrengthen.LOW, PasswordUtils.checkStrengthen("123456")); assertEquals(PasswordStrengthen.LOW, PasswordUtils.checkStrengthen("!@#$")); assertEquals(PasswordStrengthen.MEDIUM, PasswordUtils.checkStrengthen("abcdefgAB")); assertEquals(PasswordStrengthen.MEDIUM, PasswordUtils.checkStrengthen("124asdfas")); assertEquals(PasswordStrengthen.MEDIUM, PasswordUtils.checkStrengthen("SDSDKJ345234")); assertEquals(PasswordStrengthen.MEDIUM, PasswordUtils.checkStrengthen("345345@#$")); assertEquals(PasswordStrengthen.MEDIUM, PasswordUtils.checkStrengthen("sdasd&^%%")); assertEquals(PasswordStrengthen.MEDIUM, PasswordUtils.checkStrengthen("JHJD&^%$")); assertEquals(PasswordStrengthen.HIGH, PasswordUtils.checkStrengthen("asdlkj2342JHD")); assertEquals(PasswordStrengthen.HIGH, PasswordUtils.checkStrengthen("askdjfDJFD&^#@")); assertEquals(PasswordStrengthen.HIGH, PasswordUtils.checkStrengthen("23423DJHF!@#")); assertEquals(PasswordStrengthen.HIGH, PasswordUtils.checkStrengthen("skdjfsk345345$#%^")); assertEquals(PasswordStrengthen.HIGHER, PasswordUtils.checkStrengthen("asdkfj234627JDFJ@$#$")); }
public static PasswordStrengthen checkStrengthen(String password) { if (StringUtils.isBlank(password)) { return PasswordStrengthen.LOW; } int length = password.length(); int containTypes = 0; if (length > 6) { if (password.matches(".*[\\d]+.*")) { containTypes++; } if (password.matches(".*[a-z]+.*")) { containTypes++; } if (password.matches(".*[A-Z]+.*")) { containTypes++; } if (password.matches(".*[`~!@#$%^&()\\-=_+,./<>?'|{}\\[\\]\\\\]+.*")) { containTypes++; } } switch (containTypes) { case 4: return PasswordStrengthen.HIGHER; case 3: return PasswordStrengthen.HIGH; case 2: return PasswordStrengthen.MEDIUM; default: return PasswordStrengthen.LOW; } }
PasswordUtils { public static PasswordStrengthen checkStrengthen(String password) { if (StringUtils.isBlank(password)) { return PasswordStrengthen.LOW; } int length = password.length(); int containTypes = 0; if (length > 6) { if (password.matches(".*[\\d]+.*")) { containTypes++; } if (password.matches(".*[a-z]+.*")) { containTypes++; } if (password.matches(".*[A-Z]+.*")) { containTypes++; } if (password.matches(".*[`~!@#$%^&()\\-=_+,./<>?'|{}\\[\\]\\\\]+.*")) { containTypes++; } } switch (containTypes) { case 4: return PasswordStrengthen.HIGHER; case 3: return PasswordStrengthen.HIGH; case 2: return PasswordStrengthen.MEDIUM; default: return PasswordStrengthen.LOW; } } }
PasswordUtils { public static PasswordStrengthen checkStrengthen(String password) { if (StringUtils.isBlank(password)) { return PasswordStrengthen.LOW; } int length = password.length(); int containTypes = 0; if (length > 6) { if (password.matches(".*[\\d]+.*")) { containTypes++; } if (password.matches(".*[a-z]+.*")) { containTypes++; } if (password.matches(".*[A-Z]+.*")) { containTypes++; } if (password.matches(".*[`~!@#$%^&()\\-=_+,./<>?'|{}\\[\\]\\\\]+.*")) { containTypes++; } } switch (containTypes) { case 4: return PasswordStrengthen.HIGHER; case 3: return PasswordStrengthen.HIGH; case 2: return PasswordStrengthen.MEDIUM; default: return PasswordStrengthen.LOW; } } private  PasswordUtils(); }
PasswordUtils { public static PasswordStrengthen checkStrengthen(String password) { if (StringUtils.isBlank(password)) { return PasswordStrengthen.LOW; } int length = password.length(); int containTypes = 0; if (length > 6) { if (password.matches(".*[\\d]+.*")) { containTypes++; } if (password.matches(".*[a-z]+.*")) { containTypes++; } if (password.matches(".*[A-Z]+.*")) { containTypes++; } if (password.matches(".*[`~!@#$%^&()\\-=_+,./<>?'|{}\\[\\]\\\\]+.*")) { containTypes++; } } switch (containTypes) { case 4: return PasswordStrengthen.HIGHER; case 3: return PasswordStrengthen.HIGH; case 2: return PasswordStrengthen.MEDIUM; default: return PasswordStrengthen.LOW; } } private  PasswordUtils(); static PasswordStrengthen checkStrengthen(String password); }
PasswordUtils { public static PasswordStrengthen checkStrengthen(String password) { if (StringUtils.isBlank(password)) { return PasswordStrengthen.LOW; } int length = password.length(); int containTypes = 0; if (length > 6) { if (password.matches(".*[\\d]+.*")) { containTypes++; } if (password.matches(".*[a-z]+.*")) { containTypes++; } if (password.matches(".*[A-Z]+.*")) { containTypes++; } if (password.matches(".*[`~!@#$%^&()\\-=_+,./<>?'|{}\\[\\]\\\\]+.*")) { containTypes++; } } switch (containTypes) { case 4: return PasswordStrengthen.HIGHER; case 3: return PasswordStrengthen.HIGH; case 2: return PasswordStrengthen.MEDIUM; default: return PasswordStrengthen.LOW; } } private  PasswordUtils(); static PasswordStrengthen checkStrengthen(String password); static final int PASSWORD_DIGITAL; }