org.davesag.generica.util
Class PasswordGenerator

java.lang.Object
  extended byorg.davesag.generica.util.PasswordGenerator

public class PasswordGenerator
extends Object

Generates a single use 'random' password based on concatenating a verb and a noun and then transliterating some letters to numbers at random. This is quite suitable for emailing a new password to a user who has forgotten their password, and then requiring that they change their password.

Since:
Generica 1.0
Version:
CVS Revision $Id: PasswordGenerator.java,v 1.8 2004/03/30 13:00:43 davesag Exp $
Author:
Dave Sag http://www.davesag.com

Field Summary
protected static PasswordGenerator THE_PASS_GEN
          the singleton password generator
protected static Random THE_RANDOM
          the random number generator
protected  String[] theNouns
          an array of nouns
protected  String[] theVerbs
          an array of verbs
 
Constructor Summary
protected PasswordGenerator()
          Null constructor.
 
Method Summary
static String[] buildWordArray(MessageResources messages, String name)
          Builds an array of words from a supplied resource and name.
 String generatePassword()
          Generates a randowm password based on concatanation of a verb, a noun, some numbers and so forth.
static PasswordGenerator getPasswordGenerator()
          Gets the default passwrod generator.
static PasswordGenerator getPasswordGenerator(String resource)
          Gets a password generator if one has not already been made, using the resources in the path supplied.
 Random getRandom()
          gets the singleton Random number generator if it exists, or seeds and makes one if not.
 void setNouns(String[] nouns)
          sets the array of nouns.
 void setVerbs(String[] verbs)
          sets the array of verbs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THE_PASS_GEN

protected static PasswordGenerator THE_PASS_GEN
the singleton password generator


THE_RANDOM

protected static Random THE_RANDOM
the random number generator


theVerbs

protected String[] theVerbs
an array of verbs


theNouns

protected String[] theNouns
an array of nouns

Constructor Detail

PasswordGenerator

protected PasswordGenerator()
Null constructor. Protected because it is a singleton. Use getPasswordGenerator to return an instance of this.

Method Detail

getPasswordGenerator

public static PasswordGenerator getPasswordGenerator()
Gets the default passwrod generator.

Returns:
the default password generator.

getPasswordGenerator

public static PasswordGenerator getPasswordGenerator(String resource)
Gets a password generator if one has not already been made, using the resources in the path supplied.

Parameters:
resource - The fully qualified path to a resource file.
Returns:
The password generator.

setVerbs

public void setVerbs(String[] verbs)
sets the array of verbs.

Parameters:
verbs - The array of verbs.

setNouns

public void setNouns(String[] nouns)
sets the array of nouns.

Parameters:
nouns - The array of nouns.

getRandom

public Random getRandom()
gets the singleton Random number generator if it exists, or seeds and makes one if not.

Returns:
A Random number generator.

generatePassword

public String generatePassword()
Generates a randowm password based on concatanation of a verb, a noun, some numbers and so forth.

Returns:
A shiny new password.

buildWordArray

public static String[] buildWordArray(MessageResources messages,
                                      String name)
Builds an array of words from a supplied resource and name.

Parameters:
messages - The resource file with the words in it.
name - The name of the comma delimited list of words to use.
Returns:
An array of words.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.