org.apache.mina.proxy.handlers.http.ntlm
Class NTLMResponses

java.lang.Object
  extended by org.apache.mina.proxy.handlers.http.ntlm.NTLMResponses

public class NTLMResponses
extends Object

NTLMResponses.java - Calculates the various Type 3 responses. Needs an MD4, MD5 and DES crypto provider (Please note that default provider doesn't provide MD4). Copyright (c) 2003 Eric Glass Permission to use, copy, modify, and distribute this document for any purpose and without any fee is hereby granted, provided that the above copyright notice and this list of conditions appear in all copies.

Since:
MINA 2.0.0-M3
Author:
Apache MINA Project
See Also:
http://curl.haxx.se/rfc/ntlm.html

Field Summary
static byte[] LM_HASH_MAGIC_CONSTANT
           
 
Constructor Summary
NTLMResponses()
           
 
Method Summary
static byte[] getLMResponse(String password, byte[] challenge)
          Calculates the LM Response for the given challenge, using the specified password.
static byte[] getLMv2Response(String target, String user, String password, byte[] challenge, byte[] clientNonce)
          Calculates the LMv2 Response for the given challenge, using the specified authentication target, username, password, and client challenge.
static byte[] getNTLM2SessionResponse(String password, byte[] challenge, byte[] clientNonce)
          Calculates the NTLM2 Session Response for the given challenge, using the specified password and client nonce.
static byte[] getNTLMResponse(String password, byte[] challenge)
          Calculates the NTLM Response for the given challenge, using the specified password.
static byte[] getNTLMv2Response(String target, String user, String password, byte[] targetInformation, byte[] challenge, byte[] clientNonce)
          Calculates the NTLMv2 Response for the given challenge, using the specified authentication target, username, password, target information block, and client nonce.
static byte[] getNTLMv2Response(String target, String user, String password, byte[] targetInformation, byte[] challenge, byte[] clientNonce, long time)
          Calculates the NTLMv2 Response for the given challenge, using the specified authentication target, username, password, target information block, and client nonce.
static byte[] hmacMD5(byte[] data, byte[] key)
          Calculates the HMAC-MD5 hash of the given data using the specified hashing key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LM_HASH_MAGIC_CONSTANT

public static byte[] LM_HASH_MAGIC_CONSTANT
Constructor Detail

NTLMResponses

public NTLMResponses()
Method Detail

getLMResponse

public static byte[] getLMResponse(String password,
                                   byte[] challenge)
                            throws Exception
Calculates the LM Response for the given challenge, using the specified password.

Parameters:
password - The user's password.
challenge - The Type 2 challenge from the server.
Returns:
The LM Response.
Throws:
Exception

getNTLMResponse

public static byte[] getNTLMResponse(String password,
                                     byte[] challenge)
                              throws Exception
Calculates the NTLM Response for the given challenge, using the specified password.

Parameters:
password - The user's password.
challenge - The Type 2 challenge from the server.
Returns:
The NTLM Response.
Throws:
Exception

getNTLMv2Response

public static byte[] getNTLMv2Response(String target,
                                       String user,
                                       String password,
                                       byte[] targetInformation,
                                       byte[] challenge,
                                       byte[] clientNonce)
                                throws Exception
Calculates the NTLMv2 Response for the given challenge, using the specified authentication target, username, password, target information block, and client nonce.

Parameters:
target - The authentication target (i.e., domain).
user - The username.
password - The user's password.
targetInformation - The target information block from the Type 2 message.
challenge - The Type 2 challenge from the server.
clientNonce - The random 8-byte client nonce.
Returns:
The NTLMv2 Response.
Throws:
Exception

getNTLMv2Response

public static byte[] getNTLMv2Response(String target,
                                       String user,
                                       String password,
                                       byte[] targetInformation,
                                       byte[] challenge,
                                       byte[] clientNonce,
                                       long time)
                                throws Exception
Calculates the NTLMv2 Response for the given challenge, using the specified authentication target, username, password, target information block, and client nonce.

Parameters:
target - The authentication target (i.e., domain).
user - The username.
password - The user's password.
targetInformation - The target information block from the Type 2 message.
challenge - The Type 2 challenge from the server.
clientNonce - The random 8-byte client nonce.
time - The time stamp.
Returns:
The NTLMv2 Response.
Throws:
Exception

getLMv2Response

public static byte[] getLMv2Response(String target,
                                     String user,
                                     String password,
                                     byte[] challenge,
                                     byte[] clientNonce)
                              throws Exception
Calculates the LMv2 Response for the given challenge, using the specified authentication target, username, password, and client challenge.

Parameters:
target - The authentication target (i.e., domain).
user - The username.
password - The user's password.
challenge - The Type 2 challenge from the server.
clientNonce - The random 8-byte client nonce.
Returns:
The LMv2 Response.
Throws:
Exception

getNTLM2SessionResponse

public static byte[] getNTLM2SessionResponse(String password,
                                             byte[] challenge,
                                             byte[] clientNonce)
                                      throws Exception
Calculates the NTLM2 Session Response for the given challenge, using the specified password and client nonce.

Parameters:
password - The user's password.
challenge - The Type 2 challenge from the server.
clientNonce - The random 8-byte client nonce.
Returns:
The NTLM2 Session Response. This is placed in the NTLM response field of the Type 3 message; the LM response field contains the client nonce, null-padded to 24 bytes.
Throws:
Exception

hmacMD5

public static byte[] hmacMD5(byte[] data,
                             byte[] key)
                      throws Exception
Calculates the HMAC-MD5 hash of the given data using the specified hashing key.

Parameters:
data - The data for which the hash will be calculated.
key - The hashing key.
Returns:
The HMAC-MD5 hash of the given data.
Throws:
Exception


Copyright © 2004-2011 Apache MINA Project. All Rights Reserved.