Class AllowedCharacterRule

java.lang.Object
org.passay.rule.AllowedCharacterRule
All Implemented Interfaces:
Rule

public class AllowedCharacterRule extends Object implements Rule
Rule for determining if a password contains allowed characters. Validation will fail unless the password contains only allowed characters.
  • Field Details

    • ERROR_CODE

      public static final String ERROR_CODE
      Error code for allowed character failures.
      See Also:
    • reportAllFailures

      protected final boolean reportAllFailures
      Whether to report all sequence matches or just the first.
    • allowedCharacters

      private final int[] allowedCharacters
      Stores the character code points that are allowed.
    • matchBehavior

      private final MatchBehavior matchBehavior
      Where to match whitespace.
  • Constructor Details

    • AllowedCharacterRule

      public AllowedCharacterRule(UnicodeString unicodeString)
      Create a new allowed character rule.
      Parameters:
      unicodeString - allowed characters
    • AllowedCharacterRule

      public AllowedCharacterRule(UnicodeString unicodeString, MatchBehavior behavior)
      Create a new allowed character rule.
      Parameters:
      unicodeString - allowed characters
      behavior - how to match allowed characters
    • AllowedCharacterRule

      public AllowedCharacterRule(UnicodeString unicodeString, boolean reportAll)
      Create a new allowed character rule.
      Parameters:
      unicodeString - allowed characters
      reportAll - whether to report all matches or just the first
    • AllowedCharacterRule

      public AllowedCharacterRule(UnicodeString unicodeString, MatchBehavior behavior, boolean reportAll)
      Create a new allowed character rule.
      Parameters:
      unicodeString - allowed characters
      behavior - how to match allowed characters
      reportAll - whether to report all matches or just the first
  • Method Details

    • getReportAllFailures

      public boolean getReportAllFailures()
      Returns whether to report all matches or just the first.
      Returns:
      whether to report all matches or just the first
    • getAllowedCharacters

      public UnicodeString getAllowedCharacters()
      Returns the allowed characters for this rule.
      Returns:
      allowed character code points
    • getMatchBehavior

      public MatchBehavior getMatchBehavior()
      Returns the match behavior for this rule.
      Returns:
      match behavior
    • 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(int cp)
      Creates the parameter data for the rule result detail.
      Parameters:
      cp - illegal character code point
      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
    • toString

      public String toString()
      Overrides:
      toString in class Object