public class ConfigurablePasswordPolicy extends Object implements PasswordPolicy
PasswordPolicy
using a PasswordValidator
.configurablePasswordPolicy
can be used for configuration, defaults as
shown:
minLowerCase = 1 minUppercase = 1 minDigits = 1 minSpecialChars = 1 allowedSpecialChars = !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ minLength = 8 maxLength = 255 useHistory = true useUsername = true numCharacterGroups = 4 allowOtherCharacters = false allowWhiteSpace = false generateLength = 8 generateLowerCase = 3 generateUppercase = 3 generateDigits = 1 generateSpecialChars = 1
PasswordPolicy.ValidationResult
LOWERCASE, NUMBER, PUNCT, UPPERCASE
Constructor and Description |
---|
ConfigurablePasswordPolicy() |
Modifier and Type | Method and Description |
---|---|
void |
configure(Properties platformProperties)
Configures the
PasswordPolicy |
String |
generatePassword()
Generates a new random password that matches the requirements and returns it.
|
String |
getErrorMessageKey()
Returns the message-key of an errormessage for the case that the password doesn't match the requirements.
|
org.passay.PasswordValidator |
getValidator() |
boolean |
isValidPassword(char[] password)
Checks whether the given character-sequence is a valid password.
|
PasswordPolicy.ValidationResult |
validatePassword(String username,
char[] currentPassword,
char[] password)
Validates the password an returns a
PasswordPolicy.ValidationResult |
public void configure(Properties platformProperties)
PasswordPolicy
PasswordPolicy
configure
in interface PasswordPolicy
platformProperties
- the platform's Properties
public boolean isValidPassword(char[] password)
PasswordPolicy
isValidPassword
in interface PasswordPolicy
password
- the character-sequence sequence to checktrue
if the character-sequence is a valid password, false
otherwisepublic PasswordPolicy.ValidationResult validatePassword(String username, char[] currentPassword, char[] password)
PasswordPolicy
PasswordPolicy.ValidationResult
validatePassword
in interface PasswordPolicy
username
- the username (can be null
)currentPassword
- the current password (can be null
)password
- the new password (must not be null
)public String getErrorMessageKey()
PasswordPolicy
getErrorMessageKey
in interface PasswordPolicy
public String generatePassword()
PasswordPolicy
generatePassword
in interface PasswordPolicy
public org.passay.PasswordValidator getValidator()
Copyright © 2011–2023 aiticon GmbH. All rights reserved.