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.ASN1ObjectIdentifier
NTLMSSP_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 Type3Message
createType3Message(Type2Message msg2)
void
dispose()
int
getFlags()
String
getNetbiosName()
byte[]
getServerChallenge()
byte[]
getSigningKey()
org.bouncycastle.asn1.ASN1ObjectIdentifier[]
getSupportedMechs()
byte[]
initSecContext(byte[] token, int offset, int len)
protected void
initSessionSecurity(byte[] mk)
boolean
isEstablished()
boolean
isMICAvailable()
boolean
isPreferredMech(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism)
boolean
isSupported(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism)
protected byte[]
makeAuthenticate(byte[] token)
protected byte[]
makeNegotiate(byte[] token)
void
setTargetName(String targetName)
boolean
supportsIntegrity()
String
toString()
void
verifyMIC(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:
getSupportedMechs
in interfaceSSPContext
- Returns:
- array of supported mechanism OIDs
- See Also:
SSPContext.getSupportedMechs()
-
getFlags
public int getFlags()
- Specified by:
getFlags
in interfaceSSPContext
- Returns:
- context flags
- See Also:
SSPContext.getFlags()
-
isSupported
public boolean isSupported(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism)
- Specified by:
isSupported
in 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:
isPreferredMech
in interfaceSSPContext
- Returns:
- whether the specified mechanism is preferred
- See Also:
SSPContext.isPreferredMech(org.bouncycastle.asn1.ASN1ObjectIdentifier)
-
isEstablished
public boolean isEstablished()
- Specified by:
isEstablished
in interfaceSSPContext
- Returns:
- whether the context is established
-
getServerChallenge
public byte[] getServerChallenge()
- Returns:
- the server's challenge
-
getSigningKey
public byte[] getSigningKey()
- Specified by:
getSigningKey
in interfaceSSPContext
- Returns:
- the signing key for the session
-
getNetbiosName
public String getNetbiosName()
- Specified by:
getNetbiosName
in 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:
initSecContext
in 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:
GeneralSecurityException
CIFSException
-
makeNegotiate
protected byte[] makeNegotiate(byte[] token)
-
initSessionSecurity
protected void initSessionSecurity(byte[] mk)
-
supportsIntegrity
public boolean supportsIntegrity()
- Specified by:
supportsIntegrity
in interfaceSSPContext
- Returns:
- whether this mechanisms supports integrity
-
isMICAvailable
public boolean isMICAvailable()
- Specified by:
isMICAvailable
in interfaceSSPContext
- Returns:
- whether MIC can be used
-
calculateMIC
public byte[] calculateMIC(byte[] data) throws CIFSException
- Specified by:
calculateMIC
in interfaceSSPContext
- Returns:
- MIC
- Throws:
CIFSException
-
verifyMIC
public void verifyMIC(byte[] data, byte[] mic) throws CIFSException
- Specified by:
verifyMIC
in interfaceSSPContext
- Throws:
CIFSException
-
dispose
public void dispose() throws SmbException
- Specified by:
dispose
in interfaceSSPContext
- Throws:
SmbException
- See Also:
SSPContext.dispose()
-
-