- java.lang.Object
-
- rodeo.password.pgencheck.PasswordMaker
-
public final class PasswordMaker extends Object
Create passwords according to predefined criteria.The following criteria are available:
- 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;
-
the way random numbers are used in password generation can be configured by implementing a
RandomUIntGenerator.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPasswordMaker.FactoryInternal factory to createPasswordMakers.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcreate()Generate a new password.static PasswordMaker.Factoryfactory()Create a factory to specify password generation criteria and create aPasswordMakerobject.StringgetAllChars()Return all characters used in generating password.StringgetCharacterGroup(int index)Return the nth character group used in creating passwords.intgetCharacterGroupCount()Returns how many character groups are used in composing passwords.List<String>getCharacterGroups()Returns a list of the character groups composing the generated passwords.intgetLength()Returns the specified length for generated passwords.intgetMaxCharactersInGroup(int index)Return the maximum number of characters from the nth character group allowed in generated passwords.intgetMinCharactersInGroup(int index)Return how many characters from the nth character group are required in generated passwords.RandomUIntGeneratorgetRandomUIntGenerator()Returns the implementation of the random number generator used to create passwords.
-
-
-
Method Detail
-
factory
public static PasswordMaker.Factory factory()
Create a factory to specify password generation criteria and create aPasswordMakerobject.- Returns:
- an internal
PasswordMakerfactory - See Also:
PasswordMaker.Factory
-
getLength
public int getLength()
Returns the specified length for generated passwords.- Returns:
- the specified length for generated passwords
-
getRandomUIntGenerator
public RandomUIntGenerator getRandomUIntGenerator()
Returns the implementation of the random number generator used to create passwords.- Returns:
- the implementation of the random number generator used to create passwords
- See Also:
RandomUIntGenerator,DefaultUIntGenerator
-
create
public String create()
Generate a new password.- Returns:
- the generated password
-
getCharacterGroups
public List<String> 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
public String getCharacterGroup(int index)
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 theindexis 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
indexrequired to form a valid password - Throws:
IndexOutOfBoundsException- if theindexis 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
indexallowed in a valid password - Throws:
IndexOutOfBoundsException- if theindexis invalid
-
getAllChars
public String getAllChars()
Return all characters used in generating password.- Returns:
- characters used in generating password
-
-