eTextReader.authentication
Class CompoundPolicy

java.lang.Object
  extended by eTextReader.authentication.CompoundPolicy
All Implemented Interfaces:
PasswordPolicy

public class CompoundPolicy
extends java.lang.Object
implements PasswordPolicy

This class provides a mechanism by which two or more other PasswordPolicy implementations can be combined using a Boolean AND operation. An object of this class will accept any password that is accepted by all of its component policy implementations.

Two constructors are provided: one that joins together exactly 2 other PasswordPolicy objects, and one that accepts a List of PasswordPolicy objects.

Author:
mcfall

Field Summary
private  java.util.List<PasswordPolicy> policies
           
 
Constructor Summary
CompoundPolicy(java.util.List<PasswordPolicy> policies)
           
CompoundPolicy(PasswordPolicy policy1, PasswordPolicy policy2)
           Constructs a CompoundPolicy that combines two other policy objects.
 
Method Summary
 java.lang.String getDescription()
          Retrieves a human-readable description of the rules this policy enforces
 boolean isValid(java.lang.String password)
          Determines whether or not the given password is valid under this policy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

policies

private java.util.List<PasswordPolicy> policies
Constructor Detail

CompoundPolicy

public CompoundPolicy(PasswordPolicy policy1,
                      PasswordPolicy policy2)

Constructs a CompoundPolicy that combines two other policy objects.

The order that the policies are passed is generally not relevant. The only case in which the order by matter is if one of the policies is more computationally expensive. The first policy passed will be evaluated first if this is of concern to you.

Note that since CompoundPolicy implements PasswordPolicy, either or both of the parameters may themselves be CompoundPolicy objects.

Parameters:
policy1 - the first policy to be evaluated
policy2 - the second policy to be evaluated

CompoundPolicy

public CompoundPolicy(java.util.List<PasswordPolicy> policies)
Method Detail

getDescription

public java.lang.String getDescription()
Description copied from interface: PasswordPolicy
Retrieves a human-readable description of the rules this policy enforces

Specified by:
getDescription in interface PasswordPolicy
Returns:
a string describing the policy rules

isValid

public boolean isValid(java.lang.String password)
Description copied from interface: PasswordPolicy
Determines whether or not the given password is valid under this policy

Specified by:
isValid in interface PasswordPolicy
Parameters:
password - the password to check
Returns:
true if the given password is valid, false otherwise