java.lang.Object
org.codelibs.jcifs.smb.ntlmssp.NtlmMessage
org.codelibs.jcifs.smb.ntlmssp.Type3Message
- All Implemented Interfaces:
NtlmFlags
Represents an NTLMSSP Type-3 message.
-
Field Summary
Fields inherited from class org.codelibs.jcifs.smb.ntlmssp.NtlmMessage
NTLMSSP_SIGNATURE, NTLMSSP_TYPE1, NTLMSSP_TYPE2, NTLMSSP_TYPE3, NTLMSSP_VERSION, UNI_ENCODINGFields inherited from interface org.codelibs.jcifs.smb.ntlmssp.NtlmFlags
NTLMSSP_NEGOTIATE_128, NTLMSSP_NEGOTIATE_56, NTLMSSP_NEGOTIATE_ALWAYS_SIGN, NTLMSSP_NEGOTIATE_ANONYMOUS, NTLMSSP_NEGOTIATE_DATAGRAM_STYLE, NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY, NTLMSSP_NEGOTIATE_KEY_EXCH, NTLMSSP_NEGOTIATE_LM_KEY, NTLMSSP_NEGOTIATE_LOCAL_CALL, NTLMSSP_NEGOTIATE_NETWARE, NTLMSSP_NEGOTIATE_NTLM, NTLMSSP_NEGOTIATE_OEM, NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED, NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED, NTLMSSP_NEGOTIATE_SEAL, NTLMSSP_NEGOTIATE_SIGN, NTLMSSP_NEGOTIATE_TARGET_INFO, NTLMSSP_NEGOTIATE_UNICODE, NTLMSSP_NEGOTIATE_VERSION, NTLMSSP_REQUEST_ACCEPT_RESPONSE, NTLMSSP_REQUEST_INIT_RESPONSE, NTLMSSP_REQUEST_NON_NT_SESSION_KEY, NTLMSSP_REQUEST_TARGET, NTLMSSP_TARGET_TYPE_DOMAIN, NTLMSSP_TARGET_TYPE_SERVER, NTLMSSP_TARGET_TYPE_SHARE -
Constructor Summary
ConstructorsConstructorDescriptionType3Message(byte[] material) Creates a Type-3 message using the given raw Type-3 material.Type3Message(int flags, byte[] lmResponse, byte[] ntResponse, String domain, String user, String workstation) Creates a Type-3 message with the specified parameters.Creates a Type-3 message using default values from the current environment.Type3Message(CIFSContext tc, Type2Message type2, String targetName, byte[] passwordHash, String domain, String user, String workstation, int flags) Creates a Type-3 message in response to the given Type-2 message.Type3Message(CIFSContext tc, Type2Message type2, String targetName, byte[] passwordHash, String password, String domain, String user, String workstation, int flags, boolean nonAnonymous) Creates a Type-3 message in response to the given Type-2 message.Type3Message(CIFSContext tc, Type2Message type2, String targetName, String password, String domain, String user, String workstation, int flags) Creates a Type-3 message in response to the given Type-2 message.Type3Message(CIFSContext tc, Type2Message type2, String targetName, String password, String domain, String user, String workstation, int flags, boolean nonAnonymous) Creates a Type-3 message in response to the given Type-2 message. -
Method Summary
Modifier and TypeMethodDescriptionstatic intReturns the default flags for a generic Type-3 message in the current environment.static intgetDefaultFlags(CIFSContext tc, Type2Message type2) Returns the default flags for a Type-3 message created in response to the given Type-2 message in the current environment.Returns the domain in which the user has an account.byte[]Returns the session key.byte[]Returns the LanManager/LMv2 response.static byte[]getLMResponse(CIFSContext tc, Type2Message type2, String password) Constructs the LanManager response to the given Type-2 message using the supplied password.static byte[]getLMv2Response(CIFSContext tc, Type2Message type2, String domain, String user, byte[] passwordHash, byte[] clientChallenge) Calculates the LMv2 response using a pre-computed NT password hash.static byte[]getLMv2Response(CIFSContext tc, Type2Message type2, String domain, String user, String password, byte[] clientChallenge) Calculates the LMv2 response for NTLM authentication.byte[]The real session key if the regular session key is actually the encrypted version used for key exchange.byte[]getMic()Returns the message integrity code (MIC) for this Type-3 message.static byte[]getNTLMv2Response(CIFSContext tc, Type2Message type2, byte[] responseKeyNT, byte[] clientChallenge, byte[] clientChallengeInfo, long ts) Calculates the NTLMv2 response for authentication.byte[]Returns the NT/NTLMv2 response.static byte[]getNTResponse(CIFSContext tc, Type2Message type2, byte[] passwordHash) Constructs the NT response to the given Type-2 message using the supplied password.static byte[]getNTResponse(CIFSContext tc, Type2Message type2, String password) Constructs the NT response to the given Type-2 message using the supplied password.getUser()Returns the username for the authenticating user.Returns the workstation from which authentication is being performed.booleanChecks whether a message integrity code (MIC) should be calculated for this message.voidSets the domain for this message.voidsetEncryptedSessionKey(byte[] sessionKey) Sets the session key.voidsetLMResponse(byte[] lmResponse) Sets the LanManager/LMv2 response for this message.voidsetMic(byte[] mic) Sets the message integrity code (MIC) for this Type-3 message.voidsetNTResponse(byte[] ntResponse) Sets the NT/NTLMv2 response for this message.voidsetupMIC(byte[] type1, byte[] type2) Sets the MICvoidSets the user for this message.voidsetWorkstation(String workstation) Sets the workstation for this message.byte[]Returns the raw byte representation of this message.toString()Methods inherited from class org.codelibs.jcifs.smb.ntlmssp.NtlmMessage
getFlag, getFlags, setFlag, setFlags
-
Constructor Details
-
Type3Message
Creates a Type-3 message using default values from the current environment.- Parameters:
tc- context to use
-
Type3Message
public Type3Message(CIFSContext tc, Type2Message type2, String targetName, String password, String domain, String user, String workstation, int flags) throws GeneralSecurityException, CIFSException Creates a Type-3 message in response to the given Type-2 message.- Parameters:
tc- context to usetype2- The Type-2 message which this represents a response to.targetName- SPN of the target system, optionalpassword- The password to use when constructing the response.domain- The domain in which the user has an account.user- The username for the authenticating user.workstation- The workstation from which authentication is taking place.flags- the flags to use for the Type-3 message- Throws:
GeneralSecurityException- if a cryptographic error occursCIFSException- if a CIFS protocol error occurs
-
Type3Message
public Type3Message(CIFSContext tc, Type2Message type2, String targetName, String password, String domain, String user, String workstation, int flags, boolean nonAnonymous) throws GeneralSecurityException, CIFSException Creates a Type-3 message in response to the given Type-2 message.- Parameters:
tc- context to usetype2- The Type-2 message which this represents a response to.targetName- SPN of the target system, optionalpassword- The password to use when constructing the response.domain- The domain in which the user has an account.user- The username for the authenticating user.workstation- The workstation from which authentication is taking place.flags- the flags to use for the Type-3 messagenonAnonymous- actually perform authentication with empty password- Throws:
GeneralSecurityException- if a cryptographic error occursCIFSException- if a CIFS protocol error occurs
-
Type3Message
public Type3Message(CIFSContext tc, Type2Message type2, String targetName, byte[] passwordHash, String domain, String user, String workstation, int flags) throws CIFSException, GeneralSecurityException Creates a Type-3 message in response to the given Type-2 message.- Parameters:
tc- context to usetype2- The Type-2 message which this represents a response to.targetName- SPN of the target system, optionalpasswordHash- The NT password hash to use when constructing the response.domain- The domain in which the user has an account.user- The username for the authenticating user.workstation- The workstation from which authentication is taking place.flags- the flags to use for the Type-3 message- Throws:
GeneralSecurityException- if a cryptographic error occursCIFSException- if a CIFS protocol error occurs
-
Type3Message
public Type3Message(CIFSContext tc, Type2Message type2, String targetName, byte[] passwordHash, String password, String domain, String user, String workstation, int flags, boolean nonAnonymous) throws GeneralSecurityException, CIFSException Creates a Type-3 message in response to the given Type-2 message.- Parameters:
tc- context to usetype2- The Type-2 message which this represents a response to.targetName- SPN of the target system, optionalpasswordHash- The NT password hash, takes precedence over password (which is no longer required unless legacy LM authentication is needed)password- The password to use when constructing the response.domain- The domain in which the user has an account.user- The username for the authenticating user.workstation- The workstation from which authentication is taking place.flags- the flags to use for the Type-3 messagenonAnonymous- actually perform authentication with empty password- Throws:
GeneralSecurityException- if a cryptographic error occursCIFSException- if a CIFS protocol error occurs
-
Type3Message
public Type3Message(int flags, byte[] lmResponse, byte[] ntResponse, String domain, String user, String workstation) Creates a Type-3 message with the specified parameters.- Parameters:
flags- The flags to apply to this message.lmResponse- The LanManager/LMv2 response.ntResponse- The NT/NTLMv2 response.domain- The domain in which the user has an account.user- The username for the authenticating user.workstation- The workstation from which authentication is taking place.
-
Type3Message
Creates a Type-3 message using the given raw Type-3 material.- Parameters:
material- The raw Type-3 material used to construct this message.- Throws:
IOException- If an error occurs while parsing the material.
-
-
Method Details
-
setupMIC
Sets the MIC- Parameters:
type1- the Type-1 message bytestype2- the Type-2 message bytes- Throws:
GeneralSecurityException- if a cryptographic error occursIOException- if an I/O error occurs
-
getDefaultFlags
Returns the default flags for a generic Type-3 message in the current environment.- Parameters:
tc- context to use- Returns:
- An
intcontaining the default flags.
-
getDefaultFlags
Returns the default flags for a Type-3 message created in response to the given Type-2 message in the current environment.- Parameters:
tc- context to usetype2- The Type-2 message.- Returns:
- An
intcontaining the default flags.
-
getLMResponse
public byte[] getLMResponse()Returns the LanManager/LMv2 response.- Returns:
- A
byte[]containing the LanManager response.
-
setLMResponse
public void setLMResponse(byte[] lmResponse) Sets the LanManager/LMv2 response for this message.- Parameters:
lmResponse- The LanManager response.
-
getNTResponse
public byte[] getNTResponse()Returns the NT/NTLMv2 response.- Returns:
- A
byte[]containing the NT/NTLMv2 response.
-
setNTResponse
public void setNTResponse(byte[] ntResponse) Sets the NT/NTLMv2 response for this message.- Parameters:
ntResponse- The NT/NTLMv2 response.
-
getDomain
Returns the domain in which the user has an account.- Returns:
- A
Stringcontaining the domain for the user.
-
setDomain
Sets the domain for this message.- Parameters:
domain- The domain.
-
getUser
Returns the username for the authenticating user.- Returns:
- A
Stringcontaining the user for this message.
-
setUser
Sets the user for this message.- Parameters:
user- The user.
-
getWorkstation
Returns the workstation from which authentication is being performed.- Returns:
- A
Stringcontaining the workstation.
-
setWorkstation
Sets the workstation for this message.- Parameters:
workstation- The workstation.
-
getMasterKey
public byte[] getMasterKey()The real session key if the regular session key is actually the encrypted version used for key exchange.- Returns:
- A
byte[]containing the session key.
-
getEncryptedSessionKey
public byte[] getEncryptedSessionKey()Returns the session key. This is the encrypted session key included in the message, if the actual session key is desired usegetMasterKey()instead.- Returns:
- A
byte[]containing the encrypted session key.
-
setEncryptedSessionKey
public void setEncryptedSessionKey(byte[] sessionKey) Sets the session key.- Parameters:
sessionKey- The session key.
-
getMic
public byte[] getMic()Returns the message integrity code (MIC) for this Type-3 message.- Returns:
- A
byte[]containing the message integrity code.
-
setMic
public void setMic(byte[] mic) Sets the message integrity code (MIC) for this Type-3 message.- Parameters:
mic- NTLM mic to set (16 bytes)
-
isMICRequired
public boolean isMICRequired()Checks whether a message integrity code (MIC) should be calculated for this message.- Returns:
- whether a MIC should be calculated
-
toByteArray
Description copied from class:NtlmMessageReturns the raw byte representation of this message.- Specified by:
toByteArrayin classNtlmMessage- Returns:
- A
byte[]containing the raw message material. - Throws:
IOException- if an error occurs during message serialization
-
toString
-
getLMResponse
public static byte[] getLMResponse(CIFSContext tc, Type2Message type2, String password) throws GeneralSecurityException Constructs the LanManager response to the given Type-2 message using the supplied password.- Parameters:
tc- context to usetype2- The Type-2 message.password- The password.- Returns:
- A
byte[]containing the LanManager response. - Throws:
GeneralSecurityException- if a cryptographic error occurs
-
getLMv2Response
public static byte[] getLMv2Response(CIFSContext tc, Type2Message type2, String domain, String user, String password, byte[] clientChallenge) throws GeneralSecurityException Calculates the LMv2 response for NTLM authentication.- Parameters:
tc- the CIFS contexttype2- the Type-2 message containing the server challengedomain- the domain nameuser- the usernamepassword- the user's passwordclientChallenge- the client challenge bytes- Returns:
- the calculated response
- Throws:
GeneralSecurityException- if a cryptographic error occurs
-
getLMv2Response
public static byte[] getLMv2Response(CIFSContext tc, Type2Message type2, String domain, String user, byte[] passwordHash, byte[] clientChallenge) throws GeneralSecurityException Calculates the LMv2 response using a pre-computed NT password hash.- Parameters:
tc- the CIFS contexttype2- the Type-2 message containing the server challengedomain- the domain nameuser- the usernamepasswordHash- NT password hashclientChallenge- the client challenge bytes- Returns:
- the calculated response
- Throws:
GeneralSecurityException- if a cryptographic error occurs
-
getNTLMv2Response
public static byte[] getNTLMv2Response(CIFSContext tc, Type2Message type2, byte[] responseKeyNT, byte[] clientChallenge, byte[] clientChallengeInfo, long ts) Calculates the NTLMv2 response for authentication.- Parameters:
tc- context to usetype2- The Type-2 message.responseKeyNT- the NT response keyclientChallenge- the client challenge bytesclientChallengeInfo- additional client challenge informationts- timestamp (nanos since 1601)- Returns:
- A
byte[]containing the NTLMv2 response.
-
getNTResponse
public static byte[] getNTResponse(CIFSContext tc, Type2Message type2, String password) throws GeneralSecurityException Constructs the NT response to the given Type-2 message using the supplied password.- Parameters:
tc- context to usetype2- The Type-2 message.password- The password.- Returns:
- A
byte[]containing the NT response. - Throws:
GeneralSecurityException- if a cryptographic error occurs
-
getNTResponse
public static byte[] getNTResponse(CIFSContext tc, Type2Message type2, byte[] passwordHash) throws GeneralSecurityException Constructs the NT response to the given Type-2 message using the supplied password.- Parameters:
tc- context to usetype2- The Type-2 message.passwordHash- The NT password hash.- Returns:
- A
byte[]containing the NT response. - Throws:
GeneralSecurityException- if a cryptographic error occurs
-