Class NTLMEngineImpl
java.lang.Object
org.apache.hc.client5.http.impl.auth.NTLMEngineImpl
- All Implemented Interfaces:
NTLMEngine
Deprecated.
Do not use.
Provides an implementation for NTLMv1, NTLMv2, and NTLM2 Session forms of the NTLM
authentication protocol.
- Since:
- 4.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Deprecated.(package private) static class
Deprecated.(package private) static class
Deprecated.Cryptography support - HMACMD5 - algorithmically based on various web resources by Karl Wright(package private) static class
Deprecated.Cryptography support - MD4.(package private) static enum
Deprecated.(package private) static class
Deprecated.NTLM message generation, base class(package private) static class
Deprecated.Type 1 message assembly class(package private) static class
Deprecated.Type 2 message class(package private) static class
Deprecated.Type 3 message assembly class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Charset
Deprecated.Character encoding(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.private static final byte[]
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.(package private) static final int
Deprecated.private static final SecureRandom
Deprecated.Secure random generatorprivate static final byte[]
Deprecated.private static final byte[]
Deprecated.private static final byte[]
Deprecated.private static final byte[]
Deprecated.private static final byte[]
Deprecated.The signature string as bytes in the default encodingprivate static final String
Deprecated.private static final Charset
Deprecated.Unicode encoding -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]
createBlob
(byte[] clientChallenge, byte[] targetInformation, byte[] timestamp) Deprecated.Creates the NTLMv2 blob from the given target information block and client challenge.private static Key
createDESKey
(byte[] bytes, int offset) Deprecated.Creates a DES encryption key from the given key material.private static void
encodeLong
(byte[] buf, int offset, int value) Deprecated.private static byte[]
encodeLong
(int value) Deprecated.(package private) static int
F
(int x, int y, int z) Deprecated.(package private) static int
G
(int x, int y, int z) Deprecated.generateType1Msg
(String domain, String workstation) Deprecated.Generates a Type1 message given the domain and workstation.generateType3Msg
(String username, char[] password, String domain, String workstation, String challenge) Deprecated.Generates a Type3 message given the user credentials and the authentication challenge.private static Charset
getCharset
(int flags) Deprecated.Find the character set based on the flags.(package private) static MessageDigest
getMD5()
Deprecated.private static byte[]
getNullTerminatedAsciiString
(String source) Deprecated.(package private) static String
getResponseFor
(String message, String username, char[] password, String host, String domain) Deprecated.Returns the response for the given message.(package private) static String
getResponseFor
(String message, String username, char[] password, String host, String domain, Certificate peerServerCertificate) Deprecated.Returns the response for the given message.(package private) static String
getType1Message
(String host, String domain) Deprecated.Creates the first message (type 1 message) in the NTLM authentication sequence.(package private) static String
getType3Message
(String user, char[] password, String host, String domain, byte[] nonce, int type2Flags, String target, byte[] targetInformation) Deprecated.Creates the type 3 message using the given server nonce.(package private) static String
getType3Message
(String user, char[] password, String host, String domain, byte[] nonce, int type2Flags, String target, byte[] targetInformation, Certificate peerServerCertificate, byte[] type1Message, byte[] type2Message) Deprecated.Creates the type 3 message using the given server nonce.(package private) static int
H
(int x, int y, int z) Deprecated.(package private) static byte[]
hmacMD5
(byte[] value, byte[] key) Deprecated.Calculates HMAC-MD5private static byte[]
lmHash
(char[] password) Deprecated.Creates the LM Hash of the user's password.private static byte[]
lmResponse
(byte[] hash, byte[] challenge) Deprecated.Creates the LM Response from the given hash and Type 2 challenge.private static byte[]
Deprecated.Creates the LMv2 Hash of the user's password.private static byte[]
lmv2Response
(byte[] hash, byte[] challenge, byte[] clientData) Deprecated.Creates the LMv2 Response from the given hash, client data, and Type 2 challenge.private static byte[]
makeRandomChallenge
(Random random) Deprecated.Calculate a challenge blockprivate static byte[]
makeSecondaryKey
(Random random) Deprecated.Calculate a 16-byte secondary key(package private) static byte[]
ntlm2SessionResponse
(byte[] ntlmHash, byte[] challenge, byte[] clientChallenge) Deprecated.Calculates the NTLM2 Session Response for the given challenge, using the specified password and client challenge.private static byte[]
ntlmHash
(char[] password) Deprecated.Creates the NTLM Hash of the user's password.private static byte[]
ntlmv2Hash
(String domain, String user, byte[] ntlmHash) Deprecated.Creates the NTLMv2 Hash of the user's password.private static void
oddParity
(byte[] bytes) Deprecated.Applies odd parity to the given byte array.(package private) static byte[]
RC4
(byte[] value, byte[] key) Deprecated.Calculates RC4private static byte[]
readSecurityBuffer
(byte[] src, int index) Deprecated.private static int
readULong
(byte[] src, int index) Deprecated.private static int
readUShort
(byte[] src, int index) Deprecated.(package private) static int
rotintlft
(int val, int numbits) Deprecated.(package private) static void
writeULong
(byte[] buffer, int value, int offset) Deprecated.(package private) static void
writeUShort
(byte[] buffer, int value, int offset) Deprecated.
-
Field Details
-
UNICODE_LITTLE_UNMARKED
Deprecated.Unicode encoding -
DEFAULT_CHARSET
Deprecated.Character encoding -
FLAG_REQUEST_UNICODE_ENCODING
static final int FLAG_REQUEST_UNICODE_ENCODINGDeprecated.- See Also:
-
FLAG_REQUEST_OEM_ENCODING
static final int FLAG_REQUEST_OEM_ENCODINGDeprecated.- See Also:
-
FLAG_REQUEST_TARGET
static final int FLAG_REQUEST_TARGETDeprecated.- See Also:
-
FLAG_REQUEST_SIGN
static final int FLAG_REQUEST_SIGNDeprecated.- See Also:
-
FLAG_REQUEST_SEAL
static final int FLAG_REQUEST_SEALDeprecated.- See Also:
-
FLAG_REQUEST_LAN_MANAGER_KEY
static final int FLAG_REQUEST_LAN_MANAGER_KEYDeprecated.- See Also:
-
FLAG_REQUEST_NTLMv1
static final int FLAG_REQUEST_NTLMv1Deprecated.- See Also:
-
FLAG_DOMAIN_PRESENT
static final int FLAG_DOMAIN_PRESENTDeprecated.- See Also:
-
FLAG_WORKSTATION_PRESENT
static final int FLAG_WORKSTATION_PRESENTDeprecated.- See Also:
-
FLAG_REQUEST_ALWAYS_SIGN
static final int FLAG_REQUEST_ALWAYS_SIGNDeprecated.- See Also:
-
FLAG_REQUEST_NTLM2_SESSION
static final int FLAG_REQUEST_NTLM2_SESSIONDeprecated.- See Also:
-
FLAG_REQUEST_VERSION
static final int FLAG_REQUEST_VERSIONDeprecated.- See Also:
-
FLAG_TARGETINFO_PRESENT
static final int FLAG_TARGETINFO_PRESENTDeprecated.- See Also:
-
FLAG_REQUEST_128BIT_KEY_EXCH
static final int FLAG_REQUEST_128BIT_KEY_EXCHDeprecated.- See Also:
-
FLAG_REQUEST_EXPLICIT_KEY_EXCH
static final int FLAG_REQUEST_EXPLICIT_KEY_EXCHDeprecated.- See Also:
-
FLAG_REQUEST_56BIT_ENCRYPTION
static final int FLAG_REQUEST_56BIT_ENCRYPTIONDeprecated.- See Also:
-
MSV_AV_EOL
static final int MSV_AV_EOLDeprecated.- See Also:
-
MSV_AV_NB_COMPUTER_NAME
static final int MSV_AV_NB_COMPUTER_NAMEDeprecated.- See Also:
-
MSV_AV_NB_DOMAIN_NAME
static final int MSV_AV_NB_DOMAIN_NAMEDeprecated.- See Also:
-
MSV_AV_DNS_COMPUTER_NAME
static final int MSV_AV_DNS_COMPUTER_NAMEDeprecated.- See Also:
-
MSV_AV_DNS_DOMAIN_NAME
static final int MSV_AV_DNS_DOMAIN_NAMEDeprecated.- See Also:
-
MSV_AV_DNS_TREE_NAME
static final int MSV_AV_DNS_TREE_NAMEDeprecated.- See Also:
-
MSV_AV_FLAGS
static final int MSV_AV_FLAGSDeprecated.- See Also:
-
MSV_AV_TIMESTAMP
static final int MSV_AV_TIMESTAMPDeprecated.- See Also:
-
MSV_AV_SINGLE_HOST
static final int MSV_AV_SINGLE_HOSTDeprecated.- See Also:
-
MSV_AV_TARGET_NAME
static final int MSV_AV_TARGET_NAMEDeprecated.- See Also:
-
MSV_AV_CHANNEL_BINDINGS
static final int MSV_AV_CHANNEL_BINDINGSDeprecated.- See Also:
-
MSV_AV_FLAGS_ACCOUNT_AUTH_CONSTAINED
static final int MSV_AV_FLAGS_ACCOUNT_AUTH_CONSTAINEDDeprecated.- See Also:
-
MSV_AV_FLAGS_MIC
static final int MSV_AV_FLAGS_MICDeprecated.- See Also:
-
MSV_AV_FLAGS_UNTRUSTED_TARGET_SPN
static final int MSV_AV_FLAGS_UNTRUSTED_TARGET_SPNDeprecated.- See Also:
-
RND_GEN
Deprecated.Secure random generator -
SIGNATURE
private static final byte[] SIGNATUREDeprecated.The signature string as bytes in the default encoding -
SIGN_MAGIC_SERVER
private static final byte[] SIGN_MAGIC_SERVERDeprecated. -
SIGN_MAGIC_CLIENT
private static final byte[] SIGN_MAGIC_CLIENTDeprecated. -
SEAL_MAGIC_SERVER
private static final byte[] SEAL_MAGIC_SERVERDeprecated. -
SEAL_MAGIC_CLIENT
private static final byte[] SEAL_MAGIC_CLIENTDeprecated. -
MAGIC_TLS_SERVER_ENDPOINT
private static final byte[] MAGIC_TLS_SERVER_ENDPOINTDeprecated. -
TYPE_1_MESSAGE
Deprecated.
-
-
Constructor Details
-
NTLMEngineImpl
NTLMEngineImpl()Deprecated.
-
-
Method Details
-
getNullTerminatedAsciiString
Deprecated. -
getResponseFor
static String getResponseFor(String message, String username, char[] password, String host, String domain) throws NTLMEngineException Deprecated.Returns the response for the given message.- Parameters:
message
- the message that was received from the server.username
- the username to authenticate with.password
- the password to authenticate with.host
- The host.domain
- the NT domain to authenticate in.- Returns:
- The response.
- Throws:
NTLMEngineException
-
getResponseFor
static String getResponseFor(String message, String username, char[] password, String host, String domain, Certificate peerServerCertificate) throws NTLMEngineException Deprecated.Returns the response for the given message.- Parameters:
message
- the message that was received from the server.username
- the username to authenticate with.password
- the password to authenticate with.host
- The host.domain
- the NT domain to authenticate in.- Returns:
- The response.
- Throws:
NTLMEngineException
-
getType1Message
Deprecated.Creates the first message (type 1 message) in the NTLM authentication sequence. This message includes the user name, domain and host for the authentication session.- Parameters:
host
- the computer name of the host requesting authentication.domain
- The domain to authenticate with.- Returns:
- String the message to add to the HTTP request header.
-
getType3Message
static String getType3Message(String user, char[] password, String host, String domain, byte[] nonce, int type2Flags, String target, byte[] targetInformation) throws NTLMEngineException Deprecated.Creates the type 3 message using the given server nonce. The type 3 message includes all the information for authentication, host, domain, username and the result of encrypting the nonce sent by the server using the user's password as the key.- Parameters:
user
- The user name. This should not include the domain name.password
- The password.host
- The host that is originating the authentication request.domain
- The domain to authenticate within.nonce
- the 8 byte array the server sent.- Returns:
- The type 3 message.
- Throws:
NTLMEngineException
- IfType3Message(String, String, String, char[], byte[], int, String, byte[])
fails.
-
getType3Message
static String getType3Message(String user, char[] password, String host, String domain, byte[] nonce, int type2Flags, String target, byte[] targetInformation, Certificate peerServerCertificate, byte[] type1Message, byte[] type2Message) throws NTLMEngineException Deprecated.Creates the type 3 message using the given server nonce. The type 3 message includes all the information for authentication, host, domain, username and the result of encrypting the nonce sent by the server using the user's password as the key.- Parameters:
user
- The user name. This should not include the domain name.password
- The password.host
- The host that is originating the authentication request.domain
- The domain to authenticate within.nonce
- the 8 byte array the server sent.- Returns:
- The type 3 message.
- Throws:
NTLMEngineException
-
readULong
private static int readULong(byte[] src, int index) Deprecated. -
readUShort
private static int readUShort(byte[] src, int index) Deprecated. -
readSecurityBuffer
private static byte[] readSecurityBuffer(byte[] src, int index) Deprecated. -
makeRandomChallenge
Deprecated.Calculate a challenge block -
makeSecondaryKey
Deprecated.Calculate a 16-byte secondary key -
hmacMD5
static byte[] hmacMD5(byte[] value, byte[] key) Deprecated.Calculates HMAC-MD5 -
RC4
Deprecated.Calculates RC4- Throws:
NTLMEngineException
-
ntlm2SessionResponse
static byte[] ntlm2SessionResponse(byte[] ntlmHash, byte[] challenge, byte[] clientChallenge) throws NTLMEngineException Deprecated.Calculates the NTLM2 Session Response for the given challenge, using the specified password and client challenge.- 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 challenge, null-padded to 24 bytes.
- Throws:
NTLMEngineException
-
lmHash
Deprecated.Creates the LM Hash of the user's password.- Parameters:
password
- The password.- Returns:
- The LM Hash of the given password, used in the calculation of the LM Response.
- Throws:
NTLMEngineException
-
ntlmHash
Deprecated.Creates the NTLM Hash of the user's password.- Parameters:
password
- The password.- Returns:
- The NTLM Hash of the given password, used in the calculation of the NTLM Response and the NTLMv2 and LMv2 Hashes.
- Throws:
NTLMEngineException
-
lmv2Hash
private static byte[] lmv2Hash(String domain, String user, byte[] ntlmHash) throws NTLMEngineException Deprecated.Creates the LMv2 Hash of the user's password.- Returns:
- The LMv2 Hash, used in the calculation of the NTLMv2 and LMv2 Responses.
- Throws:
NTLMEngineException
-
ntlmv2Hash
private static byte[] ntlmv2Hash(String domain, String user, byte[] ntlmHash) throws NTLMEngineException Deprecated.Creates the NTLMv2 Hash of the user's password.- Returns:
- The NTLMv2 Hash, used in the calculation of the NTLMv2 and LMv2 Responses.
- Throws:
NTLMEngineException
-
lmResponse
Deprecated.Creates the LM Response from the given hash and Type 2 challenge.- Parameters:
hash
- The LM or NTLM Hash.challenge
- The server challenge from the Type 2 message.- Returns:
- The response (either LM or NTLM, depending on the provided hash).
- Throws:
NTLMEngineException
-
lmv2Response
private static byte[] lmv2Response(byte[] hash, byte[] challenge, byte[] clientData) Deprecated.Creates the LMv2 Response from the given hash, client data, and Type 2 challenge.- Parameters:
hash
- The NTLMv2 Hash.challenge
- The server challenge from the Type 2 message.clientData
- The client data (blob or client challenge).- Returns:
- The response (either NTLMv2 or LMv2, depending on the client data).
-
encodeLong
private static byte[] encodeLong(int value) Deprecated. -
encodeLong
private static void encodeLong(byte[] buf, int offset, int value) Deprecated. -
createBlob
private static byte[] createBlob(byte[] clientChallenge, byte[] targetInformation, byte[] timestamp) Deprecated.Creates the NTLMv2 blob from the given target information block and client challenge.- Parameters:
clientChallenge
- The random 8-byte client challenge.targetInformation
- The target information block from the Type 2 message.- Returns:
- The blob, used in the calculation of the NTLMv2 Response.
-
createDESKey
Deprecated.Creates a DES encryption key from the given key material.- Parameters:
bytes
- A byte array containing the DES key material.offset
- The offset in the given byte array at which the 7-byte key material starts.- Returns:
- A DES encryption key created from the key material starting at the specified offset in the given byte array.
-
oddParity
private static void oddParity(byte[] bytes) Deprecated.Applies odd parity to the given byte array.- Parameters:
bytes
- The data whose parity bits are to be adjusted for odd parity.
-
getCharset
Deprecated.Find the character set based on the flags.- Parameters:
flags
- is the flags.- Returns:
- the character set.
- Throws:
NTLMEngineException
-
writeUShort
static void writeUShort(byte[] buffer, int value, int offset) Deprecated. -
writeULong
static void writeULong(byte[] buffer, int value, int offset) Deprecated. -
F
static int F(int x, int y, int z) Deprecated. -
G
static int G(int x, int y, int z) Deprecated. -
H
static int H(int x, int y, int z) Deprecated. -
rotintlft
static int rotintlft(int val, int numbits) Deprecated. -
getMD5
Deprecated. -
generateType1Msg
Deprecated.Description copied from interface:NTLMEngine
Generates a Type1 message given the domain and workstation.- Specified by:
generateType1Msg
in interfaceNTLMEngine
- Parameters:
domain
- Optional Windows domain name. Can benull
.workstation
- Optional Windows workstation name. Can benull
.- Returns:
- Type1 message
- Throws:
NTLMEngineException
-
generateType3Msg
public String generateType3Msg(String username, char[] password, String domain, String workstation, String challenge) throws NTLMEngineException Deprecated.Description copied from interface:NTLMEngine
Generates a Type3 message given the user credentials and the authentication challenge.- Specified by:
generateType3Msg
in interfaceNTLMEngine
- Parameters:
username
- Windows user namepassword
- Passworddomain
- Windows domain nameworkstation
- Windows workstation namechallenge
- Type2 challenge.- Returns:
- Type3 response.
- Throws:
NTLMEngineException
-