Package org.passay
Class PasswordGenerator
- java.lang.Object
-
- org.passay.PasswordGenerator
-
public class PasswordGenerator extends Object
Creates passwords that meet password character rule criteria.- Author:
- Sean C. Sullivan, Middleware Services
-
-
Constructor Summary
Constructors Constructor Description PasswordGenerator()
Default constructor.PasswordGenerator(Random r)
Creates a new password generator with the supplied random.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
fillRandomCharacters(CharSequence source, int count, Appendable target)
Fills the supplied target with count random characters from source.String
generatePassword(int length, List<CharacterRule> rules)
Generates a password of the supplied length which meets the requirements of the supplied character rules.String
generatePassword(int length, CharacterRule... rules)
protected void
randomize(CharBuffer buffer)
Randomizes the contents of the given buffer.
-
-
-
Constructor Detail
-
PasswordGenerator
public PasswordGenerator()
Default constructor. Instantiates a secure random for password generation.
-
PasswordGenerator
public PasswordGenerator(Random r)
Creates a new password generator with the supplied random.- Parameters:
r
- random
-
-
Method Detail
-
generatePassword
public String generatePassword(int length, CharacterRule... rules)
- Parameters:
length
- of password to generaterules
- to generate compliant password from- Returns:
- generated password
-
generatePassword
public String generatePassword(int length, List<CharacterRule> rules)
Generates a password of the supplied length which meets the requirements of the supplied character rules. For length to be evaluated it must be greater than the number of characters defined in the character rule.- Parameters:
length
- of password to generaterules
- to generate compliant password from- Returns:
- generated password
-
fillRandomCharacters
protected void fillRandomCharacters(CharSequence source, int count, Appendable target)
Fills the supplied target with count random characters from source.- Parameters:
source
- of random characters.count
- number of random characters.target
- character sequence that will hold characters.
-
randomize
protected void randomize(CharBuffer buffer)
Randomizes the contents of the given buffer.- Parameters:
buffer
- character buffer whose contents will be randomized.
-
-