Package org.passay

Class UsernameRule

  • All Implemented Interfaces:
    Rule

    public class UsernameRule
    extends Object
    implements Rule
    Rule for determining if a password contains the username associated with that password. This rule returns true if a supplied PasswordData returns a null or empty username.
    Author:
    Middleware Services
    • Constructor Detail

      • UsernameRule

        public UsernameRule()
        Default constructor.
      • UsernameRule

        public UsernameRule​(MatchBehavior behavior)
        Create a new username rule.
        Parameters:
        behavior - how to match username
      • UsernameRule

        public UsernameRule​(boolean mb,
                            boolean ic)
        Create a new username rule.
        Parameters:
        mb - whether to match backwards
        ic - whether to ignore case
      • UsernameRule

        public UsernameRule​(boolean mb,
                            boolean ic,
                            MatchBehavior behavior)
        Create a new username rule.
        Parameters:
        mb - whether to match backwards
        ic - whether to ignore case
        behavior - how to match username
    • Method Detail

      • setMatchBackwards

        public void setMatchBackwards​(boolean b)
        Sets whether the verify method will search the password for the username spelled backwards as well as forwards.
        Parameters:
        b - whether to match username backwards
      • isMatchBackwards

        public boolean isMatchBackwards()
        Returns whether to match the username backwards.
        Returns:
        whether to match username backwards
      • setIgnoreCase

        public void setIgnoreCase​(boolean b)
        Sets whether the verify method will ignore case when searching the for a username.
        Parameters:
        b - whether to ignore case
      • isIgnoreCase

        public boolean isIgnoreCase()
        Returns whether to ignore the case of the username.
        Returns:
        whether to ignore case
      • 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​(String username)
        Creates the parameter data for the rule result detail.
        Parameters:
        username - matching username
        Returns:
        map of parameter name to value