- java.lang.Object
-
- rodeo.password.pgencheck.PasswordMaker.Factory
-
- Enclosing class:
- PasswordMaker
public static final class PasswordMaker.Factory extends Object
Internal factory to createPasswordMakers.This factory class allows you to build a
PasswordMakerusing a fluent interface. You create aFactoryby callingPasswordMaker.factory(). Once all the criteria have been specified, you call thecreatefunction to create aPasswordMakerobject.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PasswordMaker.FactoryaddCharGroup(String charGroup)Add a group of allowed characters in the composition of the password.PasswordMaker.FactoryaddCharGroup(String charGroup, int minCount)Add a group of allowed characters in the composition of the password and specifies a minimum character count.PasswordMaker.FactoryaddCharGroup(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.PasswordMakercreate()Create aPasswordMakeraccording to the specified criteria.PasswordMaker.FactorydisallowDuplicateCharacters(boolean disallowDuplicateCharacters)Disallow or allow duplicate character groups and between character groups.PasswordMaker.FactorysetLength(int length)Sets the length of generated password.PasswordMaker.FactorysetRandomUIntGenerator(RandomUIntGenerator randomUIntGenerator)Specify the method used to generate random numbers used for password generation.
-
-
-
Method Detail
-
setLength
public PasswordMaker.Factory setLength(int length)
Sets the length of generated password.- Parameters:
length- the password length- Returns:
thisfactory
-
setRandomUIntGenerator
public PasswordMaker.Factory setRandomUIntGenerator(RandomUIntGenerator randomUIntGenerator)
Specify the method used to generate random numbers used for password generation.- Parameters:
randomUIntGenerator- an implementation of theRandomUIntGeneratorinterface- Returns:
thisfactory- See Also:
RandomUIntGenerator,DefaultUIntGenerator
-
create
public PasswordMaker create()
Create aPasswordMakeraccording to the specified criteria.- Returns:
- a new
PasswordMakermatching 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
public PasswordMaker.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 PasswordMaker.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 PasswordMaker.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 a 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 PasswordMaker.Factory disallowDuplicateCharacters(boolean disallowDuplicateCharacters)
Disallow or allow duplicate character groups and between character groups. Allowing duplicate is usually unnecessary and error-prone.- Parameters:
disallowDuplicateCharacters-trueif duplicates character should be disallowed (default),falseotherwise- Returns:
thisfactory
-
-