Package org.jclouds.util
Class PasswordGenerator
- java.lang.Object
-
- org.jclouds.util.PasswordGenerator
-
public class PasswordGenerator extends Object
Generates random passwords.This class allows to configure the password requirements for:
- Number of upper case and lower case letters
- Inclusion of numbers
- Inclusion of special characters
It also allows to configure forbidden characters to accommodate the password requirements for the different clouds.
Example usage:
String password = new PasswordGenerator() .lower().count(3) // Exactly three lower case characters .upper().count(2) // Exactly 2 upper case characters .numbers().min(5).exclude("012345".toCharArray()) // At least five numbers, from 6 to 9. .symbols().min(6).max(10) // Between 6 and 10 special characters .generate();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
PasswordGenerator.Config
-
Constructor Summary
Constructors Constructor Description PasswordGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
generate()
Generates a random password using the configured spec.PasswordGenerator.Config
lower()
Returns the lower case configuration.PasswordGenerator.Config
numbers()
Returns the numbers configuration.PasswordGenerator.Config
symbols()
Returns the special character configuration.PasswordGenerator.Config
upper()
Returns the upper case configuration.
-
-
-
Method Detail
-
lower
public PasswordGenerator.Config lower()
Returns the lower case configuration. Allows to configure the presence of lower case characters.
-
upper
public PasswordGenerator.Config upper()
Returns the upper case configuration. Allows to configure the presence of upper case characters.
-
numbers
public PasswordGenerator.Config numbers()
Returns the numbers configuration. Allows to configure the presence of numeric characters.
-
symbols
public PasswordGenerator.Config symbols()
Returns the special character configuration. Allows to configure the presence of special characters.
-
generate
public String generate()
Generates a random password using the configured spec.
-
-