org.xwiki.crypto.passwd.internal
Class DefaultPasswordVerificationFunction

java.lang.Object
  extended by org.xwiki.crypto.passwd.internal.DefaultPasswordVerificationFunction
All Implemented Interfaces:
java.io.Serializable, PasswordVerificationFunction

public class DefaultPasswordVerificationFunction
extends java.lang.Object
implements PasswordVerificationFunction

Default password verification function wraps a key derivation function and stores the hash output.

Since:
2.5M1
Version:
$Id$
See Also:
Serialized Form

Constructor Summary
DefaultPasswordVerificationFunction()
           
 
Method Summary
 void init(KeyDerivationFunction underlyingHashFunction, byte[] password)
          Initialize this function with the desired key length.
 boolean isPasswordCorrect(byte[] password)
          Validate a user supplied password.
 byte[] serialize()
          Store this function as a byte array so another function of the same class can be initialized with the same array and will then produce the same key for the given password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPasswordVerificationFunction

public DefaultPasswordVerificationFunction()
Method Detail

init

public void init(KeyDerivationFunction underlyingHashFunction,
                 byte[] password)
Initialize this function with the desired key length.

Specified by:
init in interface PasswordVerificationFunction
Parameters:
underlyingHashFunction - the function which will be used when converting the password to a hash.
password - the user supplied password to be verified later.
See Also:
PasswordVerificationFunction.init(KeyDerivationFunction, byte[])

serialize

public byte[] serialize()
                 throws java.io.IOException
Store this function as a byte array so another function of the same class can be initialized with the same array and will then produce the same key for the given password.

Specified by:
serialize in interface PasswordVerificationFunction
Returns:
a byte array which can be used to recreate the same function again using init.
Throws:
java.io.IOException - if something fails within the serialization framework.
See Also:
PasswordVerificationFunction.serialize()

isPasswordCorrect

public boolean isPasswordCorrect(byte[] password)
Validate a user supplied password.

Specified by:
isPasswordCorrect in interface PasswordVerificationFunction
Parameters:
password - the user supplied password.
Returns:
true if the hash of the password is the same as the stored hash.
See Also:
PasswordVerificationFunction.init(KeyDerivationFunction, byte[])


Copyright © 2004-2011 XWiki. All Rights Reserved.