java.lang.Object
org.panteleyev.commons.password.PasswordGenerator
Implements password generation functionality.
The following characters are considered ambiguous from visual standpoint: I l O. They are excluded
by default and can be included with generate(Set, int, boolean).
Password length must be greater than 4 in order to ensure all specified character sets can be present in the generated string. There is no upper limit for password length.
Instances of this class are thread safe and can be reused.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate(Set<PasswordCharacterSet> characterSets, int length) Generates password and avoids ambiguous letters.generate(Set<PasswordCharacterSet> characterSets, int length, boolean allowAmbiguousLetters) Generates password.
-
Constructor Details
-
PasswordGenerator
public PasswordGenerator()
-
-
Method Details
-
generate
Generates password and avoids ambiguous letters.- Parameters:
characterSets- password character setslength- password length- Returns:
- password
- Throws:
IllegalArgumentException- if no character sets are selected or password length < 4
-
generate
public String generate(Set<PasswordCharacterSet> characterSets, int length, boolean allowAmbiguousLetters) Generates password.- Parameters:
characterSets- password character setslength- password lengthallowAmbiguousLetters- true if set of ambiguous letters should be included- Returns:
- password
- Throws:
IllegalArgumentException- if no character sets are selected or password length < 4
-