Class AWSSecretsManagerDb2Driver

  • All Implemented Interfaces:
    Driver

    public final class AWSSecretsManagerDb2Driver
    extends AWSSecretsManagerDriver

    Provides support for accessing Db2 databases using credentials stored within AWS Secrets Manager.

    Configuration properties are specified using the "db2" subprefix (e.g drivers.mysql.realDriverClass).

    • Field Detail

      • ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE

        public static final int ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE
        The Db2 error code for when a user logs in using an invalid password. See Db2 error codes.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AWSSecretsManagerDb2Driver

        public AWSSecretsManagerDb2Driver()
        Constructs the driver setting the properties from the properties file using system properties as defaults. Instantiates the secret cache with default options.
      • AWSSecretsManagerDb2Driver

        public AWSSecretsManagerDb2Driver​(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
      • AWSSecretsManagerDb2Driver

        public AWSSecretsManagerDb2Driver​(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
      • AWSSecretsManagerDb2Driver

        public AWSSecretsManagerDb2Driver​(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
      • AWSSecretsManagerDb2Driver

        public AWSSecretsManagerDb2Driver​(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 Detail

      • getPropertySubprefix

        public String getPropertySubprefix()
        Description copied from class: AWSSecretsManagerDriver
        Gets 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:
        getPropertySubprefix in class AWSSecretsManagerDriver
        Returns:
        String The subprefix to use for configuration properties.
      • isExceptionDueToAuthenticationError

        public boolean isExceptionDueToAuthenticationError​(Exception e)
        Description copied from class: AWSSecretsManagerDriver
        Determines whether or not an Exception is due to an authentication failure with the remote database. This method is called during connect to decide if authentication needs to be attempted again with refreshed credentials. A good way to implement this is to look up the error codes that java.sqlSQLExceptions will have when an authentication failure occurs. These are database specific.
        Specified by:
        isExceptionDueToAuthenticationError in class AWSSecretsManagerDriver
        Parameters:
        e - The Exception to test.
        Returns:
        boolean Whether or not the Exception indicates that the credentials used for authentication are stale.
      • constructUrlFromEndpointPortDatabase

        public String constructUrlFromEndpointPortDatabase​(String endpoint,
                                                           String port,
                                                           String dbname)
        Description copied from class: AWSSecretsManagerDriver
        Construct a database URL from the endpoint, port and database name. This method is called when the connect method is called with a secret ID instead of a URL.
        Specified by:
        constructUrlFromEndpointPortDatabase in class AWSSecretsManagerDriver
        Parameters:
        endpoint - The endpoint retrieved from the secret cache
        port - The port retrieved from the secret cache
        dbname - The database name retrieved from the secret cache
        Returns:
        String The constructed URL based on the endpoint and port