java.lang.Object
rodeo.password.pgencheck.PasswordChecker
Validate passwords according to predefined criteria.
The following criteria are available:
- minimum length;
- maximum length;
-
constraints on characters composing the password:
- character must belong to a predefined group of characters;
- minimum and maximum number of characters per group can be specified.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Internal factory to createPasswordChecker
s. -
Method Summary
Modifier and TypeMethodDescriptionCheck if a password can be validated against the specified criteria and return the first error encountered if any orPasswordCheckStatus.OK
otherwise.static PasswordChecker.Factory
factory()
Create a factory to specify password validation criteria and create aPasswordChecker
object.Check if a password can be validated against the specified criteria and return a list of all the problems encountered.Return all characters used in generating password.getCharacterGroup
(int index) Return the nth character group used in creating passwords.int
Returns how many character groups are used in composing passwords.Returns a list of the character groups composing the generated passwords.int
getMaxCharactersInGroup
(int index) Return the maximum number of characters from the nth character group allowed in generated passwords.int
Get the maximum length required for a password to be accepted.int
getMinCharactersInGroup
(int index) Return how many characters from the nth character group are required in generated passwords.int
Get the minimum length required for a password to be accepted.boolean
quickCheck
(String password) Check if a password can be validated against the specified criteria and returntrue
if that's the case.
-
Method Details
-
factory
Create a factory to specify password validation criteria and create aPasswordChecker
object.- Returns:
- an internal
PasswordChecker
factory - See Also:
-
getMinLength
public int getMinLength()Get the minimum length required for a password to be accepted.- Returns:
- the minimum length required for a password to be accepted
-
getMaxLength
public int getMaxLength()Get the maximum length required for a password to be accepted.- Returns:
- the maximum length required for a password to be accepted
-
quickCheck
Check if a password can be validated against the specified criteria and returntrue
if that's the case.- Parameters:
password
- to be validated- Returns:
true
ifpassword
matches the criteria, false otherwise
-
check
Check if a password can be validated against the specified criteria and return the first error encountered if any orPasswordCheckStatus.OK
otherwise.Criteria are checked in this order:
- minimum length of password;
- maximum length of password;
- illegal characters;
- not enough characters from a certain group;
- too many characters form a certain group.
- Parameters:
password
- to be validated- Returns:
PasswordCheckStatus.OK
ifpassword
matches the criteria, otherwise a code for the first error encountered- See Also:
-
fullCheck
Check if a password can be validated against the specified criteria and return a list of all the problems encountered. This list is empty if there is no error.- Parameters:
password
- to be validated- Returns:
- a list of all the errors encountered while validating the password or an empty list if the
password
matches all the criteria - See Also:
-
getCharacterGroups
Returns a list of the character groups composing the generated passwords.- Returns:
- the character groups
-
getCharacterGroupCount
public int getCharacterGroupCount()Returns how many character groups are used in composing passwords.- Returns:
- character group count
-
getCharacterGroup
Return the nth character group used in creating passwords. Character groups are referenced in the order they are added to the factory. The first index is0
(zero).- Parameters:
index
- of the character group to retrieve- Returns:
- the character group at the
index
- Throws:
IndexOutOfBoundsException
- if theindex
is invalid
-
getMinCharactersInGroup
public int getMinCharactersInGroup(int index) Return how many characters from the nth character group are required in generated passwords. Character groups are referenced in the order they were added to the factory. The first index is0
(zero).- Parameters:
index
- of the character group minimum count to retrieve- Returns:
- the minimum number of characters from the group at the
index
required to form a valid password - Throws:
IndexOutOfBoundsException
- if theindex
is invalid
-
getMaxCharactersInGroup
public int getMaxCharactersInGroup(int index) Return the maximum number of characters from the nth character group allowed in generated passwords. Character groups are referenced in the order they were added to the factory. The first index is0
(zero).- Parameters:
index
- of the character group maximum count to retrieve- Returns:
- the maximum number of characters from the group at the
index
allowed in a valid password - Throws:
IndexOutOfBoundsException
- if theindex
is invalid
-
getAllChars
Return all characters used in generating password.- Returns:
- characters used in generating password
-