Class PasswordChecker.Factory

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

public static final class PasswordChecker.Factory extends Object
Internal factory to create PasswordCheckers.

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

  • Method Details

    • setMinMaxLength

      public PasswordChecker.Factory setMinMaxLength(int minLength, int maxLength)
      Sets the minimum and maximum password lengths allowed.
      Parameters:
      minLength - the password minimum length
      maxLength - the password maximum length
      Returns:
      this factory
    • create

      public PasswordChecker create()
      Create a PasswordChecker according to the specified criteria.
      Returns:
      a new PasswordChecker matching the specified criteria
      Throws:
      IllegalStateException - if no character group has been specified
      IllegalStateException - if validation would be impossible because the minimum count requirements on character groups would exceed the maximum length allowed for the password
    • addCharGroup

      public PasswordChecker.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 PasswordChecker.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 PasswordChecker.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 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 PasswordChecker.Factory disallowDuplicateCharacters(boolean disallowDuplicateCharacters)
      Disallow or allow duplicates inside character groups and between character groups. Allowing duplicate is usually unnecessary and error-prone.
      Parameters:
      disallowDuplicateCharacters - true if duplicate characters should be disallowed (default), false otherwise
      Returns:
      this factory