Skip to content

Commit f035e8f

Browse files
Merge branch 'main' into aws-appconfig-centralized-config-provider
2 parents 9689663 + 16894da commit f035e8f

File tree

78 files changed

+2302
-273
lines changed

Some content is hidden

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

78 files changed

+2302
-273
lines changed

ojdbc-provider-aws/README.md

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Provider</a></dt>
1212
<dt><a href="#aws-secrets-manager-config-provider">AWS Secrets Manager Configuration
1313
Provider</a></dt>
1414
<dd>Provides connection properties managed by the Secrets Manager service</dd>
15+
<dt><a href="#aws-parameter-store-config-provider">AWS Parameter Store Configuration Provider</a></dt>
16+
<dd>Provides connection properties managed by the Systems Manager Parameter Store</dd>
1517
<dt><a href="#aws-appconfig-freeform-config-provider">AWS AppConfig Freeform Configuration Provider</a></dt>
1618
<dd>Provides connection properties managed by the AWS AppConfig Freeform Configuration service</dd>
1719
<dt><a href="#common-parameters-for-centralized-config-providers">Common Parameters for Centralized Config Providers</a></dt>
@@ -49,7 +51,7 @@ JDK versions. The coordinates for the latest release are:
4951
<dependency>
5052
<groupId>com.oracle.database.jdbc</groupId>
5153
<artifactId>ojdbc-provider-aws</artifactId>
52-
<version>1.0.5</version>
54+
<version>1.0.6</version>
5355
</dependency>
5456
```
5557

@@ -70,11 +72,12 @@ The {S3-URI} can be obtained from the Amazon S3 console and follows this naming
7072

7173
### JSON Payload format
7274

73-
There are 3 fixed values that are looked at the root level.
75+
There are 4 fixed values that are looked at the root level.
7476

7577
- connect_descriptor (required)
7678
- user (optional)
7779
- password (optional)
80+
- wallet_location (optional)
7881

7982
The rest are dependent on the driver, in our case `/jdbc`. The key-value pairs that are with sub-prefix `/jdbc` will be applied to a DataSource. The key values are constant keys which are equivalent to the properties defined in the [OracleConnection](https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/OracleConnection.html) interface.
8083

@@ -95,6 +98,11 @@ And the JSON Payload for the file **payload_ojdbc_objectstorage.json** in **mybu
9598
"value": "test-secret",
9699
"field_name": "<field-name>" // Optional: Only needed when the secret is structured and contains multiple key-value pairs.
97100
},
101+
"wallet_location": {
102+
"type": "awssecretsmanager",
103+
"value": "wallet-secret",
104+
"field_name": "<field-name>" // Optional: Only needed when the secret is structured and contains multiple key-value pairs.
105+
},
98106
"jdbc": {
99107
"oracle.jdbc.ReadTimeout": 1000,
100108
"defaultRowPrefetch": 20,
@@ -117,34 +125,69 @@ The sample code below executes as expected with the previous configuration.
117125

118126
### Password JSON Object
119127

120-
For the JSON type of provider (AWS S3, AWS Secrets Manager, HTTP/HTTPS, File) the password is an object itself with the following spec:
128+
For the JSON type of provider (AWS S3, AWS Secrets Manager, AWS Parameter Store, HTTP/HTTPS, File) the password is an object itself with the following spec:
121129

122-
- type
130+
- `type`
123131
- Mandatory
124132
- Possible values
125-
- ocivault
126-
- azurevault
127-
- base64
128-
- awssecretsmanager
129-
- value
133+
- `ocivault` (OCI Vault)
134+
- `azurevault` (Azure Key Vault)
135+
- `base64` (Base64)
136+
- `awssecretsmanager` (AWS Secrets Manager)
137+
- `awsparameterstore` (AWS Parameter Store)
138+
- `hcpvaultdedicated` (HCP Vault Dedicated)
139+
- `hcpvaultsecret` (HCP Vault Secrets)
140+
- `gcpsecretmanager` (GCP Secret Manager)
141+
- `value`
130142
- Mandatory
131143
- Possible values
132144
- OCID of the secret (if ocivault)
133145
- Azure Key Vault URI (if azurevault)
134146
- Base64 Encoded password (if base64)
135147
- AWS Secret name (if awssecretsmanager)
136-
- field_name
148+
- AWS Parameter name (if awsparameterstore)
149+
- Secret path (if hcpvaultdedicated)
150+
- Secret name (if hcpvaultsecret)
151+
- Secret name (if gcpsecretmanager)
152+
- `field_name`
137153
- Optional
138154
- Description: Specifies the key within the secret JSON object from which to extract the password value.
139155
If the secret JSON contains multiple key-value pairs, field_name must be provided to unambiguously select the desired secret value.
140156
If the secret contains only a single key-value pair and field_name is not provided, that sole value will be used.
141157
If the secret is provided as plain text (i.e., not structured as a JSON object), no field_name is required.
142-
- authentication
158+
- `authentication`
143159
- Optional
144160
- Possible Values
145161
- method
146162
- optional parameters (depends on the cloud provider).
147163

164+
### Wallet_location JSON Object
165+
166+
The `oracle.net.wallet_location` connection property is not allowed in the `jdbc` object due to security reasons. Instead, users should use the `wallet_location` object to specify the wallet in the configuration.
167+
168+
For the JSON type of provider (AWS S3, HTTPS, File) the wallet_location is an object itself with the same spec as the [password JSON object](#password-json-object) mentioned above.
169+
170+
The value stored in the secret should be the Base64 representation of of a supported wallet file. This is equivalent to setting the `oracle.net.wallet_location` connection property in a regular JDBC application using the following format:
171+
172+
```
173+
data:;base64,<Base64 representation of the wallet file>
174+
```
175+
176+
#### Supported formats
177+
- `cwallet.sso` (SSO wallet)
178+
- `ewallet.pem` (PEM wallet)
179+
180+
If the PEM wallet is encrypted, you must also set the wallet password using the `oracle.net.wallet_password` property.
181+
This property should be included inside the jdbc object of the JSON payload:
182+
183+
```
184+
"jdbc": {
185+
"oracle.net.wallet_password": "<your-password>"
186+
}
187+
```
188+
189+
<i>*Note: When storing a wallet in AWS Secrets Manager, store the raw Base64-encoded wallet bytes directly. The provider will automatically detect and handle the encoding correctly.</i>
190+
148191
## AWS Secrets Manager Config Provider
149192
Apart from AWS S3, users can also store JSON Payload in the content of AWS Secrets Manager secret. Users need to indicate the secret name:
150193

@@ -154,6 +197,16 @@ jdbc:oracle:thin:@config-awssecretsmanager://{secret-name}
154197

155198
The JSON Payload retrieved by AWS Secrets Manager Provider follows the same format in [AWS S3 Configuration Provider](#json-payload-format).
156199

200+
## AWS Parameter Store Config Provider
201+
Apart from AWS S3 and Secrets Manager, users can also store JSON payload in AWS Systems Manager Parameter Store.
202+
To use it, specify the name of the parameter:
203+
204+
<pre>
205+
jdbc:oracle:thin:@config-awsparameterstore://{parameter-name}
206+
</pre>
207+
208+
The JSON payload stored in the parameter should follow the same format as described in [AWS S3 Configuration Provider](#json-payload-format).
209+
157210
## AWS AppConfig Freeform Config Provider
158211
The Oracle DataSource uses the prefix `jdbc:oracle:thin:@config-awsappconfig` to identify that the freeform
159212
configuration parameters should be loaded using AWS AppConfig. Users need to specify the application identifier or name, along with the environment and configuration profile

ojdbc-provider-aws/example-test.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ AWS_S3_URL=jdbc:oracle:thin:@config-awss3://...
8787
# The URL to test with the AWS Secrets Manager Configuration Provider
8888
AWS_SECRETS_MANAGER_URL=jdbc:oracle:thin:@config-awssecretsmanager://...
8989

90+
# The URL to test with the AWS Parameter Store Configuration Provider
91+
AWS_PARAMETER_STORE_URL=jdbc:oracle:thin:@config-awsparameterstore://...
9092
# The name of an AWS Secrets Manager secret
9193
AWS_USERNAME_SECRET_NAME=example-name
9294

ojdbc-provider-aws/pom.xml

Lines changed: 5 additions & 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>
@@ -66,6 +66,10 @@
6666
<groupId>software.amazon.awssdk</groupId>
6767
<artifactId>secretsmanager</artifactId>
6868
</dependency>
69+
<dependency>
70+
<groupId>software.amazon.awssdk</groupId>
71+
<artifactId>ssm</artifactId>
72+
</dependency>
6973
<dependency>
7074
<groupId>software.amazon.awssdk</groupId>
7175
<artifactId>appconfigdata</artifactId>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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.configuration;
40+
41+
import oracle.jdbc.provider.aws.parameterstore.ParameterStoreFactory;
42+
import oracle.jdbc.provider.parameter.ParameterSet;
43+
import oracle.jdbc.spi.OracleConfigurationSecretProvider;
44+
45+
import java.util.Base64;
46+
import java.util.Map;
47+
48+
import static oracle.jdbc.provider.aws.configuration.AwsParameterStoreConfigurationProvider.PARAMETER_SET_PARSER;
49+
50+
public class AwsJsonParameterStoreProvider
51+
implements OracleConfigurationSecretProvider {
52+
53+
/**
54+
* {@inheritDoc}
55+
* <p>
56+
* Returns the value of the parameter retrieved from AWS Systems Manager
57+
* Parameter Store.
58+
* </p>
59+
* <p>
60+
* The {@code jsonObject} is expected to be in the following form:
61+
* </p>
62+
*
63+
* <pre>{@code
64+
* "password": {
65+
* "type": "awsparameterstore",
66+
* "value": "/my-app/database-password"
67+
* }
68+
* }</pre>
69+
*
70+
* <p>
71+
* The provider retrieves the parameter specified by the {@code value} field
72+
* from AWS Parameter Store, then encodes it as a Base64 string.
73+
* The encoded value is returned as a {@code char[]} for use with Oracle JDBC's
74+
* centralized configuration.
75+
* </p>
76+
*
77+
* @param map Map object containing key-value pairs parsed from the JSON configuration.
78+
* @return Base64-encoded {@code char[]} representing the retrieved secret value.
79+
*/
80+
@Override
81+
public char[] getSecret(Map<String, String> map) {
82+
ParameterSet parameterSet = PARAMETER_SET_PARSER.parseNamedValues(map);
83+
84+
String parameterValue = ParameterStoreFactory.getInstance()
85+
.request(parameterSet)
86+
.getContent();
87+
88+
return Base64.getEncoder()
89+
.encodeToString(parameterValue.getBytes())
90+
.toCharArray();
91+
}
92+
93+
@Override
94+
public String getSecretType() {
95+
return "awsparameterstore";
96+
}
97+
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@
4242
import oracle.jdbc.provider.parameter.ParameterSet;
4343
import oracle.jdbc.spi.OracleConfigurationSecretProvider;
4444

45-
import java.nio.charset.StandardCharsets;
46-
import java.util.Base64;
4745
import java.util.Map;
4846

4947
import static oracle.jdbc.provider.aws.configuration.AwsConfigurationParameters.FIELD_NAME;
5048
import static oracle.jdbc.provider.aws.configuration.AwsSecretsManagerConfigurationProvider.PARAMETER_SET_PARSER;
49+
import static oracle.jdbc.provider.util.FileUtils.toBase64EncodedCharArray;
5150

5251
public class AwsJsonSecretsManagerProvider
5352
implements OracleConfigurationSecretProvider {
@@ -96,9 +95,7 @@ public char[] getSecret(Map<String, String> map) {
9695
String extractedSecret = AwsSecretExtractor.extractSecret(secretString,
9796
fieldName);
9897

99-
return Base64.getEncoder()
100-
.encodeToString(extractedSecret.getBytes(StandardCharsets.UTF_8))
101-
.toCharArray();
98+
return toBase64EncodedCharArray(extractedSecret);
10299
}
103100

104101
@Override

0 commit comments

Comments
 (0)