Interface CustomCredentialsProvider
Consider using the default implementation com.spotfire.ws.im.ds.sql.TokenCredentialsProvider
which is capable
of providing access tokens established when the user logs in.
An alternative to implementing this interface could be to implement the
com.spotfire.ws.im.ds.authspi.CredentialsProvider
(for plain username/password credentials).
Implementations of this interface must be thread-safe and reentrant.
- Since:
- 11.7
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
destroy()
Destroys thisCustomCredentialsProvider
instance.default void
init
(CustomCredentialsProviderInitContext initContext) Initializes thisCustomCredentialsProvider
instance.void
provideCredentials
(UserConnectionContext context, Properties connectionProperties) Provides credentials in the form of connection properties.default void
refreshCredentials
(UserConnectionContext context, Properties connectionProperties) Provides credentials in the form of connection properties, after attempting to refresh them.default boolean
Returnstrue
if the provider is capable of refreshing credentials so that a call torefreshCredentials(UserConnectionContext, Properties)
may succeed (and return new credentials), andfalse
otherwise.
-
Method Details
-
init
default void init(CustomCredentialsProviderInitContext initContext) throws ServiceProviderInitException Initializes thisCustomCredentialsProvider
instance. Called when a data source using aCustomCredentialsProvider
is initialized.The default implementation does nothing.
- Parameters:
initContext
- an initialization context containing initialization parameters and other information that may be used by the implementing class- Throws:
ServiceProviderInitException
- if the initialization failed- Since:
- 11.7
-
destroy
default void destroy()Destroys thisCustomCredentialsProvider
instance. Called when a data source using aCustomCredentialsProvider
is destroyed.The default implementation does nothing.
- Since:
- 11.7
-
provideCredentials
void provideCredentials(UserConnectionContext context, Properties connectionProperties) throws SQLException Provides credentials in the form of connection properties. The properties should be added to the given set of connection properties.- Parameters:
context
- the connection contextconnectionProperties
- a possibly empty set of connection properties, to which the credentials should be added- Throws:
SQLException
- if credentials could not be provided- Since:
- 11.7
-
refreshCredentials
default void refreshCredentials(UserConnectionContext context, Properties connectionProperties) throws SQLException Provides credentials in the form of connection properties, after attempting to refresh them. The properties should be added to the given set of connection properties.This method will only be called after an attempt to create a connection using credentials obtained from
provideCredentials(UserConnectionContext, Properties)
has failed, and only ifsupportsRefresh()
returnstrue
.The default implementation throws a
SQLException
.- Parameters:
context
- the connection contextconnectionProperties
- a possibly empty set of connection properties (including any properties added byprovideCredentials(UserConnectionContext, Properties)
) to which the credentials should be added- Throws:
SQLException
- if credentials could not be provided- Since:
- 11.7
- See Also:
-
supportsRefresh
default boolean supportsRefresh()Returnstrue
if the provider is capable of refreshing credentials so that a call torefreshCredentials(UserConnectionContext, Properties)
may succeed (and return new credentials), andfalse
otherwise.The default implementation returns
false
.- Returns:
true
if the provider is capable of refreshing credentials, andfalse
otherwise- Since:
- 11.7
-