diff --git a/src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriver.java b/src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriver.java index 5f6e05e..1b6dacf 100644 --- a/src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriver.java +++ b/src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriver.java @@ -39,6 +39,13 @@ public final class AWSSecretsManagerPostgreSQLDriver extends AWSSecretsManagerDr */ public static final String ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE = "28P01"; + /** + * The error code returned by RDS Proxy when the secret is rotated in alternating user mode. + * + * See PosgreSQL documentation. + */ + public static final String ACCESS_DENIED_FOR_INVALID_AUTHORIZATION_SPECIFICATION = "28000"; + /** * Set to postgresql. */ @@ -106,7 +113,7 @@ public boolean isExceptionDueToAuthenticationError(Exception e) { if (e instanceof SQLException) { SQLException sqle = (SQLException) e; String sqlState = sqle.getSQLState(); - return sqlState.equals(ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE); + return sqlState.equals(ACCESS_DENIED_FOR_USER_USING_PASSWORD_TO_DATABASE) || sqlState.equals(ACCESS_DENIED_FOR_INVALID_AUTHORIZATION_SPECIFICATION); } return false; }