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