edu.vt.middleware.password
Class AbstractDigester

java.lang.Object
  extended by edu.vt.middleware.password.AbstractDigester
Direct Known Subclasses:
HistoryRule, SourceRule

public abstract class AbstractDigester
extends Object

Provides common implementation for password rules that use a digest.

Version:
$Revision: 2704 $ $Date: 2013-04-24 17:30:32 -0400 (Wed, 24 Apr 2013) $
Author:
Middleware Services

Field Summary
protected  edu.vt.middleware.crypt.util.Converter converter
          Converter to use in conjunction with the digest.
protected  edu.vt.middleware.crypt.digest.DigestAlgorithm digest
          Digest object to use if comparing hashed passwords.
 
Constructor Summary
AbstractDigester()
           
 
Method Summary
protected  byte[] addSalt(byte[] data, byte[] salt)
          Concatenates the supplied salt to the supplied data.
protected  byte[] extractSalt(byte[] hash, int length)
          Extracts a salt from the end of the supplied hash.
protected  boolean matches(String undigested, String reference)
          Determines whether an undigested password matches a (possibly digested) reference value.
 void setDigest(String algorithm, edu.vt.middleware.crypt.util.Converter conv)
          This will set the supplied digest algorithm to be used when password comparison are made.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

digest

protected edu.vt.middleware.crypt.digest.DigestAlgorithm digest
Digest object to use if comparing hashed passwords.


converter

protected edu.vt.middleware.crypt.util.Converter converter
Converter to use in conjunction with the digest.

Constructor Detail

AbstractDigester

public AbstractDigester()
Method Detail

setDigest

public void setDigest(String algorithm,
                      edu.vt.middleware.crypt.util.Converter conv)
This will set the supplied digest algorithm to be used when password comparison are made. Useful if you need to compare password which are in a hashed form. See DigestAlgorithm.

Parameters:
algorithm - to use for hashing
conv - to convert bytes to string

matches

protected boolean matches(String undigested,
                          String reference)
Determines whether an undigested password matches a (possibly digested) reference value.

Parameters:
undigested - candidate clear text password.
reference - reference password (possibly digested).
Returns:
true if passwords match, false otherwise.

extractSalt

protected byte[] extractSalt(byte[] hash,
                             int length)
Extracts a salt from the end of the supplied hash.

Parameters:
hash - to read salt from
length - of the salt to extract
Returns:
salt bytes

addSalt

protected byte[] addSalt(byte[] data,
                         byte[] salt)
Concatenates the supplied salt to the supplied data.

Parameters:
data - to concatenate salt to
salt - to concatenate
Returns:
new byte array of concatenated data


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