Package jcifs.smb
Class NtlmContext
- java.lang.Object
-
- jcifs.smb.NtlmContext
-
- All Implemented Interfaces:
SSPContext
public class NtlmContext extends Object implements SSPContext
For initiating NTLM authentication (including NTLMv2). If you want to add NTLMv2 authentication support to something this is what you want to use. See the code for details. Note that JCIFS does not implement the acceptor side of NTLM authentication.
-
-
Field Summary
Fields Modifier and Type Field Description static org.bouncycastle.asn1.ASN1ObjectIdentifierNTLMSSP_OID
-
Constructor Summary
Constructors Constructor Description NtlmContext(CIFSContext tc, NtlmPasswordAuthenticator auth, boolean doSigning)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]calculateMIC(byte[] data)protected Type3MessagecreateType3Message(Type2Message msg2)voiddispose()intgetFlags()StringgetNetbiosName()byte[]getServerChallenge()byte[]getSigningKey()org.bouncycastle.asn1.ASN1ObjectIdentifier[]getSupportedMechs()byte[]initSecContext(byte[] token, int offset, int len)protected voidinitSessionSecurity(byte[] mk)booleanisEstablished()booleanisMICAvailable()booleanisPreferredMech(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism)booleanisSupported(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism)protected byte[]makeAuthenticate(byte[] token)protected byte[]makeNegotiate(byte[] token)voidsetTargetName(String targetName)booleansupportsIntegrity()StringtoString()voidverifyMIC(byte[] data, byte[] mic)
-
-
-
Constructor Detail
-
NtlmContext
public NtlmContext(CIFSContext tc, NtlmPasswordAuthenticator auth, boolean doSigning)
- Parameters:
tc- context to useauth- credentialsdoSigning- whether signing is requested
-
-
Method Detail
-
getSupportedMechs
public org.bouncycastle.asn1.ASN1ObjectIdentifier[] getSupportedMechs()
- Specified by:
getSupportedMechsin interfaceSSPContext- Returns:
- array of supported mechanism OIDs
- See Also:
SSPContext.getSupportedMechs()
-
getFlags
public int getFlags()
- Specified by:
getFlagsin interfaceSSPContext- Returns:
- context flags
- See Also:
SSPContext.getFlags()
-
isSupported
public boolean isSupported(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism)
- Specified by:
isSupportedin interfaceSSPContext- Returns:
- whether the specified mechanism is supported
- See Also:
SSPContext.isSupported(org.bouncycastle.asn1.ASN1ObjectIdentifier)
-
isPreferredMech
public boolean isPreferredMech(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism)
- Specified by:
isPreferredMechin interfaceSSPContext- Returns:
- whether the specified mechanism is preferred
- See Also:
SSPContext.isPreferredMech(org.bouncycastle.asn1.ASN1ObjectIdentifier)
-
isEstablished
public boolean isEstablished()
- Specified by:
isEstablishedin interfaceSSPContext- Returns:
- whether the context is established
-
getServerChallenge
public byte[] getServerChallenge()
- Returns:
- the server's challenge
-
getSigningKey
public byte[] getSigningKey()
- Specified by:
getSigningKeyin interfaceSSPContext- Returns:
- the signing key for the session
-
getNetbiosName
public String getNetbiosName()
- Specified by:
getNetbiosNamein interfaceSSPContext- Returns:
- the name of the remote endpoint
-
setTargetName
public void setTargetName(String targetName)
- Parameters:
targetName- the target's SPN
-
initSecContext
public byte[] initSecContext(byte[] token, int offset, int len) throws SmbException- Specified by:
initSecContextin interfaceSSPContext- Returns:
- result token
- Throws:
SmbException
-
makeAuthenticate
protected byte[] makeAuthenticate(byte[] token) throws SmbException- Throws:
SmbException
-
createType3Message
protected Type3Message createType3Message(Type2Message msg2) throws GeneralSecurityException, CIFSException
- Parameters:
msg2-- Returns:
- Throws:
GeneralSecurityExceptionCIFSException
-
makeNegotiate
protected byte[] makeNegotiate(byte[] token)
-
initSessionSecurity
protected void initSessionSecurity(byte[] mk)
-
supportsIntegrity
public boolean supportsIntegrity()
- Specified by:
supportsIntegrityin interfaceSSPContext- Returns:
- whether this mechanisms supports integrity
-
isMICAvailable
public boolean isMICAvailable()
- Specified by:
isMICAvailablein interfaceSSPContext- Returns:
- whether MIC can be used
-
calculateMIC
public byte[] calculateMIC(byte[] data) throws CIFSException- Specified by:
calculateMICin interfaceSSPContext- Returns:
- MIC
- Throws:
CIFSException
-
verifyMIC
public void verifyMIC(byte[] data, byte[] mic) throws CIFSException- Specified by:
verifyMICin interfaceSSPContext- Throws:
CIFSException
-
dispose
public void dispose() throws SmbException- Specified by:
disposein interfaceSSPContext- Throws:
SmbException- See Also:
SSPContext.dispose()
-
-