Package com.amazonaws.secretsmanager.sql
Class AWSSecretsManagerRedshiftDriver
java.lang.Object
com.amazonaws.secretsmanager.sql.AWSSecretsManagerDriver
com.amazonaws.secretsmanager.sql.AWSSecretsManagerRedshiftDriver
- All Implemented Interfaces:
Driver
Provides support for accessing Redshift databases using credentials stored within AWS Secrets Manager.
Configuration properties are specified using the "redshift" subprefix (e.g drivers.redshift.realDriverClass).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe Redshift error code for when a user logs in using an invalid password.static final StringThe Redshift JDBC sub-prefix.Fields inherited from class com.amazonaws.secretsmanager.sql.AWSSecretsManagerDriver
INVALID_SECRET_STRING_JSON, MAX_RETRY, PROPERTY_PREFIX, SCHEME -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the driver setting the properties from the properties file using system properties as defaults.AWSSecretsManagerRedshiftDriver(com.amazonaws.secretsmanager.caching.SecretCache cache) Constructs the driver setting the properties from the properties file using system properties as defaults.AWSSecretsManagerRedshiftDriver(com.amazonaws.secretsmanager.caching.SecretCacheConfiguration cacheConfig) Constructs the driver setting the properties from the properties file using system properties as defaults.AWSSecretsManagerRedshiftDriver(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client) Constructs the driver setting the properties from the properties file using system properties as defaults.AWSSecretsManagerRedshiftDriver(software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder builder) Constructs the driver setting the properties from the properties file using system properties as defaults. -
Method Summary
Modifier and TypeMethodDescriptionconstructUrlFromEndpointPortDatabase(String endpoint, String port, String dbname) Construct a database URL from the endpoint, port and database name.Get the default real driver class name for this driver.Gets the "subprefix" used for configuration properties for this driver.booleanDetermines whether or not anExceptionis due to an authentication failure with the remote database.Methods inherited from class com.amazonaws.secretsmanager.sql.AWSSecretsManagerDriver
acceptsURL, connect, getMajorVersion, getMinorVersion, getParentLogger, getPropertyInfo, getWrappedDriver, jdbcCompliant, register
-
Field Details
-
ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE
The Redshift error code for when a user logs in using an invalid password. See Postgres documentation (Redshift is built on Postgres).- See Also:
-
SUBPREFIX
The Redshift JDBC sub-prefix.- See Also:
-
-
Constructor Details
-
AWSSecretsManagerRedshiftDriver
public AWSSecretsManagerRedshiftDriver()Constructs the driver setting the properties from the properties file using system properties as defaults. Instantiates the secret cache with default options. -
AWSSecretsManagerRedshiftDriver
public AWSSecretsManagerRedshiftDriver(com.amazonaws.secretsmanager.caching.SecretCache cache) Constructs the driver setting the properties from the properties file using system properties as defaults. Uses the passed in SecretCache.- Parameters:
cache- Secret cache to use to retrieve secrets
-
AWSSecretsManagerRedshiftDriver
public AWSSecretsManagerRedshiftDriver(software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder builder) Constructs the driver setting the properties from the properties file using system properties as defaults. Instantiates the secret cache with the passed in client builder.- Parameters:
builder- Builder used to instantiate cache
-
AWSSecretsManagerRedshiftDriver
public AWSSecretsManagerRedshiftDriver(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client) Constructs the driver setting the properties from the properties file using system properties as defaults. Instantiates the secret cache with the provided AWS Secrets Manager client.- Parameters:
client- AWS Secrets Manager client to instantiate cache
-
AWSSecretsManagerRedshiftDriver
public AWSSecretsManagerRedshiftDriver(com.amazonaws.secretsmanager.caching.SecretCacheConfiguration cacheConfig) Constructs the driver setting the properties from the properties file using system properties as defaults. Instantiates the secret cache with the provided cache configuration.- Parameters:
cacheConfig- Cache configuration to instantiate cache
-
-
Method Details
-
getPropertySubprefix
Description copied from class:AWSSecretsManagerDriverGets the "subprefix" used for configuration properties for this driver. For example, if this method returns the String, "mysql", then the real driver that this will forward requests to would be set to drivers.mysql.realDriverClass in the properties file or in the system properties.- Specified by:
getPropertySubprefixin classAWSSecretsManagerDriver- Returns:
- String The subprefix to use for configuration properties.
-
isExceptionDueToAuthenticationError
Description copied from class:AWSSecretsManagerDriverDetermines whether or not anExceptionis due to an authentication failure with the remote database. This method is called duringconnectto decide if authentication needs to be attempted again with refreshed credentials. A good way to implement this is to look up the error codes thatjava.sqlSQLExceptions will have when an authentication failure occurs. These are database specific.- Specified by:
isExceptionDueToAuthenticationErrorin classAWSSecretsManagerDriver- Parameters:
e- TheExceptionto test.- Returns:
- boolean Whether or not the
Exceptionindicates that the credentials used for authentication are stale.
-
constructUrlFromEndpointPortDatabase
Description copied from class:AWSSecretsManagerDriverConstruct a database URL from the endpoint, port and database name. This method is called when theconnectmethod is called with a secret ID instead of a URL.- Specified by:
constructUrlFromEndpointPortDatabasein classAWSSecretsManagerDriver- Parameters:
endpoint- The endpoint retrieved from the secret cacheport- The port retrieved from the secret cachedbname- The database name retrieved from the secret cache- Returns:
- String The constructed URL based on the endpoint and port
-
getDefaultDriverClass
Description copied from class:AWSSecretsManagerDriverGet the default real driver class name for this driver.- Specified by:
getDefaultDriverClassin classAWSSecretsManagerDriver- Returns:
- String The default real driver class name
-