public class AwsSecretsManagerConnectionPlugin extends AbstractConnectionPlugin
| Modifier and Type | Field and Description |
|---|---|
static AwsWrapperProperty |
ENDPOINT_PROPERTY |
protected @Nullable TelemetryCounter |
fetchCredentialsCounter |
protected PluginService |
pluginService |
static AwsWrapperProperty |
REGION_PROPERTY |
protected static RegionUtils |
regionUtils |
protected @Nullable software.amazon.jdbc.plugin.AwsSecretsManagerConnectionPlugin.Secret |
secret |
static AwsWrapperProperty |
SECRET_ID_PROPERTY |
protected long |
secretExpirationTime |
static AwsWrapperProperty |
SECRETS_MANAGER_EXPIRATION_SEC_PROPERTY |
static AwsWrapperProperty |
SECRETS_MANAGER_SECRET_PASSWORD_PROPERTY |
static AwsWrapperProperty |
SECRETS_MANAGER_SECRET_USERNAME_PROPERTY |
protected FullServicesContainer |
servicesContainer |
protected static java.lang.String |
TELEMETRY_UPDATE_SECRETS |
| Constructor and Description |
|---|
AwsSecretsManagerConnectionPlugin(FullServicesContainer servicesContainer,
java.util.Properties props) |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearCache() |
java.sql.Connection |
connect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc)
Establishes a connection to the given host using the given driver protocol and properties.
|
protected software.amazon.jdbc.plugin.AwsSecretsManagerConnectionPlugin.Secret |
fetchAndStoreSecret(HostSpec hostSpec)
Fetches the latest credentials from the AWS Secrets Manager service and stores them in the shared cache.
|
java.sql.Connection |
forceConnect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
JdbcCallable<java.sql.Connection,java.sql.SQLException> forceConnectFunc)
Establishes a connection to the given host using the given driver protocol and properties.
|
java.util.Set<java.lang.String> |
getSubscribedMethods() |
protected long |
resolveSecretExpirationTime(long configuredExpirationTime)
Resolves the effective credentials' expiration time (in seconds) from the configured value.
|
protected boolean |
updateSecret(HostSpec hostSpec,
boolean forceReFetch)
Called to update credentials from the cache, or from the AWS Secrets Manager service.
|
acceptsStrategy, execute, getHostSpecByStrategy, getHostSpecByStrategy, getSnapshotState, initHostProvider, notifyConnectionChanged, notifyNodeListChangedprotected static final java.lang.String TELEMETRY_UPDATE_SECRETS
public static final AwsWrapperProperty SECRET_ID_PROPERTY
public static final AwsWrapperProperty REGION_PROPERTY
public static final AwsWrapperProperty ENDPOINT_PROPERTY
public static final AwsWrapperProperty SECRETS_MANAGER_SECRET_USERNAME_PROPERTY
public static final AwsWrapperProperty SECRETS_MANAGER_SECRET_PASSWORD_PROPERTY
public static final AwsWrapperProperty SECRETS_MANAGER_EXPIRATION_SEC_PROPERTY
protected static final RegionUtils regionUtils
protected @Nullable software.amazon.jdbc.plugin.AwsSecretsManagerConnectionPlugin.Secret secret
protected final long secretExpirationTime
protected final PluginService pluginService
protected final FullServicesContainer servicesContainer
protected final @Nullable TelemetryCounter fetchCredentialsCounter
public AwsSecretsManagerConnectionPlugin(FullServicesContainer servicesContainer, java.util.Properties props)
public java.util.Set<java.lang.String> getSubscribedMethods()
getSubscribedMethods in interface ConnectionPlugingetSubscribedMethods in class AbstractConnectionPluginpublic java.sql.Connection connect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
JdbcCallable<java.sql.Connection,java.sql.SQLException> connectFunc)
throws java.sql.SQLException
ConnectionPluginConnectionProvider has been set with
Driver.setCustomConnectionProvider(ConnectionProvider) and
ConnectionProvider.acceptsUrl(String, HostSpec, Properties) returns true for the given
protocol, host, and properties, the connection will be created by the non-default
ConnectionProvider. Otherwise, the connection will be created by the default
ConnectionProvider. The default ConnectionProvider will be DriverConnectionProvider for
connections requested via the DriverManager and
DataSourceConnectionProvider for connections requested via an
AwsWrapperDataSource.connect in interface ConnectionPluginconnect in class AbstractConnectionPlugindriverProtocol - the driver protocol that should be used to establish the connectionhostSpec - the host details for the desired connectionprops - the connection propertiesisInitialConnection - a boolean indicating whether the current Connection is
establishing an initial physical connection to the database or has
already established a physical connection in the pastconnectFunc - the function to call to continue the connect request down the
connect pipelineConnection to the requested hostjava.sql.SQLException - if there was an error establishing a Connection to the requested
hostpublic java.sql.Connection forceConnect(java.lang.String driverProtocol,
HostSpec hostSpec,
java.util.Properties props,
boolean isInitialConnection,
JdbcCallable<java.sql.Connection,java.sql.SQLException> forceConnectFunc)
throws java.sql.SQLException
ConnectionPluginConnectionPlugin.connect(java.lang.String, software.amazon.jdbc.HostSpec, java.util.Properties, boolean, software.amazon.jdbc.JdbcCallable<java.sql.Connection, java.sql.SQLException>) in that the default
ConnectionProvider will be used to establish the connection even if a non-default
ConnectionProvider has been set via Driver.setCustomConnectionProvider(ConnectionProvider).
The default ConnectionProvider will be DriverConnectionProvider for connections
requested via the DriverManager and DataSourceConnectionProvider for
connections requested via an AwsWrapperDataSource.forceConnect in interface ConnectionPluginforceConnect in class AbstractConnectionPlugindriverProtocol - the driver protocol that should be used to establish the connectionhostSpec - the host details for the desired connectionprops - the connection propertiesisInitialConnection - a boolean indicating whether the current Connection is
establishing an initial physical connection to the database or has
already established a physical connection in the pastforceConnectFunc - the function to call to continue the forceConnect request down the
forceConnect pipelineConnection to the requested hostjava.sql.SQLException - if there was an error establishing a Connection to the requested
hostprotected long resolveSecretExpirationTime(long configuredExpirationTime)
configuredExpirationTime - the value configured via secretsManagerExpirationTimeSec.protected boolean updateSecret(HostSpec hostSpec, boolean forceReFetch) throws java.sql.SQLException
forceReFetch - Allows ignoring cached credentials and force fetches the latest credentials from the service.java.sql.SQLExceptionprotected software.amazon.jdbc.plugin.AwsSecretsManagerConnectionPlugin.Secret fetchAndStoreSecret(HostSpec hostSpec) throws java.sql.SQLException
SQLException (or RuntimeException for a
misconfigured endpoint), preserving the original error handling.hostSpec - A HostSpec instance containing host information for the current connection.Secret, or null if none was returned.java.sql.SQLException - if the credentials could not be fetched.public static void clearCache()