- java.lang.Object
-
- rodeo.password.pgencheck.PasswordChecker.Factory
-
- Enclosing class:
- PasswordChecker
public static final class PasswordChecker.Factory extends Object
Internal factory to createPasswordCheckers.This factory class allows you to build a
PasswordCheckerusing a fluent interface. You create aFactoryby callingPasswordChecker.factory(). Once all the criteria have been specified, you call thecreatefunction to create aPasswordCheckerobject.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PasswordChecker.FactoryaddCharGroup(String charGroup)Add a group of allowed characters in the composition of the password.PasswordChecker.FactoryaddCharGroup(String charGroup, int minCount)Add a group of allowed characters in the composition of the password and specifies a minimum character count.PasswordChecker.FactoryaddCharGroup(String charGroup, int minCount, int maxCount)Add a group of allowed characters in the composition of the password and specifies a minimum and maximum character count.PasswordCheckercreate()Create aPasswordCheckeraccording to the specified criteria.PasswordChecker.FactorydisallowDuplicateCharacters(boolean disallowDuplicateCharacters)Disallow or allow duplicates inside character groups and between character groups.PasswordChecker.FactorysetMinMaxLength(int minLength, int maxLength)Sets the minimum and maximum password lengths allowed.
-
-
-
Method Detail
-
setMinMaxLength
public PasswordChecker.Factory setMinMaxLength(int minLength, int maxLength)
Sets the minimum and maximum password lengths allowed.- Parameters:
minLength- the password minimum lengthmaxLength- the password maximum length- Returns:
thisfactory
-
create
public PasswordChecker create()
Create aPasswordCheckeraccording to the specified criteria.- Returns:
- a new
PasswordCheckermatching the specified criteria - Throws:
IllegalStateException- if no character group has been specifiedIllegalStateException- if validation would be impossible because the minimum count requirements on character groups would exceed the maximum length allowed for the password
-
addCharGroup
public PasswordChecker.Factory addCharGroup(String charGroup)
Add a group of allowed characters in the composition of the password.- Parameters:
charGroup- aStringcontaining all characters allowed in this group- Returns:
thisfactory- Throws:
IllegalArgumentException- if the character group contains duplicates or if the character group contains characters already present in other character groups, unless duplicates have been explicitly allowed by callingdisallowDuplicateCharacters(false)- See Also:
disallowDuplicateCharacters(boolean)
-
addCharGroup
public PasswordChecker.Factory addCharGroup(String charGroup, int minCount)
Add a group of allowed characters in the composition of the password and specifies a minimum character count.- Parameters:
charGroup- aStringcontaining all characters allowed in this groupminCount- minimum number of characters from this group that must be present in the password- Returns:
thisfactory- Throws:
IllegalArgumentException- if the character group contains duplicates or if the character group contains characters already present in other character groups, unless duplicates have been explicitly allowed by callingdisallowDuplicateCharacters(false)IllegalArgumentException- ifminCount < 0- See Also:
disallowDuplicateCharacters(boolean)
-
addCharGroup
public PasswordChecker.Factory addCharGroup(String charGroup, int minCount, int maxCount)
Add a group of allowed characters in the composition of the password and specifies a minimum and maximum character count.- Parameters:
charGroup- aStringcontaining all characters allowed in this groupminCount- minimum number of characters from this group that must be present in the passwordmaxCount- maximum number of characters from this group allowed in the password; a value of0(zero) means "unlimited" (same as callingaddCharGroup(String, int))- Returns:
thisfactory- Throws:
IllegalArgumentException- if the character group contains duplicates or if the character group contains characters already present in other character groups, unless duplicates have been explicitly allowed by callingdisallowDuplicateCharacters(false)IllegalArgumentException- ifminCount < 0, ormaxCount < 0, ormaxCount < minCount(unlessmaxCount == 0)- See Also:
disallowDuplicateCharacters(boolean)
-
disallowDuplicateCharacters
public PasswordChecker.Factory disallowDuplicateCharacters(boolean disallowDuplicateCharacters)
Disallow or allow duplicates inside character groups and between character groups. Allowing duplicate is usually unnecessary and error-prone.- Parameters:
disallowDuplicateCharacters-trueif duplicate characters should be disallowed (default),falseotherwise- Returns:
thisfactory
-
-