Package org.passay

Class LengthRule

  • All Implemented Interfaces:
    Rule

    public class LengthRule
    extends Object
    implements Rule
    Rule for determining if a password is within a desired length. The minimum and maximum lengths are used inclusively to determine if a password meets this rule.
    Author:
    Middleware Services
    • Constructor Detail

      • LengthRule

        public LengthRule()
        Creates a new length rule with lengths unset. The defaults are 0 and Integer.MAX_VALUE respectively.
      • LengthRule

        public LengthRule​(int length)
        Creates a new length rule with the supplied length. Both the minimum and the maximum length will be set to this value.
        Parameters:
        length - length of password
      • LengthRule

        public LengthRule​(int minLength,
                          int maxLength)
        Create a new length rule.
        Parameters:
        minLength - minimum length of a password
        maxLength - maximum length of a password
    • Method Detail

      • setMinimumLength

        public void setMinimumLength​(int minLength)
        Sets the minimum password length.
        Parameters:
        minLength - minimum length of a password
      • getMinimumLength

        public int getMinimumLength()
        Returns the minimum password length.
        Returns:
        minimum password length
      • setMaximumLength

        public void setMaximumLength​(int maxLength)
        Sets the maximum password length.
        Parameters:
        maxLength - maximum length of a password
      • getMaximumLength

        public int getMaximumLength()
        Returns the maximum password length.
        Returns:
        maximum length of a password
      • validate

        public RuleResult validate​(PasswordData passwordData)
        Description copied from interface: Rule
        Validates the supplied password data per the requirements of this rule.
        Specified by:
        validate in interface Rule
        Parameters:
        passwordData - to verify (not null).
        Returns:
        details on password verification
      • createRuleResultDetailParameters

        protected Map<String,​Object> createRuleResultDetailParameters()
        Creates the parameter data for the rule result detail.
        Returns:
        map of parameter name to value
      • createRuleResultMetadata

        protected RuleResultMetadata createRuleResultMetadata​(PasswordData password)
        Creates the rule result metadata.
        Parameters:
        password - data used for metadata creation
        Returns:
        rule result metadata