Java Doc for RandPass.java in  » Template-Engine » ostermillerutils » com » Ostermiller » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Template Engine » ostermillerutils » com.Ostermiller.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.Ostermiller.util.RandPass

RandPass
public class RandPass (Code)
Generates a random String using a cryptographically secure random number generator.

The alphabet (characters used in the passwords generated) may be specified, and the random number generator can be externally supplied.

Care should be taken when using methods that limit the types of passwords may be generated. Using an alphabet that is too small, using passwords that are too short, requiring too many of a certain type of character, or not allowing repetition, may decrease security.

More information about this class is available from ostermiller.org.
author:
   Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities
since:
   ostermillerutils 1.00.00



Field Summary
final public static  char[]LETTERS_ALPHABET
     Alphabet consisting of upper and lower case letters A-Z.
final public static  char[]LOWERCASE_LETTERS_ALPHABET
     Alphabet consisting of the lower case letters A-Z.
final public static  char[]LOWERCASE_LETTERS_AND_NUMBERS_ALPHABET
     Alphabet consisting of the lower case letters A-Z and the digits 0-9.
final public static  char[]NONCONFUSING_ALPHABET
     Alphabet consisting of upper and lower case letters A-Z and the digits 0-9 but with characters that are often mistaken for each other when typed removed.
final public static  char[]NUMBERS_AND_LETTERS_ALPHABET
     Alphabet consisting of upper and lower case letters A-Z and the digits 0-9.
final public static  char[]PRINTABLE_ALPHABET
     Alphabet consisting of all the printable ASCII characters.
final public static  char[]SYMBOLS_ALPHABET
     Alphabet consisting of all the printable ASCII symbols.
final public static  char[]UPPERCASE_LETTERS_ALPHABET
     Alphabet consisting of the upper letters A-Z.
protected  char[]alphabet
     Set of characters which may be used in the generated passwords.
protected  char[]firstAlphabet
     Set of characters which may be used for the first character in the generated passwords.
protected static  ResourceBundlelabels
     Locale specific strings displayed to the user.
protected  char[]lastAlphabet
     Set of characters which may be used for the last character in the generated passwords.
protected  SecureRandomrand
     Random number generator used.
protected  intrepetition
     One less than the maximum number of repeated characters that are allowed in a password.
final public static  Stringversion
    

Constructor Summary
public  RandPass()
     Create a new random password generator with the default secure random number generator and default NONCONFUSING alphabet for all characters.
public  RandPass(SecureRandom rand)
     Create a new random password generator with the given secure random number generator and default NONCONFUSING alphabet for all characters.
public  RandPass(char[] alphabet)
     Create a new random password generator with the default secure random number generator and given alphabet for all characters.
public  RandPass(SecureRandom rand, char[] alphabet)
     Create a new random password generator with the given secure random number generator and given alphabet for all characters.

Method Summary
public  voidaddRequirement(char[] alphabet, int num)
     Require that a certain number of characters from an alphabet be present in generated passwords.
public  voidaddVerifier(PasswordVerifier verifier)
     Add a class that will verify passwords.
public  StringgetPass(int length)
     Generate a random password of the given length.

NOTE: Strings can not be modified.

public  StringgetPass()
     Generate a random password of the default length (8).

NOTE: Strings can not be modified.

public  char[]getPassChars(char[] pass)
     Fill the given buffer with random characters.

Using this method, the password character array can easily be reused for efficiency, or overwritten with new random characters for security.

NOTE: If it is possible for a hacker to examine memory to find passwords, the password should be overwritten in memory as soon as possible after i is no longer in use.
Parameters:
  pass - buffer that will hold the password.

public  char[]getPassChars(int length)
     Generate a random password of the given length.

NOTE: If it is possible for a hacker to examine memory to find passwords, the password should be overwritten in memory as soon as possible after i is no longer in use.
Parameters:
  length - The desired length of the generated password.

public  char[]getPassChars()
     Generate a random password of the default length (8).
public static  voidmain(String[] args)
     Generate a random passwords.
public  voidsetAlphabet(char[] alphabet)
     Set the alphabet used by this random password generator.
public  voidsetFirstAlphabet(char[] alphabet)
     Set the alphabet used by this random password generator for the first character of passwords.
public  voidsetLastAlphabet(char[] alphabet)
     Set the alphabet used by this random password generator for the last character of passwords.
public  voidsetMaxRepetition(int rep)
     Set the maximum number of characters that may appear in sequence more than once in a password.
public  voidsetRandomGenerator(SecureRandom rand)
     Set the random number generator used by this random password generator.

Field Detail
LETTERS_ALPHABET
final public static char[] LETTERS_ALPHABET(Code)
Alphabet consisting of upper and lower case letters A-Z.
since:
   ostermillerutils 1.00.00



LOWERCASE_LETTERS_ALPHABET
final public static char[] LOWERCASE_LETTERS_ALPHABET(Code)
Alphabet consisting of the lower case letters A-Z.
since:
   ostermillerutils 1.00.00



LOWERCASE_LETTERS_AND_NUMBERS_ALPHABET
final public static char[] LOWERCASE_LETTERS_AND_NUMBERS_ALPHABET(Code)
Alphabet consisting of the lower case letters A-Z and the digits 0-9.
since:
   ostermillerutils 1.00.00



NONCONFUSING_ALPHABET
final public static char[] NONCONFUSING_ALPHABET(Code)
Alphabet consisting of upper and lower case letters A-Z and the digits 0-9 but with characters that are often mistaken for each other when typed removed. (I,L,O,U,V,i,l,o,u,v,0,1)
since:
   ostermillerutils 1.00.00



NUMBERS_AND_LETTERS_ALPHABET
final public static char[] NUMBERS_AND_LETTERS_ALPHABET(Code)
Alphabet consisting of upper and lower case letters A-Z and the digits 0-9.
since:
   ostermillerutils 1.00.00



PRINTABLE_ALPHABET
final public static char[] PRINTABLE_ALPHABET(Code)
Alphabet consisting of all the printable ASCII characters.
since:
   ostermillerutils 1.00.00



SYMBOLS_ALPHABET
final public static char[] SYMBOLS_ALPHABET(Code)
Alphabet consisting of all the printable ASCII symbols.
since:
   ostermillerutils 1.00.00



UPPERCASE_LETTERS_ALPHABET
final public static char[] UPPERCASE_LETTERS_ALPHABET(Code)
Alphabet consisting of the upper letters A-Z.
since:
   ostermillerutils 1.00.00



alphabet
protected char[] alphabet(Code)
Set of characters which may be used in the generated passwords.

This value may not be null or have no elements.
since:
   ostermillerutils 1.00.00




firstAlphabet
protected char[] firstAlphabet(Code)
Set of characters which may be used for the first character in the generated passwords.

This value may be null but it must have at least one element otherwise.
since:
   ostermillerutils 1.00.00




labels
protected static ResourceBundle labels(Code)
Locale specific strings displayed to the user.
since:
   ostermillerutils 1.00.00



lastAlphabet
protected char[] lastAlphabet(Code)
Set of characters which may be used for the last character in the generated passwords.

This value may be null but it must have at least one element otherwise.
since:
   ostermillerutils 1.00.00




rand
protected SecureRandom rand(Code)
Random number generator used.
since:
   ostermillerutils 1.00.00



repetition
protected int repetition(Code)
One less than the maximum number of repeated characters that are allowed in a password. Set to -1 to disable this feature.
since:
   ostermillerutils 1.00.00



version
final public static String version(Code)
Version number of this program
since:
   ostermillerutils 1.00.00




Constructor Detail
RandPass
public RandPass()(Code)
Create a new random password generator with the default secure random number generator and default NONCONFUSING alphabet for all characters.
since:
   ostermillerutils 1.00.00



RandPass
public RandPass(SecureRandom rand)(Code)
Create a new random password generator with the given secure random number generator and default NONCONFUSING alphabet for all characters.
Parameters:
  rand - Secure random number generator to use when generating passwords.
since:
   ostermillerutils 1.00.00



RandPass
public RandPass(char[] alphabet)(Code)
Create a new random password generator with the default secure random number generator and given alphabet for all characters.
Parameters:
  alphabet - Characters allowed in generated passwords.
since:
   ostermillerutils 1.00.00



RandPass
public RandPass(SecureRandom rand, char[] alphabet)(Code)
Create a new random password generator with the given secure random number generator and given alphabet for all characters.
Parameters:
  rand - Secure random number generator to use when generating passwords.
Parameters:
  alphabet - Characters allowed in generated passwords.
since:
   ostermillerutils 1.00.00




Method Detail
addRequirement
public void addRequirement(char[] alphabet, int num)(Code)
Require that a certain number of characters from an alphabet be present in generated passwords.
Parameters:
  alphabet - set of letters that must be present
Parameters:
  num - number of letters from the alphabet that must be present.
since:
   ostermillerutils 1.00.00



addVerifier
public void addVerifier(PasswordVerifier verifier)(Code)
Add a class that will verify passwords. No password will be returned unless all verifiers approve of it.
Parameters:
  verifier - class that performs verification of password.
since:
   ostermillerutils 1.00.00



getPass
public String getPass(int length)(Code)
Generate a random password of the given length.

NOTE: Strings can not be modified. If it is possible for a hacker to examine memory to find passwords, getPassChars() should be used so that the password can be zeroed out of memory when no longer in use.
Parameters:
  length - The desired length of the generated password. a random password
See Also:   RandPass.getPassChars(int)
since:
   ostermillerutils 1.00.00




getPass
public String getPass()(Code)
Generate a random password of the default length (8).

NOTE: Strings can not be modified. If it is possible for a hacker to examine memory to find passwords, getPassChars() should be used so that the password can be zeroed out of memory when no longer in use. a random password
See Also:   RandPass.getPassChars()
since:
   ostermillerutils 1.00.00




getPassChars
public char[] getPassChars(char[] pass)(Code)
Fill the given buffer with random characters.

Using this method, the password character array can easily be reused for efficiency, or overwritten with new random characters for security.

NOTE: If it is possible for a hacker to examine memory to find passwords, the password should be overwritten in memory as soon as possible after i is no longer in use.
Parameters:
  pass - buffer that will hold the password. the buffer, filled with random characters.
since:
   ostermillerutils 1.00.00




getPassChars
public char[] getPassChars(int length)(Code)
Generate a random password of the given length.

NOTE: If it is possible for a hacker to examine memory to find passwords, the password should be overwritten in memory as soon as possible after i is no longer in use.
Parameters:
  length - The desired length of the generated password. a random password
since:
   ostermillerutils 1.00.00




getPassChars
public char[] getPassChars()(Code)
Generate a random password of the default length (8).

NOTE: If it is possible for a hacker to examine memory to find passwords, the password should be overwritten in memory as soon as possible after i is no longer in use. a random password
since:
   ostermillerutils 1.00.00




main
public static void main(String[] args) throws Exception(Code)
Generate a random passwords. Run with --help argument for more information.
Parameters:
  args - Command line arguments.
throws:
  Exception - errors
since:
   ostermillerutils 1.00.00



setAlphabet
public void setAlphabet(char[] alphabet)(Code)
Set the alphabet used by this random password generator.
Parameters:
  alphabet - Characters allowed in generated passwords.
throws:
  NullPointerException - if the alphabet is null.
throws:
  ArrayIndexOutOfBoundsException - if the alphabet has no elements.
since:
   ostermillerutils 1.00.00



setFirstAlphabet
public void setFirstAlphabet(char[] alphabet)(Code)
Set the alphabet used by this random password generator for the first character of passwords.

If the alphabet for the first character is set to null or has no elements, the main alphabet will be used for the first character.
Parameters:
  alphabet - Characters allowed for the first character of the passwords.
since:
   ostermillerutils 1.00.00




setLastAlphabet
public void setLastAlphabet(char[] alphabet)(Code)
Set the alphabet used by this random password generator for the last character of passwords.

If the alphabet for the last character is set to null or has no elements, the main alphabet will be used for the last character.
Parameters:
  alphabet - Characters allowed for the last character of the passwords.
since:
   ostermillerutils 1.00.00




setMaxRepetition
public void setMaxRepetition(int rep)(Code)
Set the maximum number of characters that may appear in sequence more than once in a password. Your alphabet must be large enough to handle this option. If your alphabet is {'a', 'b'} and you want 8 character passwords in which no character appears twice (repetition 1) you are out of luck. In such instances your request for no repetition will be ignored.

For example setRepetition(3) will allow a password ababab but not allow abcabc.

Using this method can greatly reduce the pool of passwords that are generated. For example if only one repetition is allowed then the pool of passwords is the permutation of the alphabet rather than the combination.
Parameters:
  rep - Maximum character repetition.
since:
   ostermillerutils 1.00.00




setRandomGenerator
public void setRandomGenerator(SecureRandom rand)(Code)
Set the random number generator used by this random password generator.
Parameters:
  rand - Secure random number generator to use when generating passwords.
since:
   ostermillerutils 1.00.00



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.