edu.vt.middleware.password
Class PasswordGenerator

java.lang.Object
  extended by edu.vt.middleware.password.PasswordGenerator

public class PasswordGenerator
extends java.lang.Object

PasswordGenerator creates passwords that meet password rule criteria.

Version:
$Revision: 1841 $
Author:
Sean C. Sullivan, Middleware Services

Constructor Summary
PasswordGenerator()
          Default constructor.
PasswordGenerator(java.util.Random r)
          Creates a new PasswordGenerator with the supplied random.
 
Method Summary
protected  void fillRandomCharacters(java.lang.CharSequence source, int count, java.lang.Appendable target)
          Fills the supplied target with count random characters from source.
 java.lang.String generatePassword(int length, java.util.List<CharacterRule> rules)
          Generates a password of the supplied length which meets the requirements of the supplied character rules.
protected  void randomize(java.nio.CharBuffer buffer)
          Randomizes the contents of the given buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswordGenerator

public PasswordGenerator()
Default constructor. Instantiates a SecureRandom for password generation.


PasswordGenerator

public PasswordGenerator(java.util.Random r)
Creates a new PasswordGenerator with the supplied random.

Parameters:
r - Random
Method Detail

generatePassword

public java.lang.String generatePassword(int length,
                                         java.util.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 - int
rules - List of rules to generate password from
Returns:
String - generated password

fillRandomCharacters

protected void fillRandomCharacters(java.lang.CharSequence source,
                                    int count,
                                    java.lang.Appendable target)
Fills the supplied target with count random characters from source.

Parameters:
source - CharSequence of random characters.
count - int number of random characters.
target - Appendable character sequence that will hold characters.

randomize

protected void randomize(java.nio.CharBuffer buffer)
Randomizes the contents of the given buffer.

Parameters:
buffer - Character buffer whose contents will be randomized.


Copyright © 2003-2011 Virginia Tech. All Rights Reserved.