Class PasswordMaker.Factory

java.lang.Object
rodeo.password.pgencheck.PasswordMaker.Factory
Enclosing class:
PasswordMaker

public static final class PasswordMaker.Factory extends Object
Internal factory to create PasswordMakers.

This factory class allows you to build a PasswordMaker using a fluent interface. You create a Factory by calling PasswordMaker.factory(). Once all the criteria have been specified, you call the create function to create a PasswordMaker object.

  • Method Details

    • setLength

      public PasswordMaker.Factory setLength(int length)
      Sets the length of generated password.
      Parameters:
      length - the password length
      Returns:
      this factory
    • setRandomUIntGenerator

      public PasswordMaker.Factory setRandomUIntGenerator(RandomUIntGenerator randomUIntGenerator)
      Specify the method used to generate random numbers used for password generation.
      Parameters:
      randomUIntGenerator - an implementation of the RandomUIntGenerator interface
      Returns:
      this factory
      See Also:
    • create

      public PasswordMaker create()
      Create a PasswordMaker according to the specified criteria.
      Returns:
      a new PasswordMaker matching the specified criteria
      Throws:
      IllegalStateException - if no character group has been specified
      IllegalStateException - if password generation would be impossible because the minimum count requirements on character groups would exceed the maximum length allowed for the password
      IllegalStateException - if password generation would be impossible because too many restrictions are placed on the maximum character count of each character group so that the specified password length could not be reached.
    • addCharGroup

      public PasswordMaker.Factory addCharGroup(String charGroup)
      Add a group of allowed characters in the composition of the password.
      Parameters:
      charGroup - a String containing all characters allowed in this group
      Returns:
      this factory
      Throws:
      IllegalArgumentException - if the character group contains duplicates or if the character group contains characters already present in other character groups, unless duplicates have been explicitly allowed by calling disallowDuplicateCharacters(false)
      See Also:
    • addCharGroup

      public PasswordMaker.Factory addCharGroup(String charGroup, int minCount)
      Add a group of allowed characters in the composition of the password and specifies a minimum character count.
      Parameters:
      charGroup - a String containing all characters allowed in this group
      minCount - minimum number of characters from this group that must be present in the password
      Returns:
      this factory
      Throws:
      IllegalArgumentException - if the character group contains duplicates or if the character group contains characters already present in other character groups, unless duplicates have been explicitly allowed by calling disallowDuplicateCharacters(false)
      IllegalArgumentException - if minCount < 0
      See Also:
    • addCharGroup

      public PasswordMaker.Factory addCharGroup(String charGroup, int minCount, int maxCount)
      Add a group of allowed characters in the composition of the password and specifies a minimum and a maximum character count.
      Parameters:
      charGroup - a String containing all characters allowed in this group
      minCount - minimum number of characters from this group that must be present in the password
      maxCount - maximum number of characters from this group allowed in the password; a value of 0 (zero) means "unlimited" (same as calling addCharGroup(String, int))
      Returns:
      this factory
      Throws:
      IllegalArgumentException - if the character group contains duplicates or if the character group contains characters already present in other character groups, unless duplicates have been explicitly allowed by calling disallowDuplicateCharacters(false)
      IllegalArgumentException - if minCount < 0, or maxCount < 0, or maxCount < minCount (unless maxCount == 0)
      See Also:
    • disallowDuplicateCharacters

      public PasswordMaker.Factory disallowDuplicateCharacters(boolean disallowDuplicateCharacters)
      Disallow or allow duplicate character groups and between character groups. Allowing duplicate is usually unnecessary and error-prone.
      Parameters:
      disallowDuplicateCharacters - true if duplicates character should be disallowed (default), false otherwise
      Returns:
      this factory