Class AbstractDictionaryRule

java.lang.Object
org.passay.rule.AbstractDictionaryRule
All Implemented Interfaces:
Rule
Direct Known Subclasses:
DictionaryRule, DictionarySubstringRule, DigestDictionaryRule

public abstract class AbstractDictionaryRule extends Object implements Rule
Provides common implementation for password dictionary rules.
  • Field Details

    • dictionary

      private final Dictionary dictionary
      Dictionary of words.
    • matchBackwards

      private final boolean matchBackwards
      Whether to search for dictionary words backwards.
  • Constructor Details

    • AbstractDictionaryRule

      public AbstractDictionaryRule(Dictionary dict, boolean matchBackwards)
      Creates a new abstract dictionary rule.
      Parameters:
      dict - to use for searching
      matchBackwards - whether to match dictionary words backwards
  • Method Details

    • getDictionary

      public Dictionary getDictionary()
      Returns the dictionary used to search for passwords.
      Returns:
      dictionary used for searching
    • isMatchBackwards

      public boolean isMatchBackwards()
      Returns true if the verify method will search the password for dictionary words spelled backwards as well as forwards.
      Returns:
      whether to match dictionary words backwards
    • 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(CharSequence word)
      Creates the parameter data for the rule result detail.
      Parameters:
      word - matching word
      Returns:
      map of parameter name to value
    • getErrorCode

      protected abstract String getErrorCode(boolean backwards)
      Returns the error code for this rule.
      Parameters:
      backwards - whether to return the error code for a backwards match
      Returns:
      properties error code
    • doWordSearch

      protected abstract CharSequence doWordSearch(UnicodeString text)
      Searches the dictionary with the supplied text.
      Parameters:
      text - to search dictionary with
      Returns:
      matching word
    • toString

      public String toString()
      Overrides:
      toString in class Object