public class SSPIClient extends java.lang.Object implements ISSPIClient
Use Waffle-JNI to support SSPI authentication when PgJDBC is running on a Windows client and talking to a Windows server.
SSPI is not supported on a non-Windows client.
Modifier and Type | Field and Description |
---|---|
private IWindowsCredentialsHandle |
clientCredentials |
private boolean |
enableNegotiate |
private static java.util.logging.Logger |
LOGGER |
private PGStream |
pgStream |
private java.lang.String |
spnServiceClass |
static java.lang.String |
SSPI_DEFAULT_SPN_SERVICE_CLASS |
private WindowsSecurityContextImpl |
sspiContext |
private java.lang.String |
targetName |
Constructor and Description |
---|
SSPIClient(PGStream pgStream,
java.lang.String spnServiceClass,
boolean enableNegotiate)
Instantiate an SSPIClient for authentication of a connection.
|
Modifier and Type | Method and Description |
---|---|
void |
continueSSPI(int msgLength)
Continue an existing authentication conversation with the back-end in resonse to an
authentication request of type AUTH_REQ_GSS_CONT.
|
void |
dispose()
Clean up native win32 resources after completion or failure of SSPI authentication.
|
boolean |
isSSPISupported()
Test whether we can attempt SSPI authentication.
|
private java.lang.String |
makeSPN() |
private void |
sendSSPIResponse(byte[] outToken) |
void |
startSSPI()
Respond to an authentication request from the back-end for SSPI authentication (AUTH_REQ_SSPI).
|
public static java.lang.String SSPI_DEFAULT_SPN_SERVICE_CLASS
private static final java.util.logging.Logger LOGGER
private final PGStream pgStream
private final java.lang.String spnServiceClass
private final boolean enableNegotiate
private IWindowsCredentialsHandle clientCredentials
private WindowsSecurityContextImpl sspiContext
private java.lang.String targetName
public SSPIClient(PGStream pgStream, java.lang.String spnServiceClass, boolean enableNegotiate)
Instantiate an SSPIClient for authentication of a connection.
SSPIClient is not re-usable across connections.
It is safe to instantiate SSPIClient even if Waffle and JNA are missing or on non-Windows platforms, however you may not call any methods other than isSSPISupported().
pgStream
- PostgreSQL connection streamspnServiceClass
- SSPI SPN service class, defaults to POSTGRES if nullenableNegotiate
- enable negotiatepublic boolean isSSPISupported()
isSSPISupported
in interface ISSPIClient
private java.lang.String makeSPN() throws PSQLException
PSQLException
public void startSSPI() throws java.sql.SQLException, java.io.IOException
startSSPI
in interface ISSPIClient
java.sql.SQLException
- on SSPI authentication handshake failurejava.io.IOException
- on network I/O issuespublic void continueSSPI(int msgLength) throws java.sql.SQLException, java.io.IOException
continueSSPI
in interface ISSPIClient
msgLength
- Length of message to read, excluding length word and message type wordjava.sql.SQLException
- if something wrong happensjava.io.IOException
- if something wrong happensprivate void sendSSPIResponse(byte[] outToken) throws java.io.IOException
java.io.IOException
public void dispose()
dispose
in interface ISSPIClient