edu.vt.middleware.password
Class AbstractCharacterRule

java.lang.Object
  extended by edu.vt.middleware.password.AbstractCharacterRule
All Implemented Interfaces:
CharacterRule, Rule
Direct Known Subclasses:
AlphabeticalCharacterRule, DigitCharacterRule, LowercaseCharacterRule, NonAlphanumericCharacterRule, UppercaseCharacterRule

public abstract class AbstractCharacterRule
extends Object
implements CharacterRule

Provides common implementation for password character rules.

Version:
$Revision: 1636 $ $Date: 2010-10-04 11:12:15 -0400 (Mon, 04 Oct 2010) $
Author:
Middleware Services

Field Summary
static String ERROR_CODE
          Error code for insufficient number of characters of particular class.
protected  int numCharacters
          Number of characters to require.
 
Constructor Summary
AbstractCharacterRule()
           
 
Method Summary
protected  Map<String,?> createRuleResultDetailParameters(Password p)
          Creates the parameter data for the rule result detail.
protected abstract  String getCharacterType()
          Returns the type of character managed by this rule.
 int getNumberOfCharacters()
          Returns the number of characters which must exist in order for a password to meet the requirements of this rule.
protected abstract  int getNumberOfCharacterType(Password password)
          Returns the number of the type of characters in the supplied password for the implementing class.
 void setNumberOfCharacters(int n)
          Sets the number of characters to require in a password.
 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
 
Methods inherited from interface edu.vt.middleware.password.CharacterRule
getValidCharacters
 

Field Detail

ERROR_CODE

public static final String ERROR_CODE
Error code for insufficient number of characters of particular class.

See Also:
Constant Field Values

numCharacters

protected int numCharacters
Number of characters to require. Default value is 1.

Constructor Detail

AbstractCharacterRule

public AbstractCharacterRule()
Method Detail

setNumberOfCharacters

public void setNumberOfCharacters(int n)
Sets the number of characters to require in a password.

Specified by:
setNumberOfCharacters in interface CharacterRule
Parameters:
n - number of characters to require where n > 0

getNumberOfCharacters

public int getNumberOfCharacters()
Returns the number of characters which must exist in order for a password to meet the requirements of this rule.

Specified by:
getNumberOfCharacters in interface CharacterRule
Returns:
number of characters to require

getNumberOfCharacterType

protected abstract int getNumberOfCharacterType(Password password)
Returns the number of the type of characters in the supplied password for the implementing class.

Parameters:
password - to get character count from
Returns:
number of characters

getCharacterType

protected abstract String getCharacterType()
Returns the type of character managed by this rule.

Returns:
name of a character type, e.g. "digits."

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 Map<String,?> createRuleResultDetailParameters(Password p)
Creates the parameter data for the rule result detail.

Parameters:
p - password
Returns:
map of parameter name to value

toString

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

Overrides:
toString in class Object
Returns:
string representation


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