Class SSPIJNIClient

java.lang.Object
net.sourceforge.jtds.util.SSPIJNIClient

public class SSPIJNIClient extends 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 Details

    • 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.
  • Constructor Details

    • SSPIJNIClient

      private SSPIJNIClient()
      Private constructor for singleton.
  • Method Details

    • 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 a byte[].
    • 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 BLOB
      size - challenge BLOB size
      Returns:
      NTLM TYPE-3 message
    • getInstance

      public static SSPIJNIClient getInstance() throws Exception
      Returns the singleton SSPIJNIClient instance.
      Throws:
      SQLException - if an error occurs during initialization
      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 Exception
      Calls #prepareSSORequest() to prepare the NTLM TYPE-1 message.
      Throws:
      Exception - if an error occurs during the call or the SSPI client is uninitialized
    • invokePrepareSSOSubmit

      public byte[] invokePrepareSSOSubmit(byte[] buf) throws Exception
      Calls #prepareSSOSubmit(byte[], long) to prepare the NTLM TYPE-3 message.
      Throws:
      Exception - if an error occurs during the call or the SSPI client is uninitialized