org.apache.geronimo.javamail.authentication
Class CramMD5Authenticator

java.lang.Object
  extended by org.apache.geronimo.javamail.authentication.CramMD5Authenticator
All Implemented Interfaces:
ClientAuthenticator

public class CramMD5Authenticator
extends Object
implements ClientAuthenticator


Field Summary
protected  boolean complete
           
protected  String password
           
protected  String username
           
 
Constructor Summary
CramMD5Authenticator(String username, String password)
          Main constructor.
 
Method Summary
protected  byte[] computeCramDigest(byte[] key, byte[] input)
          Compute a CRAM digest using the hmac_md5 algorithm.
 byte[] evaluateChallenge(byte[] challenge)
          Evaluate a CRAM-MD5 login challenge, returning the a result string that should satisfy the clallenge.
 String getMechanismName()
          Retrieve the authenticator mechanism name.
 boolean hasInitialResponse()
          Respond to the hasInitialResponse query.
 boolean isComplete()
          Indicate whether the challenge/response process is complete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

username

protected String username

password

protected String password

complete

protected boolean complete
Constructor Detail

CramMD5Authenticator

public CramMD5Authenticator(String username,
                            String password)
Main constructor.

Parameters:
username - The login user name.
password - The login password.
Method Detail

hasInitialResponse

public boolean hasInitialResponse()
Respond to the hasInitialResponse query. This mechanism does not have an initial response.

Specified by:
hasInitialResponse in interface ClientAuthenticator
Returns:
Always returns false.

isComplete

public boolean isComplete()
Indicate whether the challenge/response process is complete.

Specified by:
isComplete in interface ClientAuthenticator
Returns:
True if the last challenge has been processed, false otherwise.

getMechanismName

public String getMechanismName()
Retrieve the authenticator mechanism name.

Specified by:
getMechanismName in interface ClientAuthenticator
Returns:
Always returns the string "CRAM-MD5"

evaluateChallenge

public byte[] evaluateChallenge(byte[] challenge)
                         throws MessagingException
Evaluate a CRAM-MD5 login challenge, returning the a result string that should satisfy the clallenge.

Specified by:
evaluateChallenge in interface ClientAuthenticator
Parameters:
challenge - The decoded challenge data, as a byte array.
Returns:
A formatted challege response, as an array of bytes.
Throws:
MessagingException

computeCramDigest

protected byte[] computeCramDigest(byte[] key,
                                   byte[] input)
                            throws MessagingException
Compute a CRAM digest using the hmac_md5 algorithm. See the description of RFC 2104 for algorithm details.

Parameters:
key - The key (K) for the calculation.
input - The encrypted text value.
Returns:
The computed digest, as a byte array value.
Throws:
NoSuchAlgorithmException
MessagingException


Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.