Interface CustomCredentialsProvider


public interface CustomCredentialsProvider
Service provider interface for Information Services data source credential providers that provide user-specific credentials of some other type than username/password (for example OAuth2 access tokens). A credentials provider of this type can be configured as part of a data source template.

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 Details

    • init

      Initializes this CustomCredentialsProvider instance. Called when a data source using a CustomCredentialsProvider 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 this CustomCredentialsProvider instance. Called when a data source using a CustomCredentialsProvider 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 context
      connectionProperties - 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 if supportsRefresh() returns true.

      The default implementation throws a SQLException.

      Parameters:
      context - the connection context
      connectionProperties - a possibly empty set of connection properties (including any properties added by provideCredentials(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()
      Returns true if the provider is capable of refreshing credentials so that a call to refreshCredentials(UserConnectionContext, Properties) may succeed (and return new credentials), and false otherwise.

      The default implementation returns false.

      Returns:
      true if the provider is capable of refreshing credentials, and false otherwise
      Since:
      11.7