Interface PasswordPolicy

All Known Subinterfaces:
DigitsPasswordPolicy, LengthPasswordPolicy, LowerCasePasswordPolicy, NotCodePasswordPolicy, NotSamePasswordPolicy, PatternPasswordPolicy, ScorePasswordPolicy, SpecialCharsPasswordPolicy, UpperCasePasswordPolicy
All Known Implementing Classes:
DefaultDigitsPasswordPolicy, DefaultLengthPasswordPolicy, DefaultLowerCasePasswordPolicy, DefaultNotCodePasswordPolicy, DefaultNotSamePasswordPolicy, DefaultPatternPasswordPolicy, DefaultScorePasswordPolicy, DefaultSpecialCharsPasswordPolicy, DefaultUpperCasePasswordPolicy

public interface PasswordPolicy
Represents a single password policy rule.

Implementations should return an InvalidPolicy when the password violates the rule. Multiple policies are aggregated by AuthPasswordManager.

  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a description of this policy's requirement, suitable for display on the login or change-password page as guidance before the user submits.
    Returns the unique identifier of this policy, used to look up its configuration.
    default boolean
    Returns whether this policy is enabled by default when no explicit configuration is found.
    default boolean
    Returns whether this policy is mandatory and cannot be disabled via configuration.
    validate(User user, String password)
    Checks whether the given password satisfies this policy rule.
  • Method Details

    • getPolicyId

      String getPolicyId()
      Returns the unique identifier of this policy, used to look up its configuration. The corresponding enabled setting is user.password.<policyId>.enabled.
      Returns:
      the policy identifier
    • isEnabledByDefault

      default boolean isEnabledByDefault()
      Returns whether this policy is enabled by default when no explicit configuration is found. Policies that are opt-in should override this to return false.
      Returns:
      true if this policy is active by default
    • isMandatory

      default boolean isMandatory()
      Returns whether this policy is mandatory and cannot be disabled via configuration. Mandatory policies are always enforced regardless of the user.password.<id>.enabled setting.
      Returns:
      true if this policy cannot be disabled
    • validate

      InvalidPolicy validate(@Nullable User user, String password)
      Checks whether the given password satisfies this policy rule.
      Parameters:
      user - the user for context-aware checks, or null for new users
      password - the plain-text password to check
      Returns:
      an InvalidPolicy if the password violates this rule
    • getDescription

      @Nullable PolicyDescription getDescription()
      Returns a description of this policy's requirement, suitable for display on the login or change-password page as guidance before the user submits. This is distinct from the error message returned on violation.

      Implementations may return null when the policy has no meaningful description (e.g. a pattern policy with no pattern configured).

      Returns:
      a PolicyDescription, or null if not applicable