public class CharacterClassesPasswordStrengthPolicy extends Object implements PasswordStrengthPolicy
CharacterClassesPasswordStrengthPolicy policy = CharacterClassesPasswordStrengthPolicy.create()
.withMinLength(8)
.withMinUpperCaseLetters(2)
.withMinLowerCaseLetters(2)
.withMinDigits(1)
.withMinSpecialChars(1);
if (!policy.test(password)) {
// Reject password
}
| Modifier and Type | Method and Description |
|---|---|
CharacterClassesPasswordStrengthPolicy |
create()
Returns an empty character classes password policy.
|
boolean |
test(char[] password)
Test whether the given password satisfies this strength policy.
|
CharacterClassesPasswordStrengthPolicy |
withMinDigits(int minDigits)
Sets the minimum number of digits of this policy.
|
CharacterClassesPasswordStrengthPolicy |
withMinLength(int minLength)
Sets the minimum length of this policy.
|
CharacterClassesPasswordStrengthPolicy |
withMinLowerCaseLetters(int minLowerCaseLetters)
Sets the minimum number of lower-case letters of this policy.
|
CharacterClassesPasswordStrengthPolicy |
withMinOtherChars(int minOtherChars)
Sets the minimum number of other characters of this policy.
|
CharacterClassesPasswordStrengthPolicy |
withMinSpecialChars(int minSpecialChars)
Sets the minimum number of special characters of this policy.
|
CharacterClassesPasswordStrengthPolicy |
withMinUpperCaseLetters(int minUpperCaseLetters)
Sets the minimum number of upper-case letters of this policy.
|
public CharacterClassesPasswordStrengthPolicy create()
public boolean test(char[] password)
PasswordStrengthPolicytest in interface Predicate<char[]>test in interface PasswordStrengthPolicypublic CharacterClassesPasswordStrengthPolicy withMinDigits(int minDigits)
new - IllegalArgumentException if minDigits is negativepublic CharacterClassesPasswordStrengthPolicy withMinLength(int minLength)
new - IllegalArgumentException if minLength is negativepublic CharacterClassesPasswordStrengthPolicy withMinLowerCaseLetters(int minLowerCaseLetters)
new - IllegalArgumentException if minLowerCaseLetters is negativepublic CharacterClassesPasswordStrengthPolicy withMinOtherChars(int minOtherChars)
new - IllegalArgumentException if minOtherChars is negativepublic CharacterClassesPasswordStrengthPolicy withMinSpecialChars(int minSpecialChars)
new - IllegalArgumentException if minSpecialChars is negativepublic CharacterClassesPasswordStrengthPolicy withMinUpperCaseLetters(int minUpperCaseLetters)
new - IllegalArgumentException if minUpperCaseLetters is negative