Top Description Fields Constructors Methods
org.postgresql.sspi

public Class SSPIClient

extends Object
implements ISSPIClient
Class Inheritance
All Implemented Interfaces
org.postgresql.sspi.ISSPIClient
Static Imports
org.postgresql.util.internal.Nullness.castNonNull

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.

Author
craig

Field Summary

Modifier and TypeField and Description
private @Nullable IWindowsCredentialsHandle
private final boolean
private static final Logger
private final PGStream
private static final Constructor<? extends Sspi.SecBufferDesc>
private final String
public static final String
private @Nullable WindowsSecurityContextImpl
private @Nullable String

Constructor Summary

AccessConstructor and Description
public
SSPIClient(PGStream
PostgreSQL connection stream
pgStream
,
String
SSPI SPN service class, defaults to POSTGRES if null
spnServiceClass
,
boolean
enable negotiate
enableNegotiate
)

Instantiate an SSPIClient for authentication of a connection.

Method Summary

Modifier and TypeMethod and Description
public void
continueSSPI(int
Length of message to read, excluding length word and message type word
msgLength
)

Implements org.postgresql.sspi.ISSPIClient.continueSSPI.

Continue an existing authentication conversation with the back-end in response to an authentication request of type AUTH_REQ_GSS_CONT.

public void
dispose()

Implements org.postgresql.sspi.ISSPIClient.dispose.

Clean up native win32 resources after completion or failure of SSPI authentication.

public boolean

Returns:

true if it's safe to attempt SSPI authentication
isSSPISupported
()

Implements org.postgresql.sspi.ISSPIClient.isSSPISupported.

Test whether we can attempt SSPI authentication.

private String
private void
sendSSPIResponse(byte[] outToken)

public void
startSSPI()

Implements org.postgresql.sspi.ISSPIClient.startSSPI.

Respond to an authentication request from the back-end for SSPI authentication (AUTH_REQ_SSPI).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clientCredentialsback to summary
private @Nullable IWindowsCredentialsHandle clientCredentials
enableNegotiateback to summary
private final boolean enableNegotiate
LOGGERback to summary
private static final Logger LOGGER
pgStreamback to summary
private final PGStream pgStream
SEC_BUFFER_DESC_FACTORYback to summary
private static final Constructor<? extends Sspi.SecBufferDesc> SEC_BUFFER_DESC_FACTORY
spnServiceClassback to summary
private final String spnServiceClass
SSPI_DEFAULT_SPN_SERVICE_CLASSback to summary
public static final String SSPI_DEFAULT_SPN_SERVICE_CLASS
sspiContextback to summary
private @Nullable WindowsSecurityContextImpl sspiContext
targetNameback to summary
private @Nullable String targetName

Constructor Detail

SSPIClientback to summary
public SSPIClient(PGStream pgStream, 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().

Parameters
pgStream:PGStream

PostgreSQL connection stream

spnServiceClass:String

SSPI SPN service class, defaults to POSTGRES if null

enableNegotiate:boolean

enable negotiate

Method Detail

continueSSPIback to summary
public void continueSSPI(int msgLength) throws SQLException, IOException

Implements org.postgresql.sspi.ISSPIClient.continueSSPI.

Continue an existing authentication conversation with the back-end in response to an authentication request of type AUTH_REQ_GSS_CONT.

Parameters
msgLength:int

Length of message to read, excluding length word and message type word

Annotations
@Override
Exceptions
SQLException:
if something wrong happens
IOException:
if something wrong happens
disposeback to summary
public void dispose()

Implements org.postgresql.sspi.ISSPIClient.dispose.

Clean up native win32 resources after completion or failure of SSPI authentication. This SSPIClient instance becomes unusable after disposal.

Annotations
@Override
isSSPISupportedback to summary
public boolean isSSPISupported()

Implements org.postgresql.sspi.ISSPIClient.isSSPISupported.

Test whether we can attempt SSPI authentication. If false, do not attempt to call any other SSPIClient methods.

Returns:boolean

true if it's safe to attempt SSPI authentication

Annotations
@Override
makeSPNback to summary
private String makeSPN() throws PSQLException
sendSSPIResponseback to summary
private void sendSSPIResponse(byte[] outToken) throws IOException
startSSPIback to summary
public void startSSPI() throws SQLException, IOException

Implements org.postgresql.sspi.ISSPIClient.startSSPI.

Respond to an authentication request from the back-end for SSPI authentication (AUTH_REQ_SSPI).

Annotations
@Override
Exceptions
SQLException:
on SSPI authentication handshake failure
IOException:
on network I/O issues