java.lang.Object
com.irurueta.authserver.authorization.domain.password.PasswordPolicy

public final class PasswordPolicy extends Object
Password rules in the style of NIST SP 800-63B: a minimum and a maximum length, no composition rules (no required digits, symbols or upper-case letters) and a password that does not contain the username. The policy has no state, so a single instance can be shared.
  • Field Details

    • MIN_LENGTH

      public static final int MIN_LENGTH
      Minimum number of characters of a password.
      See Also:
    • MAX_LENGTH

      public static final int MAX_LENGTH
      Maximum number of characters of a password.
      See Also:
  • Constructor Details

    • PasswordPolicy

      public PasswordPolicy()
  • Method Details

    • violations

      public List<PasswordViolation> violations(String username, String password)
      Finds the rules a candidate password breaks.
      Parameters:
      username - name of the account the password is for; the username rule is skipped when it is null or blank.
      password - the candidate password; null is treated as an empty password.
      Returns:
      the broken rules, empty when the password is acceptable.
    • isValid

      public boolean isValid(String username, String password)
      Tells whether a candidate password follows every rule.
      Parameters:
      username - name of the account the password is for.
      password - the candidate password.
      Returns:
      true when no rule is broken.