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

public abstract Class Server

extends NTLM
Class Inheritance
Imports
java.util.Arrays, .Locale

The NTLM server, not multi-thread enabled.

Example:

Server server = new Server(null, "REALM") {
    public char[] getPassword(String ntdomain, String username) {
        switch (username) {
            case "dummy": return "t0pSeCr3t".toCharArray();
            case "guest": return "".toCharArray();
            default: return null;
        }
    }
};
// Receive client request as type1
byte[] type2 = server.type2(type1, nonce);
// Send type2 to client and receive type3
verify(type3, nonce);

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
Server(String
the NTLM version to use, which can be:
  • NTLM: Original NTLM v1
  • NTLM2: NTLM v1 with Client Challenge
  • NTLMv2: NTLM v2
If null, all versions will be supported. Please note that unless NTLM2 is selected, authentication succeeds if one of LM (or LMv2) or NTLM (or NTLMv2) is verified.
version
,
String
the domain, must not be null
domain
)

Creates a Server instance.

Method Summary

Modifier and TypeMethod and Description
public abstract char[]

Returns:

the password for the user, or null if unknown
getPassword
(String
can be null
domain
,
String
must not be null
username
)

Retrieves the password for a given user.

public byte[]

Returns:

the message generated
type2
(byte[]
the Type1 message received, must not be null
type1
,
byte[]
the random 8-byte array to be used in message generation, must not be null
nonce
)

Generates the Type 2 message

public String[]

Returns:

client username, client hostname, and the request target
verify
(byte[]
the incoming Type3 message from client, must not be null
type3
,
byte[]
the same nonce provided in type2, must not be null
nonce
)

Verifies the Type3 message received from client and returns various negotiated information.

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

Field Detail

allVersionback to summary
private final boolean allVersion
domainback to summary
private final String domain

Constructor Detail

Serverback to summary
public Server(String version, String domain) throws NTLMException

Creates a Server instance.

Parameters
version:String

the NTLM version to use, which can be:

  • NTLM: Original NTLM v1
  • NTLM2: NTLM v1 with Client Challenge
  • NTLMv2: NTLM v2
If null, all versions will be supported. Please note that unless NTLM2 is selected, authentication succeeds if one of LM (or LMv2) or NTLM (or NTLMv2) is verified.
domain:String

the domain, must not be null

Annotations
@SuppressWarnings:this-escape
Exceptions
NTLMException:
if domain is null.

Method Detail

getPasswordback to summary
public abstract char[] getPassword(String domain, String username)

Retrieves the password for a given user. This method should be overridden in a concrete class.

Parameters
domain:String

can be null

username:String

must not be null

Returns:char[]

the password for the user, or null if unknown

type2back to summary
public byte[] type2(byte[] type1, byte[] nonce) throws NTLMException

Generates the Type 2 message

Parameters
type1:byte[]

the Type1 message received, must not be null

nonce:byte[]

the random 8-byte array to be used in message generation, must not be null

Returns:byte[]

the message generated

Exceptions
NTLMException:
if the incoming message is invalid, or nonce is null.
verifyback to summary
public String[] verify(byte[] type3, byte[] nonce) throws NTLMException

Verifies the Type3 message received from client and returns various negotiated information.

Parameters
type3:byte[]

the incoming Type3 message from client, must not be null

nonce:byte[]

the same nonce provided in type2, must not be null

Returns:String[]

client username, client hostname, and the request target

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