APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.security.ntlm

public final Class Client

extends NTLM
Class Inheritance
Imports
java.math.BigInteger, java.util.Arrays, .Date, .Locale

The NTLM client. Not multi-thread enabled.

Example:

Client client = new Client(null, "host", "dummy",
      "REALM", "t0pSeCr3t".toCharArray());
byte[] type1 = client.type1();
// Send type1 to server and receive response as type2
byte[] type3 = client.type3(type2, nonce);
// Send type3 to server

Field Summary

Modifier and TypeField and Description
private String
private final String
private byte[]
private byte[]
private final String
Inherited from com.sun.security.ntlm.NTLM:
vwriteLMwriteNTLM

Constructor Summary

AccessConstructor and Description
public
Client(String
the NTLM version to use, which can be:
  • LM/NTLM: Original NTLM v1
  • LM: Original NTLM v1, LM only
  • NTLM: Original NTLM v1, NTLM only
  • NTLM2: NTLM v1 with Client Challenge
  • LMv2/NTLMv2: NTLM v2
  • LMv2: NTLM v2, LM only
  • NTLMv2: NTLM v2, NTLM only
If null, "LMv2/NTLMv2" will be used.
version
,
String
hostname of the client, can be null
hostname
,
String
username to be authenticated, must not be null
username
,
String
domain of username, can be null
domain
,
char[]
password for username, must not be not null. This method does not make any modification to this parameter, it neither needs to access the content of this parameter after this method call, so you are free to modify or nullify this parameter after this call.
password
)

Creates an NTLM Client instance.

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Disposes any password-derived information.

public String

Returns:

the domain
getDomain
()

Returns the domain value provided by server after the authentication is complete, or the domain value provided by the client before it.

public byte[]

Returns:

the message generated
type1
()

Generates the Type 1 message

public byte[]

Returns:

the message generated
type3
(byte[]
the responding Type 2 message from server, must not be null
type2
,
byte[]
random 8-byte array to be used in message generation, must not be null except for original NTLM v1
nonce
)

Generates the Type 3 message

Inherited from com.sun.security.ntlm.NTLM:
calcLMHashcalcNTHashcalcResponsecalcV2debugdebuggetP1getP2hmacMD5makeDesKeyntlm2LMntlm2NTLM

Field Detail

domainback to summary
private String domain
hostnameback to summary
private final String hostname
pw1back to summary
private byte[] pw1
pw2back to summary
private byte[] pw2
usernameback to summary
private final String username

Constructor Detail

Clientback to summary
public Client(String version, String hostname, String username, String domain, char[] password) throws NTLMException

Creates an NTLM Client instance.

Parameters
version:String

the NTLM version to use, which can be:

  • LM/NTLM: Original NTLM v1
  • LM: Original NTLM v1, LM only
  • NTLM: Original NTLM v1, NTLM only
  • NTLM2: NTLM v1 with Client Challenge
  • LMv2/NTLMv2: NTLM v2
  • LMv2: NTLM v2, LM only
  • NTLMv2: NTLM v2, NTLM only
If null, "LMv2/NTLMv2" will be used.
hostname:String

hostname of the client, can be null

username:String

username to be authenticated, must not be null

domain:String

domain of username, can be null

password:char[]

password for username, must not be not null. This method does not make any modification to this parameter, it neither needs to access the content of this parameter after this method call, so you are free to modify or nullify this parameter after this call.

Exceptions
NTLMException:
if username or password is null, or version is illegal.

Method Detail

disposeback to summary
public void dispose()

Disposes any password-derived information.

getDomainback to summary
public String getDomain()

Returns the domain value provided by server after the authentication is complete, or the domain value provided by the client before it.

Returns:String

the domain

type1back to summary
public byte[] type1()

Generates the Type 1 message

Returns:byte[]

the message generated

type3back to summary
public byte[] type3(byte[] type2, byte[] nonce) throws NTLMException

Generates the Type 3 message

Parameters
type2:byte[]

the responding Type 2 message from server, must not be null

nonce:byte[]

random 8-byte array to be used in message generation, must not be null except for original NTLM v1

Returns:byte[]

the message generated

Exceptions
NTLMException:
if the incoming message is invalid, or nonce is null for NTLM v1.