com.ibm.passwordrules

Class BehavioralRule

  • java.lang.Object
    • com.ibm.passwordrules.BehavioralRule
  • All Implemented Interfaces:
    Rule, java.io.Serializable, java.lang.Cloneable


    public abstract class BehavioralRule
    extends java.lang.Object
    implements Rule, java.lang.Cloneable, java.io.Serializable
    Abstract base class for Rule implementations that provide validation of password's behavior.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      BehavioralRule() 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void constrain(PasswordGenerator generator)
      Some classes implementing Rule interface will not have a need to constrain the password generator.
      java.lang.String getParameter()
      This Rule interface method in is not valid in the context of standard rule classes.
      boolean join(Rule rule)
      Try to join the specified rule with this one.
      void setParameter(java.lang.String parameter)
      This Rule interface method in is not valid in the context of standard rule classes.
      boolean validate(java.lang.String password, ValidationInfo validationInfo)
      Validate the given password using the given validation info.
      boolean validateSafe(java.lang.String password, ValidationInfo validationInfo)
      Validate the given password using the given validation info.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.ibm.passwordrules.Rule

        cumulate
    • Constructor Detail

      • BehavioralRule

        public BehavioralRule()
    • Method Detail

      • validate

        public boolean validate(java.lang.String password,
                                ValidationInfo validationInfo)
                         throws InvalidPasswordException
        Validate the given password using the given validation info. Method overriden by subclass if validate operation supported.
        Specified by:
        validate in interface Rule
        Parameters:
        password - Password to validate.
        validationInfo - contains contextual information about the password being validated.
        Returns:
        always return true
        Throws:
        InvalidPasswordException - thrown when password is invalid.
      • join

        public boolean join(Rule rule)
                     throws IncompatibleRulesException
        Try to join the specified rule with this one. The more restrictive rule takes precedence. Overriding class may choose to leave this implementation empty. Method overriden by subclass if join operation supported.
        Specified by:
        join in interface Rule
        Parameters:
        rule - The rule to be joined with this one.
        Returns:
        always return false
        Throws:
        IncompatibleRulesException - Thrown when given rule cannot be joined because it is not compatible.
      • constrain

        public void constrain(PasswordGenerator generator)
        Some classes implementing Rule interface will not have a need to constrain the password generator. In such classes the method implemetation should be left empty.
        Specified by:
        constrain in interface Rule
        Parameters:
        generator - password generator be constrain.
      • validateSafe

        public boolean validateSafe(java.lang.String password,
                                    ValidationInfo validationInfo)
        Validate the given password using the given validation info. This version should never throw an exception, but will return false if the password is invalid. It is not possible to get any more information about why the password failed when using this version.
        Specified by:
        validateSafe in interface Rule
        Parameters:
        validationInfo - contains contextual information about the password being validated.
        password - Password to validate.
        Returns:
        true if password is valid - false it isn't
      • getParameter

        public java.lang.String getParameter()
        This Rule interface method in is not valid in the context of standard rule classes. Each standard rule class has its own method for getting constraining parameter value. RuntimeException is thrown during an attempt to use this interface method because the method is not valid in the context of this class.
        Specified by:
        getParameter in interface Rule
        Returns:
        String value of the parameter.
      • setParameter

        public void setParameter(java.lang.String parameter)
        This Rule interface method in is not valid in the context of standard rule classes. Each standard rule class has its own method for setting constraining parameter value. RuntimeException is thrown during an attempt to use this interface method because
        Specified by:
        setParameter in interface Rule
        Parameters:
        parameter - String value of the parameter.