Skip navigation links

Oracle Application Server HTTPClient Java API Reference
10g Release 3 (10.1.3.1.0)

B32117-01


HTTPClient.ntlm
Class NtlmCore

java.lang.Object
  extended byHTTPClient.ntlm.NtlmCore


public final class NtlmCore
extends java.lang.Object

The NtlmCore class implements the core functionality of the NTLM authentication protocol. This includes message formatting, message parsing, and cipher calculations.

NOTE: Currently supports LM and NTLM version 1, and does not support NTLM version 2.


Field Summary
static java.lang.String ASCII_CHARSET
           
static java.lang.String MD4_CLASS_NAME
          Supported MD4 class, needed for NTLM version 1 response.
static byte[] NTLMSSP_BYTES
           
static java.lang.String OEM_CHARSET
           
static java.lang.String UNICODE_CHARSET
           

 

Constructor Summary
NtlmCore()
           

 

Method Summary
static java.lang.String formatType1Message(java.lang.String clientHostName, java.lang.String clientHostDomain)
          Formats an NTLM Type 1 Message, containing the client host name and client host domain.
static java.lang.String formatType3Message(java.lang.String clientHostName, java.lang.String userDomain, java.lang.String username, byte[] lmPasswordHash, byte[] ntlmPasswordHash, NtlmType2Message challenge)
          Formats an NTLM Type 3 Message, containing the client host name, user account domain, username, LM response, NTLM response.
static byte[] generateLmV1Hash(java.lang.String password)
          Calculate the LM version 1 hash.
static byte[] generateNtlmV1Hash(java.lang.String password)
          Creates the NTLM version 1 hash.
static boolean isLmV1ResponseSupported()
          Determines whether the LM version 1 response is supported.
static boolean isNtlmV1ResponseSupported()
          Determines whether the NTLM version 1 response is supported.
static boolean isNtlmV2ResponseSupported()
          Determines whether the NTLM version 2 response is supported.
static NtlmType2Message parseType2Message(java.lang.String messageStr)
          Parses an NTLM Type 2 Message, containing the server challenge and the server support flags.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

OEM_CHARSET

public static final java.lang.String OEM_CHARSET
See Also:
Constant Field Values

UNICODE_CHARSET

public static final java.lang.String UNICODE_CHARSET
See Also:
Constant Field Values

ASCII_CHARSET

public static final java.lang.String ASCII_CHARSET
See Also:
Constant Field Values

NTLMSSP_BYTES

public static final byte[] NTLMSSP_BYTES

MD4_CLASS_NAME

public static final java.lang.String MD4_CLASS_NAME
Supported MD4 class, needed for NTLM version 1 response.
See Also:
Constant Field Values

Constructor Detail

NtlmCore

public NtlmCore()

Method Detail

generateLmV1Hash

public static byte[] generateLmV1Hash(java.lang.String password)
                               throws java.lang.Exception
Calculate the LM version 1 hash.
Parameters:
password - The given password.
Returns:
The 16-byte hash
Throws:
java.lang.Exception - An error occurred.

generateNtlmV1Hash

public static byte[] generateNtlmV1Hash(java.lang.String password)
                                 throws java.lang.Exception
Creates the NTLM version 1 hash.
Parameters:
password - The given password.
Returns:
The 16-byte hash, null if NTLM is not supported.
Throws:
java.lang.Exception - An error occurred.

isNtlmV1ResponseSupported

public static boolean isNtlmV1ResponseSupported()

Determines whether the NTLM version 1 response is supported.

<pTo support the NTLM version 1 response, the class com.phaos.crypto.MD4 must be in the class path. This class is usually in the .jar file ojpse.jar, available from Oracle.
Returns:
true if NTLM version 1 response is supported, otherwise false.

isNtlmV2ResponseSupported

public static boolean isNtlmV2ResponseSupported()
Determines whether the NTLM version 2 response is supported. NOTE: Currently, NTLM version 2 is NOT supported, and this method always returns false.
Returns:
true if NTLM version 2 response is supported, otherwise false.

isLmV1ResponseSupported

public static boolean isLmV1ResponseSupported()
Determines whether the LM version 1 response is supported. NOTE: Currently, LM version 1 is unconditionally supported, and this method always returns true.
Returns:
true if LM version 1 response is supported, otherwise false.

formatType1Message

public static java.lang.String formatType1Message(java.lang.String clientHostName,
                                                  java.lang.String clientHostDomain)

Formats an NTLM Type 1 Message, containing the client host name and client host domain. This starts the NTLM handshake.

The returned value has already been Base 64 encoded, and may be appended to the Authorization header after the scheme token.

Currently supports LM and NTLM version 1, and does not support NTLM version 2.

NOTE: clientHostName and clientHostDomain are included as Type 1 message parameters for completeness, and are transmitted. However, the purpose of these parameters is to facilitate Local authentication, which is not currently supported by this package.

Parameters:
clientHostName - Host name of client requesting protected resource, null if none or not using Local authentication.
clientHostDomain - Domain name of which client host belongs, null if none or not using Local authentication.
Returns:
The base-64-encoded Type 1 message

parseType2Message

public static NtlmType2Message parseType2Message(java.lang.String messageStr)

Parses an NTLM Type 2 Message, containing the server challenge and the server support flags.

Parameters:
messageStr - The portion of the WWW-Authenticate or Proxy-Authenticate server response header, after the NTLM scheme token. This is assumed base-64 encoded.
Returns:
The message fields, null if a Type 2 message could not be determined. See log for error details.

formatType3Message

public static java.lang.String formatType3Message(java.lang.String clientHostName,
                                                  java.lang.String userDomain,
                                                  java.lang.String username,
                                                  byte[] lmPasswordHash,
                                                  byte[] ntlmPasswordHash,
                                                  NtlmType2Message challenge)

Formats an NTLM Type 3 Message, containing the client host name, user account domain, username, LM response, NTLM response. Acceptance of this message by the server completes the NTLM handshake.

The returned value has already been Base 64 encoded, and may be appended to the Authorization header after the scheme token.

Parameters:
clientHostName - Host name of the client requesting the protected resource
userDomain - Domain name of which the user account has membership
username - Credentials user name
lmPasswordHash - Credentials password as LM hash (See generateLmV1Hash(String))
ntlmPasswordHash - Credentials password as NTLM version 1 hash, null if not available. (See generateNtlmV1Hash(String))
challenge - Challenge sent by the server in the type 2 message, used to generate the type 3 message.
Returns:
The base-64-encoded Type 3 message
Throws:
java.lang.IllegalArgumentException - Invalid challenge given.

Skip navigation links

Oracle Application Server HTTPClient Java API Reference
10g Release 3 (10.1.3.1.0)

B32117-01


Copyright © 2004, 2006, Oracle. All rights reserved.