|
|
@ -14,6 +14,7 @@ public class PasswordValidator { |
|
|
|
boolean requireDigit = true; |
|
|
|
boolean requireSpecialChar = true; |
|
|
|
boolean checkPwned = true; |
|
|
|
boolean checkWordlist = false; |
|
|
|
|
|
|
|
private final Pattern uppercasePattern = Pattern.compile("^(?=.*[A-Z]).+$"); |
|
|
|
private final Pattern lowercasePattern = Pattern.compile("^(?=.*[a-z]).+$"); |
|
|
@ -32,6 +33,8 @@ public class PasswordValidator { |
|
|
|
return false; |
|
|
|
} else if (requireSpecialChar && !specialCharPattern.matcher(password).matches()) { |
|
|
|
return false; |
|
|
|
} else if (checkWordlist && isInWordlist(password)) { |
|
|
|
return false; |
|
|
|
} else if (checkPwned && isPwned(password)) { |
|
|
|
return false; |
|
|
|
} |
|
|
@ -86,6 +89,14 @@ public class PasswordValidator { |
|
|
|
this.checkPwned = checkPwned; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isCheckWordlist() { |
|
|
|
return checkWordlist; |
|
|
|
} |
|
|
|
|
|
|
|
public void setCheckWordlist(boolean checkWordlist) { |
|
|
|
this.checkWordlist = checkWordlist; |
|
|
|
} |
|
|
|
|
|
|
|
public static String getSHA1Hash(String input) { |
|
|
|
if (input.length() > 0) { |
|
|
|
try { |
|
|
|