com.ibm.passwordrules

Interface Rule

  • All Known Subinterfaces:
    CompositeRule
    All Known Implementing Classes:
    BehavioralRule, LexicalRule


    public interface Rule
    This interface needs to be implemented by all standard and custom password rule classes.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      void constrain(PasswordGenerator generator)
      Constrain the character set in the given password generator to values allowed by the generator.
      boolean cumulate(Rule rule)
      Cumulate the paramter values of rules of same type
      java.lang.String getParameter()
      Get the parameter set on a custom rule object.
      boolean join(Rule rule)
      Try to join the specified rule with this one.
      void setParameter(java.lang.String parameter)
      Set the parameter on a custom rule object.
      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 given validation info.
    • Method Detail

      • validate

        boolean validate(java.lang.String password,
                         ValidationInfo validationInfo)
                  throws InvalidPasswordException
        Validate the given password using the given validation info.
        Parameters:
        password - Password to validate.
        validationInfo - contains contextual information about the password being validated.
        Returns:
        true if password is valid, false otherwise.
        Throws:
        InvalidPasswordException - thrown when password is invalid.
      • validateSafe

        boolean validateSafe(java.lang.String password,
                             ValidationInfo validationInfo)
        Validate the given password using given validation info. This version should never throw an exception, but will return false if the password is invalid or if it couldn't be validated.
        Parameters:
        password - Password to validate.
        validationInfo - contains contextual information about the password being validated.
        Returns:
        true if password is valid, false otherwise
      • constrain

        void constrain(PasswordGenerator generator)
        Constrain the character set in the given password generator to values allowed by the generator.
        Parameters:
        generator - password generator, whose character set will be constrained. NOTE: Constraining a generator only offers a hint. Implementor of a Rule class may choose not to constrain the generator at all, in which case it may take more iterations for the generator to come up with a candidate password compliant with the rule. When constraints are not implemented, IterationsExceededException may be thrown more often from the generate method of the PasswordGenerator. Skipping a constraint should be tested first by attempting to generate a large number of passwords without encountering IterationsExceededException.
      • join

        boolean join(Rule rule)
              throws IncompatibleRulesException
        Try to join the specified rule with this one. The more restrictive rule takes precedence.
        Parameters:
        rule - The rule to be joined with this one.
        Returns:
        true - Returns true, if the specified rule was successfully combined with this one. Returns false, if the specified rule and this one are not of the same class\type or they are not dependent on each other due to which they cannot be combined.
        Throws:
        IncompatibleRulesException - - Thrown if the specified rule and this one cannot be combined because they are mutually exclusive, i.e. a password cannot satisfy both the rules at the same time. Example if the given rule specifies that the max length of password should be 5, and if this rule specifies that the minimum length of password should be 6, then this function may throw IncompatibleRulesException.
      • getParameter

        java.lang.String getParameter()
        Get the parameter set on a custom rule object.
        Returns:
        parameter String representing the constraining parameter Null may be returned if the parameter is not required. Parameter value is rule specific and its format may differ from one rule implementation to other. It is up to the rule implementation class to be able to interpret the parameter's meaning.
      • setParameter

        void setParameter(java.lang.String parameter)
        Set the parameter on a custom rule object. The parameter format varies from implementation to implementation.
        Parameters:
        parameter - String representing the parameter It may be null if the parameter is not required. Parameter value is rule specific and its format may differ from one rule implementation to other. It is up to the rule implementation class to be able to interpret the parameter's meaning.