Skip to content

Commit 9359561

Browse files
Handle invalid or corrupted tnsnames secrets
1 parent 5354123 commit 9359561

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

ojdbc-provider-aws/src/main/java/oracle/jdbc/provider/aws/resource/ParameterStoreConnectionStringProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ public String getConnectionString(Map<Parameter, CharSequence> parameterValues)
107107
return connectionString;
108108
} catch (IOException e) {
109109
throw new IllegalStateException("Failed to read tnsnames.ora content", e);
110+
} catch (StringIndexOutOfBoundsException | IllegalStateException parseException) {
111+
throw new IllegalStateException(
112+
"Invalid or corrupted tnsnames.ora content. Ensure the secret contains valid, complete tnsnames.ora data (base64-encoded or plain text).", parseException
113+
);
110114
}
111115
}
112116
}

ojdbc-provider-aws/src/main/java/oracle/jdbc/provider/aws/resource/SecretsManagerConnectionStringProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public String getConnectionString(Map<Parameter, CharSequence> parameterValues)
113113
return connectionString;
114114
} catch (IOException e) {
115115
throw new IllegalStateException("Failed to read tnsnames.ora content", e);
116+
} catch (StringIndexOutOfBoundsException | IllegalStateException parseException) {
117+
throw new IllegalStateException(
118+
"Invalid or corrupted tnsnames.ora content. Ensure the secret contains valid, complete tnsnames.ora data (base64-encoded or plain text).", parseException
119+
);
116120
}
117121
}
118122

ojdbc-provider-oci/src/main/java/oracle/jdbc/provider/oci/resource/VaultConnectionStringProvider.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ public String getConnectionString(Map<Parameter, CharSequence> parameterValues)
119119
String secretValue = getVaultSecret(parameterValues)
120120
.getBase64Secret();
121121

122-
byte[] fileBytes = Base64.getDecoder().decode(secretValue);
122+
byte[] fileBytes;
123+
try {
124+
fileBytes = Base64.getDecoder().decode(secretValue);
125+
} catch (IllegalArgumentException e) {
126+
throw new IllegalStateException("Invalid base64 encoding in secret", e);
127+
}
123128

124129
TNSNames tnsNames;
125130
try (InputStream inputStream = new ByteArrayInputStream(fileBytes)) {

0 commit comments

Comments
 (0)