java.util.function.Predicate<char[]>, PasswordStrengthPolicypublic class CharacterClassesPasswordStrengthPolicy extends java.lang.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 | 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 PasswordStrengthPolicytest in interface java.util.function.Predicate<char[]>public CharacterClassesPasswordStrengthPolicy withMinDigits(int minDigits)
public CharacterClassesPasswordStrengthPolicy withMinLength(int minLength)
public CharacterClassesPasswordStrengthPolicy withMinLowerCaseLetters(int minLowerCaseLetters)
public CharacterClassesPasswordStrengthPolicy withMinOtherChars(int minOtherChars)
public CharacterClassesPasswordStrengthPolicy withMinSpecialChars(int minSpecialChars)
public CharacterClassesPasswordStrengthPolicy withMinUpperCaseLetters(int minUpperCaseLetters)