edu.vt.middleware.password
Class LengthRule

java.lang.Object
  extended by edu.vt.middleware.password.LengthRule
All Implemented Interfaces:
Rule

public class LengthRule
extends java.lang.Object
implements Rule

Rule for determining if a password is within a desired length. The minimum and maximum lengths are used inclusively to determine if a password meets this rule.

Version:
$Revision: 1930 $ $Date: 2011-04-28 13:06:17 -0400 (Thu, 28 Apr 2011) $
Author:
Middleware Services

Field Summary
static java.lang.String ERROR_CODE_MAX
          Error code for password too long.
static java.lang.String ERROR_CODE_MIN
          Error code for password too short.
 
Constructor Summary
LengthRule()
          Creates a new length rule with lengths unset.
LengthRule(int length)
          Creates a new length rule with the supplied length.
LengthRule(int minLength, int maxLength)
          Create a new length rule.
 
Method Summary
protected  java.util.Map<java.lang.String,?> createRuleResultDetailParameters()
          Creates the parameter data for the rule result detail.
 int getMaximumLength()
          Returns the maximum password length.
 int getMinimumLength()
          Returns the minimum password length.
 void setMaximumLength(int maxLength)
          Sets the maximum password length.
 void setMinimumLength(int minLength)
          Sets the minimum password length.
 java.lang.String toString()
          Returns a string representation of this object.
 RuleResult validate(PasswordData passwordData)
          Validates the supplied password data per the requirements of this rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ERROR_CODE_MIN

public static final java.lang.String ERROR_CODE_MIN
Error code for password too short.

See Also:
Constant Field Values

ERROR_CODE_MAX

public static final java.lang.String ERROR_CODE_MAX
Error code for password too long.

See Also:
Constant Field Values
Constructor Detail

LengthRule

public LengthRule()
Creates a new length rule with lengths unset. The defaults are 0 and Integer.MAX_VALUE respectively.


LengthRule

public LengthRule(int length)
Creates a new length rule with the supplied length. Both the minimum and the maximum length will be set to this value.

Parameters:
length - length of password

LengthRule

public LengthRule(int minLength,
                  int maxLength)
Create a new length rule.

Parameters:
minLength - minimum length of a password
maxLength - maximum length of a password
Method Detail

setMinimumLength

public void setMinimumLength(int minLength)
Sets the minimum password length.

Parameters:
minLength - minimum length of a password

getMinimumLength

public int getMinimumLength()
Returns the minimum password length.

Returns:
minimum password length

setMaximumLength

public void setMaximumLength(int maxLength)
Sets the maximum password length.

Parameters:
maxLength - maximum length of a password

getMaximumLength

public int getMaximumLength()
Returns the maximum password length.

Returns:
maximum length of a password

validate

public RuleResult validate(PasswordData passwordData)
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 java.util.Map<java.lang.String,?> createRuleResultDetailParameters()
Creates the parameter data for the rule result detail.

Returns:
map of parameter name to value

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
string representation


Copyright © 2003-2011 Virginia Tech. All Rights Reserved.