Skip to content

Commit 8947dd4

Browse files
Add javadocs and copyright for dedicated vault
1 parent 2bb0198 commit 8947dd4

8 files changed

+451
-56
lines changed

ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/dedicated/DedicatedVaultResourceFactory.java

+38
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
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+
139
package oracle.jdbc.provider.hashicorp.dedicated;
240

341
import oracle.jdbc.provider.factory.Resource;
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
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+
139
package oracle.jdbc.provider.hashicorp.dedicated.authentication;
240

341
/**
4-
* A method of authentication using Dedicated HashiCorp Vault.
42+
* Enumeration of authentication methods supported by Dedicated HashiCorp Vault.
543
*/
644
public enum DedicatedVaultAuthenticationMethod {
745

846
/**
9-
* Authentication using a Vault token, possibly read from a parameter,
10-
* system property, or environment variable.
47+
* Authentication using a Vault token.
48+
* <p>
49+
* The Vault token is a secure string used to authenticate API requests
50+
* to the HashiCorp Vault. It can be provided through configuration parameters,
51+
* environment variables, or system properties.
52+
* </p>
1153
*/
1254
TOKEN
1355
}

ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/dedicated/authentication/DedicatedVaultCredentials.java

+58-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,72 @@
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+
139
package oracle.jdbc.provider.hashicorp.dedicated.authentication;
240

341
/**
4-
* Holds a Vault token for Dedicated Vault usage.
42+
* <p>
43+
* Holds the credentials required for authenticating with Dedicated
44+
* HashiCorp Vault.
45+
* </p><p>
46+
* This class encapsulates a Vault token which is essential for making secure
47+
* requests to the Vault API.
48+
* </p>
549
*/
650
public final class DedicatedVaultCredentials {
51+
752
private final String vaultToken;
853

54+
/**
55+
* Constructs a new {@code DedicatedVaultCredentials} object with
56+
* the provided Vault token.
57+
*
58+
* @param vaultToken the token used to authenticate API requests to
59+
* the Vault. Must not be null or empty.
60+
*/
961
public DedicatedVaultCredentials(String vaultToken) {
1062
this.vaultToken = vaultToken;
1163
}
1264

65+
/**
66+
* Returns the Vault token used for authentication.
67+
*
68+
* @return the Vault token as a {@link String}.
69+
*/
1370
public String getVaultToken() {
1471
return vaultToken;
1572
}

ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/dedicated/authentication/DedicatedVaultCredentialsFactory.java

+69-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
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+
139
package oracle.jdbc.provider.hashicorp.dedicated.authentication;
240

341
import oracle.jdbc.provider.factory.Resource;
@@ -10,10 +48,22 @@
1048
import static oracle.jdbc.provider.util.ParameterUtil.getRequiredOrFallback;
1149

1250
/**
13-
* A factory for creating {@link DedicatedVaultCredentials} objects for Dedicated Vault.
51+
* <p>
52+
* Factory for creating {@link DedicatedVaultCredentials} objects for authenticating
53+
* with Dedicated HashiCorp Vault.
54+
* </p><p>
55+
* This factory determines the appropriate authentication method based on the provided
56+
* {@link ParameterSet} and creates credentials accordingly.
57+
* </p>
1458
*/
1559
public final class DedicatedVaultCredentialsFactory implements ResourceFactory<DedicatedVaultCredentials> {
1660

61+
/**
62+
* <p>
63+
* Parameter for configuring the authentication method.
64+
* Must be provided in the {@link ParameterSet}.
65+
* </p>
66+
*/
1767
public static final Parameter<DedicatedVaultAuthenticationMethod> AUTHENTICATION_METHOD =
1868
Parameter.create(REQUIRED);
1969

@@ -22,6 +72,11 @@ public final class DedicatedVaultCredentialsFactory implements ResourceFactory<D
2272

2373
private DedicatedVaultCredentialsFactory() { }
2474

75+
/**
76+
* Returns a singleton instance of {@code DedicatedVaultCredentialsFactory}.
77+
*
78+
* @return a singleton instance. Not null.
79+
*/
2580
public static DedicatedVaultCredentialsFactory getInstance() {
2681
return INSTANCE;
2782
}
@@ -32,6 +87,13 @@ public Resource<DedicatedVaultCredentials> request(ParameterSet parameterSet) {
3287
return Resource.createPermanentResource(credentials, true);
3388
}
3489

90+
/**
91+
* Determines the appropriate credentials based on the provided parameters.
92+
*
93+
* @param parameterSet the set of parameters configuring the request. Must
94+
* not be null.
95+
* @return the created {@code DedicatedVaultCredentials} instance.
96+
*/
3597
private static DedicatedVaultCredentials getCredential(ParameterSet parameterSet) {
3698
// Check which authentication method is requested
3799
DedicatedVaultAuthenticationMethod method =
@@ -46,6 +108,12 @@ private static DedicatedVaultCredentials getCredential(ParameterSet parameterSet
46108
}
47109
}
48110

111+
/**
112+
* Creates {@link DedicatedVaultCredentials} using the Vault token.
113+
*
114+
* @param parameterSet the set of parameters containing the Vault token. Must not be null.
115+
* @return the created {@code DedicatedVaultCredentials} instance.
116+
*/
49117
private static DedicatedVaultCredentials createTokenCredentials(ParameterSet parameterSet) {
50118
String vaultToken = getRequiredOrFallback(
51119
parameterSet,

ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/dedicated/configuration/DedicatedVaultConfigurationParameters.java

+63-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +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+
139
package oracle.jdbc.provider.hashicorp.dedicated.configuration;
240

341
import oracle.jdbc.provider.hashicorp.dedicated.authentication.DedicatedVaultAuthenticationMethod;
442
import oracle.jdbc.provider.hashicorp.dedicated.authentication.DedicatedVaultCredentialsFactory;
543
import oracle.jdbc.provider.parameter.ParameterSetParser;
644

745
/**
8-
* Defines how we parse common Vault parameters.
46+
* <p>
47+
* A class for defining and parsing configuration parameters for
48+
* Dedicated HashiCorp Vault.
49+
* </p><p>
50+
* This class provides methods to build and parse {@link ParameterSetParser}
51+
* objects, which are used to interpret configuration parameters passed to
52+
* the Vault.
53+
* </p>
954
*/
1055
public final class DedicatedVaultConfigurationParameters {
1156

57+
/**
58+
* Private constructor that should never be called.
59+
*/
1260
private DedicatedVaultConfigurationParameters() {}
1361

62+
/**
63+
* Configures a {@link ParameterSetParser.Builder} with parameters used for
64+
* Dedicated Vault authentication.
65+
*
66+
* @param builder the builder to configure. Must not be null.
67+
* @return the configured builder. Not null.
68+
*/
1469
public static ParameterSetParser.Builder configureBuilder(ParameterSetParser.Builder builder) {
1570
return builder.addParameter(
1671
// The parameter name is "AUTHENTICATION"
@@ -23,6 +78,13 @@ public static ParameterSetParser.Builder configureBuilder(ParameterSetParser.Bui
2378
;
2479
}
2580

81+
/**
82+
* Parses the authentication method from a string value.
83+
* @param value the string value representing the authentication method. Must
84+
* not be null.
85+
* @return the parsed {@link DedicatedVaultAuthenticationMethod}.
86+
* @throws IllegalArgumentException if the value is unrecognized.
87+
*/
2688
private static DedicatedVaultAuthenticationMethod parseAuthentication(String value) {
2789
if ("TOKEN".equalsIgnoreCase(value) || "VAULT_TOKEN".equalsIgnoreCase(value)) {
2890
return DedicatedVaultAuthenticationMethod.TOKEN;

0 commit comments

Comments
 (0)