Package net.sourceforge.jtds.util
Class SSPIJNIClient
- java.lang.Object
-
- net.sourceforge.jtds.util.SSPIJNIClient
-
public class SSPIJNIClient extends java.lang.Object
A JNI client to SSPI based CPP program (DLL) that returns the user credentials for NTLM authentication. The DLL name is ntlmauth.dll.- Author:
- Magendran Sathaiah (mahi@aztec.soft.net)
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
initialized
SSPI client initialized flag.private static boolean
libraryLoaded
SSPI native library loaded flag.private static SSPIJNIClient
thisInstance
Singleton instance.
-
Constructor Summary
Constructors Modifier Constructor Description private
SSPIJNIClient()
Private constructor for singleton.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SSPIJNIClient
getInstance()
Returns the singletonSSPIJNIClient
instance.private void
initialize()
Initializes the SSPI client.void
invokeInitialize()
Calls#initialize()
if the SSPI client is not already inited.byte[]
invokePrepareSSORequest()
Calls#prepareSSORequest()
to prepare the NTLM TYPE-1 message.byte[]
invokePrepareSSOSubmit(byte[] buf)
Calls#prepareSSOSubmit(byte[], long)
to prepare the NTLM TYPE-3 message.void
invokeUnInitialize()
Calls#unInitialize()
if the SSPI client is inited.private byte[]
prepareSSORequest()
Prepares the NTLM TYPE-1 message and returns it as abyte[]
.private byte[]
prepareSSOSubmit(byte[] buf, long size)
Prepares the NTLM TYPE-3 message using the current user's credentials.private void
unInitialize()
Uninitializes the SSPI client.
-
-
-
Field Detail
-
thisInstance
private static SSPIJNIClient thisInstance
Singleton instance.
-
libraryLoaded
private static boolean libraryLoaded
SSPI native library loaded flag.
-
initialized
private boolean initialized
SSPI client initialized flag.
-
-
Method Detail
-
initialize
private void initialize()
Initializes the SSPI client.
-
unInitialize
private void unInitialize()
Uninitializes the SSPI client.
-
prepareSSORequest
private byte[] prepareSSORequest()
Prepares the NTLM TYPE-1 message and returns it as abyte[]
.
-
prepareSSOSubmit
private byte[] prepareSSOSubmit(byte[] buf, long size)
Prepares the NTLM TYPE-3 message using the current user's credentials.It needs the challenge BLOB and it's size as input. The challenge BLOB is nothig but the TYPE-2 message that is received from the SQL Server.
- Parameters:
buf
- challenge BLOBsize
- challenge BLOB size- Returns:
- NTLM TYPE-3 message
-
getInstance
public static SSPIJNIClient getInstance() throws java.lang.Exception
Returns the singletonSSPIJNIClient
instance.- Throws:
java.sql.SQLException
- if an error occurs during initializationjava.lang.Exception
-
invokeInitialize
public void invokeInitialize()
Calls#initialize()
if the SSPI client is not already inited.
-
invokeUnInitialize
public void invokeUnInitialize()
Calls#unInitialize()
if the SSPI client is inited.
-
invokePrepareSSORequest
public byte[] invokePrepareSSORequest() throws java.lang.Exception
Calls#prepareSSORequest()
to prepare the NTLM TYPE-1 message.- Throws:
java.lang.Exception
- if an error occurs during the call or the SSPI client is uninitialized
-
invokePrepareSSOSubmit
public byte[] invokePrepareSSOSubmit(byte[] buf) throws java.lang.Exception
Calls#prepareSSOSubmit(byte[], long)
to prepare the NTLM TYPE-3 message.- Throws:
java.lang.Exception
- if an error occurs during the call or the SSPI client is uninitialized
-
-