org.sandev.sandbuild
Class PassGen

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.sandev.sandbuild.SandTask
              extended by org.sandev.sandbuild.PassGen

public class PassGen
extends SandTask

Sets the defined property to be a random password of the given length. The password starts with a letter, followed by letters, numbers or special characters.


Field Summary
protected  int length
          The length of the generated password.
protected  java.lang.String name
          The name of the property to set with a random password value.
protected  java.lang.String okEscapes
          Characters between ascii 33 and and ascii 126, other than letters or numbers, which can be included in the resulting password.
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
PassGen()
           
 
Method Summary
 void execute()
          Set the specified property to the random password value.
 int getLength()
           
 java.lang.String getName()
           
 java.lang.String getOkEscapes()
           
protected  char getRandomChar(java.util.Random random)
          Return the next random character from the sequence generator.
 void setLength(int val)
           
 void setName(java.lang.String val)
           
 void setOkEscapes(java.lang.String val)
           
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name of the property to set with a random password value.


length

protected int length
The length of the generated password. Defaults to 10.


okEscapes

protected java.lang.String okEscapes
Characters between ascii 33 and and ascii 126, other than letters or numbers, which can be included in the resulting password. Defaults to just "_" since anything other than that can be a problem as a java identifier or database index value.

Constructor Detail

PassGen

public PassGen()
Method Detail

setName

public void setName(java.lang.String val)

getName

public java.lang.String getName()

setLength

public void setLength(int val)

getLength

public int getLength()

setOkEscapes

public void setOkEscapes(java.lang.String val)

getOkEscapes

public java.lang.String getOkEscapes()

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Set the specified property to the random password value.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

getRandomChar

protected char getRandomChar(java.util.Random random)
Return the next random character from the sequence generator. What we want is to get an ascii value between 33 (exclamation point, 32 is a space char which is not useful) and 126 (tilde, 127 is the DEL character which is not useful). This inclusive range encompasses all the upper and lower case letters, numbers, and punctuation characters. If the resulting character is in badChars, then we repeat the process to get something acceptable.