java.lang.Object
rodeo.password.pgencheck.PasswordMaker.Factory
- Enclosing class:
- PasswordMaker
Internal factory to create
PasswordMaker
s.
This factory class allows you to build a PasswordMaker
using a fluent interface. You create a
Factory
by calling PasswordMaker.factory()
.
Once all the criteria have been specified, you call the create
function
to create a PasswordMaker
object.
-
Method Summary
Modifier and TypeMethodDescriptionaddCharGroup
(String charGroup) Add a group of allowed characters in the composition of the password.addCharGroup
(String charGroup, int minCount) Add a group of allowed characters in the composition of the password and specifies a minimum character count.addCharGroup
(String charGroup, int minCount, int maxCount) Add a group of allowed characters in the composition of the password and specifies a minimum and a maximum character count.create()
Create aPasswordMaker
according to the specified criteria.disallowDuplicateCharacters
(boolean disallowDuplicateCharacters) Disallow or allow duplicate character groups and between character groups.setLength
(int length) Sets the length of generated password.setRandomUIntGenerator
(RandomUIntGenerator randomUIntGenerator) Specify the method used to generate random numbers used for password generation.
-
Method Details
-
setLength
Sets the length of generated password.- Parameters:
length
- the password length- Returns:
this
factory
-
setRandomUIntGenerator
Specify the method used to generate random numbers used for password generation.- Parameters:
randomUIntGenerator
- an implementation of theRandomUIntGenerator
interface- Returns:
this
factory- See Also:
-
create
Create aPasswordMaker
according to the specified criteria.- Returns:
- a new
PasswordMaker
matching the specified criteria - Throws:
IllegalStateException
- if no character group has been specifiedIllegalStateException
- if password generation would be impossible because the minimum count requirements on character groups would exceed the maximum length allowed for the passwordIllegalStateException
- if password generation would be impossible because too many restrictions are placed on the maximum character count of each character group so that the specified password length could not be reached.
-
addCharGroup
Add a group of allowed characters in the composition of the password.- Parameters:
charGroup
- aString
containing all characters allowed in this group- Returns:
this
factory- 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:
-
addCharGroup
Add a group of allowed characters in the composition of the password and specifies a minimum character count.- Parameters:
charGroup
- aString
containing all characters allowed in this groupminCount
- minimum number of characters from this group that must be present in the password- Returns:
this
factory- 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:
-
addCharGroup
Add a group of allowed characters in the composition of the password and specifies a minimum and a maximum character count.- Parameters:
charGroup
- aString
containing 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:
this
factory- 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
Disallow or allow duplicate character groups and between character groups. Allowing duplicate is usually unnecessary and error-prone.- Parameters:
disallowDuplicateCharacters
-true
if duplicates character should be disallowed (default),false
otherwise- Returns:
this
factory
-