Skip to content

Commit ad9c25b

Browse files
Merge branch 'main' into aws-parameter-store-centralized-config-provider
2 parents 7f8f6be + 4a1ed4c commit ad9c25b

File tree

135 files changed

+8762
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+8762
-347
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Each module of this project contains a set of providers.
1717
<dd>Providers for integration with Google Cloud Platform</dd>
1818
<dt><a href="ojdbc-provider-hashicorp/README.md">Oracle JDBC HashiCorp Providers</a></dt>
1919
<dd>Providers for integration with Hashicorp</dd>
20+
<dt><a href="ojdbc-provider-aws/README.md">Oracle JDBC AWS Providers</a></dt>
21+
<dd>Providers for integration with AWS</dd>
2022
</dl>
2123
<u>The next one contains a provider for Open Telemetry:</u>
2224
<dl>
@@ -132,6 +134,10 @@ this project:
132134

133135
[ojdbc-provider-azure](ojdbc-provider-azure/README.md#installation)
134136

137+
[ojdbc-provider-hashicorp](ojdbc-provider-hashicorp/README.md#installation)
138+
139+
[ojdbc-provider-aws](ojdbc-provider-aws/README.md#installation)
140+
135141
[ojdbc-provider-gcp](ojdbc-provider-gcp/README.md#installation)
136142

137143
[ojdbc-provider-opentelemetry](ojdbc-provider-opentelemetry/README.md#installation)

ojdbc-provider-aws/README.md

Lines changed: 448 additions & 11 deletions
Large diffs are not rendered by default.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
################################################################################
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or data
8+
# (collectively the "Software"), free of charge and under any and all copyright
9+
# rights in the Software, and any and all patent rights owned or freely
10+
# licensable by each licensor hereunder covering either (i) the unmodified
11+
# Software as contributed to or provided by such licensor, or (ii) the Larger
12+
# Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
# one is included with the Software (each a "Larger Work" to which the Software
17+
# is contributed by such licensors),
18+
#
19+
# without restriction, including without limitation the rights to copy, create
20+
# derivative works of, display, perform, and distribute the Software and make,
21+
# use, sell, offer for sale, import, export, have made, and have sold the
22+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
# either these or other terms.
24+
#
25+
# This license is subject to the following condition:
26+
# The above copyright notice and either this complete permission notice or at
27+
# a minimum a reference to the UPL must be included in all copies or
28+
# substantial portions of the Software.
29+
#
30+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
# SOFTWARE.
37+
################################################################################
38+
39+
# An example of a connection properties file that configures Oracle JDBC to
40+
# obtain a TLS wallet and SEPS credentials from AWS Secrets Manager.
41+
#
42+
# This file can be located by Oracle JDBC using the "oracle.jdbc.config.file"
43+
# connection property. For details, see:
44+
# https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/OracleConnection.html#CONNECTION_PROPERTY_CONFIG_FILE
45+
46+
# Configures the AWS Secrets Manager TCPS Wallet Provider.
47+
# The wallet secret name, wallet password, and file type are configured via
48+
# "TLS_WALLET_SECRET_NAME", "TLS_FILE_PASSWORD", and "TLS_FILE_TYPE" environment variables or JVM system properties.
49+
oracle.jdbc.provider.tlsConfiguration=ojdbc-provider-aws-secretsmanager-tls
50+
oracle.jdbc.provider.tlsConfiguration.secretName=${TLS_WALLET_SECRET_NAME}
51+
oracle.jdbc.provider.tlsConfiguration.walletPassword=${TLS_FILE_PASSWORD}
52+
oracle.jdbc.provider.tlsConfiguration.type=${TLS_FILE_TYPE}
53+
oracle.jdbc.provider.tlsConfiguration.awsRegion=${AWS_REGION}
54+
55+
# Configures the AWS Secrets Manager SEPS Wallet Provider for both username and password.
56+
# The SEPS wallet secret name, wallet password, and index are configured via
57+
# "SEPS_WALLET_SECRET_NAME", "SEPS_WALLET_PASSWORD", and "SEPS_CONNECTION_STRING_INDEX".
58+
oracle.jdbc.provider.username=ojdbc-provider-aws-secretsmanager-seps
59+
oracle.jdbc.provider.username.secretName=${SEPS_WALLET_SECRET_NAME}
60+
oracle.jdbc.provider.username.walletPassword=${SEPS_WALLET_PASSWORD}
61+
oracle.jdbc.provider.username.connectionStringIndex=${SEPS_CONNECTION_STRING_INDEX}
62+
oracle.jdbc.provider.username.awsRegion=${AWS_REGION}
63+
64+
oracle.jdbc.provider.password=ojdbc-provider-aws-secretsmanager-seps
65+
oracle.jdbc.provider.password.secretName=${SEPS_WALLET_SECRET_NAME}
66+
oracle.jdbc.provider.password.walletPassword=${SEPS_WALLET_PASSWORD}
67+
oracle.jdbc.provider.password.connectionStringIndex=${SEPS_CONNECTION_STRING_INDEX}
68+
oracle.jdbc.provider.password.authenticationMethod=aws-default
69+
oracle.jdbc.provider.password.awsRegion=${AWS_REGION}
70+
71+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
################################################################################
2+
# Copyright (c) 2025 Oracle and/or its affiliates.
3+
#
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# Subject to the condition set forth below, permission is hereby granted to any
7+
# person obtaining a copy of this software, associated documentation and/or data
8+
# (collectively the "Software"), free of charge and under any and all copyright
9+
# rights in the Software, and any and all patent rights owned or freely
10+
# licensable by each licensor hereunder covering either (i) the unmodified
11+
# Software as contributed to or provided by such licensor, or (ii) the Larger
12+
# Works (as defined below), to deal in both
13+
#
14+
# (a) the Software, and
15+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
# one is included with the Software (each a "Larger Work" to which the Software
17+
# is contributed by such licensors),
18+
#
19+
# without restriction, including without limitation the rights to copy, create
20+
# derivative works of, display, perform, and distribute the Software and make,
21+
# use, sell, offer for sale, import, export, have made, and have sold the
22+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
# either these or other terms.
24+
#
25+
# This license is subject to the following condition:
26+
# The above copyright notice and either this complete permission notice or at
27+
# a minimum a reference to the UPL must be included in all copies or
28+
# substantial portions of the Software.
29+
#
30+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
# SOFTWARE.
37+
################################################################################
38+
39+
# An example of a connection properties file that configures Oracle JDBC to
40+
# login using a username and password managed by AWS Secrets manager Service.
41+
#
42+
# This file can be located by Oracle JDBC using the "oracle.jdbc.config.file"
43+
# connection property. For details, see:
44+
# https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/OracleConnection.html#CONNECTION_PROPERTY_CONFIG_FILE
45+
46+
# Configures the AWS Secrets Manager Username Provider.
47+
# The secret name is configured as an environment variable or JVM system property
48+
# named "USERNAME_SECRET_NAME". The AWS region is configured via "AWS_REGION".
49+
oracle.jdbc.provider.username=ojdbc-provider-aws-secretsmanager-username
50+
oracle.jdbc.provider.username.secretName=${USERNAME_SECRET_NAME}
51+
oracle.jdbc.provider.username.awsRegion=${AWS_REGION}
52+
53+
# Configures the AWS Secrets Manager Password Provider.
54+
# The secret name is configured as an environment variable or JVM system property
55+
# named "PASSWORD_SECRET_NAME". The AWS region is configured via "AWS_REGION".
56+
oracle.jdbc.provider.password=ojdbc-provider-aws-secretsmanager-password
57+
oracle.jdbc.provider.password.secretName=${PASSWORD_SECRET_NAME}
58+
oracle.jdbc.provider.password.awsRegion=${AWS_REGION}
59+
60+
# Configures the AWS Secrets Manager Connection String Provider.
61+
# The secret name and alias are configured as environment variables or JVM system properties
62+
# named "TNSNAMES_SECRET_NAME" and "TNS_ALIAS", respectively. The AWS region is configured via "AWS_REGION".
63+
oracle.jdbc.provider.connectionString=ojdbc-provider-aws-secretsmanager-tnsnames
64+
oracle.jdbc.provider.connectionString.secretName=${TNSNAMES_SECRET_NAME}
65+
oracle.jdbc.provider.connectionString.tnsAlias=${TNS_ALIAS}
66+
oracle.jdbc.provider.connectionString.awsRegion=${AWS_REGION}
67+
68+

ojdbc-provider-aws/example-test.properties

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,30 @@ AWS_S3_URL=jdbc:oracle:thin:@config-awss3://...
8888
AWS_SECRETS_MANAGER_URL=jdbc:oracle:thin:@config-awssecretsmanager://...
8989

9090
# The URL to test with the AWS Parameter Store Configuration Provider
91-
AWS_PARAMETER_STORE_URL=jdbc:oracle:thin:@config-awsparameterstore://...
91+
AWS_PARAMETER_STORE_URL=jdbc:oracle:thin:@config-awsparameterstore://...
92+
# The name of an AWS Secrets Manager secret
93+
AWS_USERNAME_SECRET_NAME=example-name
94+
95+
# The name of an AWS Secrets Manager secret for TCPS (TLS) wallet
96+
AWS_TLS_WALLET_SECRET_NAME=aws-tcps-wallet-secret
97+
98+
# The type of the file stored in AWS Secrets Manager (SSO, PKCS12, PEM)
99+
AWS_TLS_FILE_TYPE=PKCS12
100+
101+
# Optional password for the TLS file stored in AWS Secrets Manager
102+
AWS_TLS_FILE_PASSWORD=******
103+
104+
# The name of an AWS Secrets Manager secret for SEPS wallet
105+
AWS_SEPS_WALLET_SECRET_NAME=aws-seps-wallet-secret
106+
107+
# Optional password for the SEPS wallet stored in AWS Secrets Manager
108+
AWS_SEPS_WALLET_PASSWORD=*****
109+
110+
# Optional index to select specific credentials from the SEPS wallet
111+
AWS_SEPS_CONNECTION_STRING_INDEX=1
112+
113+
# The name of the AWS Secrets Manager secret containing the tnsnames.ora file
114+
AWS_TNSNAMES_SECRET_NAME=aws-tnsnames-secret
115+
116+
# The alias in the tnsnames.ora file to use for the connection string
117+
AWS_TNS_NAMES_ALIAS=your_tns_alias

ojdbc-provider-aws/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>com.oracle.database.jdbc</groupId>
1212
<artifactId>ojdbc-extensions</artifactId>
13-
<version>1.0.5</version>
13+
<version>1.0.6</version>
1414
</parent>
1515

1616
<dependencyManagement>

ojdbc-provider-aws/src/main/java/oracle/jdbc/provider/aws/configuration/AwsJsonSecretsManagerProvider.java

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,20 @@
3737
*/
3838
package oracle.jdbc.provider.aws.configuration;
3939

40+
import oracle.jdbc.provider.aws.secrets.AwsSecretExtractor;
4041
import oracle.jdbc.provider.aws.secrets.SecretsManagerFactory;
4142
import oracle.jdbc.provider.parameter.ParameterSet;
4243
import oracle.jdbc.spi.OracleConfigurationSecretProvider;
43-
import oracle.sql.json.OracleJsonException;
44-
import oracle.sql.json.OracleJsonFactory;
45-
import oracle.sql.json.OracleJsonObject;
4644

47-
import java.io.ByteArrayInputStream;
48-
import java.nio.charset.StandardCharsets;
49-
import java.util.Base64;
5045
import java.util.Map;
5146

5247
import static oracle.jdbc.provider.aws.configuration.AwsConfigurationParameters.FIELD_NAME;
5348
import static oracle.jdbc.provider.aws.configuration.AwsSecretsManagerConfigurationProvider.PARAMETER_SET_PARSER;
49+
import static oracle.jdbc.provider.util.FileUtils.toBase64EncodedCharArray;
5450

5551
public class AwsJsonSecretsManagerProvider
5652
implements OracleConfigurationSecretProvider {
5753

58-
private static final OracleJsonFactory JSON_FACTORY = new OracleJsonFactory();
59-
6054
/**
6155
* {@inheritDoc}
6256
* <p>
@@ -98,32 +92,10 @@ public char[] getSecret(Map<String, String> map) {
9892
.request(parameterSet)
9993
.getContent();
10094

101-
String extractedSecret;
102-
103-
try {
104-
OracleJsonObject jsonObject = JSON_FACTORY.createJsonTextValue(
105-
new ByteArrayInputStream(secretString.getBytes(StandardCharsets.UTF_8)))
106-
.asJsonObject();
107-
108-
if (fieldName != null) {
109-
if (!jsonObject.containsKey(fieldName)) {
110-
throw new IllegalStateException("Field '" + fieldName + "' not found in secret JSON.");
111-
}
112-
extractedSecret = jsonObject.get(fieldName).asJsonString().getString();
113-
} else if (jsonObject.size() == 1) {
114-
extractedSecret = jsonObject.values().iterator().next().asJsonString().getString();
115-
} else {
116-
throw new IllegalStateException(
117-
"FIELD_NAME is required when multiple keys exist in the secret JSON");
118-
}
119-
120-
} catch (OracleJsonException e) {
121-
extractedSecret = secretString;
122-
}
95+
String extractedSecret = AwsSecretExtractor.extractSecret(secretString,
96+
fieldName);
12397

124-
return Base64.getEncoder()
125-
.encodeToString(extractedSecret.getBytes(StandardCharsets.UTF_8))
126-
.toCharArray();
98+
return toBase64EncodedCharArray(extractedSecret);
12799
}
128100

129101
@Override
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
** Copyright (c) 2025 Oracle and/or its affiliates.
3+
**
4+
** The Universal Permissive License (UPL), Version 1.0
5+
**
6+
** Subject to the condition set forth below, permission is hereby granted to any
7+
** person obtaining a copy of this software, associated documentation and/or data
8+
** (collectively the "Software"), free of charge and under any and all copyright
9+
** rights in the Software, and any and all patent rights owned or freely
10+
** licensable by each licensor hereunder covering either (i) the unmodified
11+
** Software as contributed to or provided by such licensor, or (ii) the Larger
12+
** Works (as defined below), to deal in both
13+
**
14+
** (a) the Software, and
15+
** (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
** one is included with the Software (each a "Larger Work" to which the Software
17+
** is contributed by such licensors),
18+
**
19+
** without restriction, including without limitation the rights to copy, create
20+
** derivative works of, display, perform, and distribute the Software and make,
21+
** use, sell, offer for sale, import, export, have made, and have sold the
22+
** Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
** either these or other terms.
24+
**
25+
** This license is subject to the following condition:
26+
** The above copyright notice and either this complete permission notice or at
27+
** a minimum a reference to the UPL must be included in all copies or
28+
** substantial portions of the Software.
29+
**
30+
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
** SOFTWARE.
37+
*/
38+
39+
package oracle.jdbc.provider.aws.resource;
40+
41+
import oracle.jdbc.provider.aws.authentication.AwsAuthenticationMethod;
42+
import oracle.jdbc.provider.aws.authentication.AwsCredentialsFactory;
43+
import oracle.jdbc.provider.resource.AbstractResourceProvider;
44+
import oracle.jdbc.provider.resource.ResourceParameter;
45+
46+
import java.util.stream.Stream;
47+
48+
import static oracle.jdbc.provider.aws.authentication.AwsAuthenticationMethod.DEFAULT;
49+
import static oracle.jdbc.provider.aws.authentication.AwsCredentialsFactory.AUTHENTICATION_METHOD;
50+
import static oracle.jdbc.provider.aws.configuration.AwsConfigurationParameters.REGION;
51+
import static oracle.jdbc.provider.aws.resource.AwsSecretsManagerResourceParameterNames.AWS_REGION;
52+
53+
/**
54+
* Super class of all {@code OracleResourceProvider} implementations
55+
* that request a resource from AWS. This super class defines parameters for
56+
* authentication with AWS.
57+
*/
58+
public abstract class AwsResourceProvider extends AbstractResourceProvider {
59+
60+
private static final ResourceParameter[] PARAMETERS = {
61+
new ResourceParameter("authenticationMethod", AUTHENTICATION_METHOD,
62+
"aws-default",
63+
AwsResourceProvider::parseAuthenticationMethod),
64+
new ResourceParameter(AWS_REGION, REGION)
65+
};
66+
67+
/**
68+
* Constructs a provider identified by the name:
69+
* <pre>{@code
70+
* ojdbc-provider-aws-{resourceType}
71+
* }</pre>
72+
* @param resourceType The resource type identifier used in the provider name.
73+
* @param parameters Additional parameters specific to the subclass provider.
74+
*/
75+
protected AwsResourceProvider(String resourceType, ResourceParameter... parameters) {
76+
super("aws", resourceType,
77+
Stream.concat(Stream.of(PARAMETERS), Stream.of(parameters))
78+
.toArray(ResourceParameter[]::new));
79+
}
80+
81+
/**
82+
* Parses the "authenticationMethod" parameter as an
83+
* {@link AwsAuthenticationMethod} recognized by {@link AwsCredentialsFactory}.
84+
*
85+
* @param authenticationMethod The value to parse.
86+
* @return An {@link AwsAuthenticationMethod} enum.
87+
* @throws IllegalArgumentException if the value is unrecognized.
88+
*/
89+
private static AwsAuthenticationMethod parseAuthenticationMethod(String authenticationMethod) {
90+
switch (authenticationMethod) {
91+
case "aws-default": return DEFAULT;
92+
default:
93+
throw new IllegalArgumentException("Unrecognized authentication method: " + authenticationMethod);
94+
}
95+
}
96+
}

0 commit comments

Comments
 (0)