Skip to content

Commit 651ac0e

Browse files
authored
Applied code style format (#19)
1 parent e64e0e0 commit 651ac0e

File tree

121 files changed

+4799
-4303
lines changed

Some content is hidden

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

121 files changed

+4799
-4303
lines changed

.github/workflows/gradle.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
java: [11]
16-
os: [ubuntu-latest, windows-latest]
15+
java: [ 11 ]
16+
os: [ ubuntu-latest, windows-latest ]
1717
include:
1818
# TODO(casz) remove once https://github.com/testcontainers/testcontainers-java/pull/1780 is available
19-
- os: 'ubuntu-latest'
20-
tasks: 'integrationTest'
19+
- os: 'ubuntu-latest'
20+
tasks: 'integrationTest'
2121

2222
steps:
2323
- uses: actions/checkout@v1

.github/workflows/test-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Test Report'
22
on:
33
workflow_run:
4-
workflows: ['CI'] # runs after CI workflow
4+
workflows: [ 'CI' ] # runs after CI workflow
55
types:
66
- completed
77
jobs:

README.md

Lines changed: 331 additions & 253 deletions
Large diffs are not rendered by default.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ task unitTest(type: Test) {
114114
}
115115

116116
task integrationTest(type: Test) {
117-
testClassesDirs= sourceSets.integrationTests.output.classesDirs
117+
testClassesDirs = sourceSets.integrationTests.output.classesDirs
118118
classpath = sourceSets.integrationTests.runtimeClasspath
119119
testLogging {
120120
events "passed", "skipped", "failed"

src/main/java/io/github/jopenlibs/vault/EnvironmentLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import java.nio.file.Paths;
88

99
/**
10-
* The code used to load environment variables is encapsulated within an inner class,
11-
* so that a mock version of that environment loader can be used by unit tests.
10+
* The code used to load environment variables is encapsulated within an inner class, so that a mock
11+
* version of that environment loader can be used by unit tests.
1212
*/
1313
public class EnvironmentLoader implements Serializable {
1414

src/main/java/io/github/jopenlibs/vault/SslConfig.java

Lines changed: 257 additions & 192 deletions
Large diffs are not rendered by default.

src/main/java/io/github/jopenlibs/vault/Vault.java

Lines changed: 85 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
import java.util.logging.Logger;
2121

2222
/**
23-
* <p>The Vault driver class, the primary interface through which dependent applications will access Vault.</p>
23+
* <p>The Vault driver class, the primary interface through which dependent applications will
24+
* access Vault.</p>
2425
*
25-
* <p>This driver exposes a DSL, compartmentalizing the various endpoints of the HTTP API (e.g. "/", "sys/init",
26-
* "sys/seal") into separate implementation classes (e.g. <code>Logical</code>, <code>Init</code>, etc).</p>
26+
* <p>This driver exposes a DSL, compartmentalizing the various endpoints of the HTTP API (e.g.
27+
* "/", "sys/init", "sys/seal") into separate implementation classes (e.g. <code>Logical</code>,
28+
* <code>Init</code>, etc).</p>
2729
*
2830
* <p>Example usage:</p>
2931
*
@@ -57,74 +59,90 @@
5759
public class Vault {
5860

5961
private final VaultConfig vaultConfig;
60-
private Logger logger = Logger.getLogger(Vault.class.getCanonicalName());
62+
private Logger logger = Logger.getLogger(Vault.class.getCanonicalName());
6163

6264
/**
6365
* Construct a Vault driver instance with the provided config settings.
6466
*
65-
* @param vaultConfig Configuration settings for Vault interaction (e.g. server address, token, etc)
66-
* If the VaultConfig Engine version path map is not supplied in the config, default to global KV
67-
* engine version 2.
67+
* @param vaultConfig Configuration settings for Vault interaction (e.g. server address, token,
68+
* etc) If the VaultConfig Engine version path map is not supplied in the config, default to
69+
* global KV engine version 2.
6870
*/
6971
public Vault(final VaultConfig vaultConfig) {
7072
this.vaultConfig = vaultConfig;
7173
if (this.vaultConfig.getNameSpace() != null && !this.vaultConfig.getNameSpace().isEmpty()) {
72-
logger.info(String.format("The NameSpace %s has been bound to this Vault instance. Please keep this in mind when running operations.", this.vaultConfig.getNameSpace()));
74+
logger.info(String.format(
75+
"The NameSpace %s has been bound to this Vault instance. Please keep this in mind when running operations.",
76+
this.vaultConfig.getNameSpace()));
7377
}
74-
if (this.vaultConfig.getSecretsEnginePathMap().isEmpty() && this.vaultConfig.getGlobalEngineVersion() == null) {
75-
logger.info("Constructing a Vault instance with no provided Engine version, defaulting to version 2.");
78+
if (this.vaultConfig.getSecretsEnginePathMap().isEmpty()
79+
&& this.vaultConfig.getGlobalEngineVersion() == null) {
80+
logger.info(
81+
"Constructing a Vault instance with no provided Engine version, defaulting to version 2.");
7682
this.vaultConfig.setEngineVersion(2);
7783
}
7884
}
7985

8086
/**
81-
* Construct a Vault driver instance with the provided config settings, and use the provided global KV Engine version for all secrets.
87+
* Construct a Vault driver instance with the provided config settings, and use the provided
88+
* global KV Engine version for all secrets.
8289
*
83-
* @param vaultConfig Configuration settings for Vault interaction (e.g. server address, token, etc)
84-
* @param engineVersion Which version of the Key/Value Secret Engine to use globally (i.e. 1 or 2)
90+
* @param vaultConfig Configuration settings for Vault interaction (e.g. server address, token,
91+
* etc)
92+
* @param engineVersion Which version of the Key/Value Secret Engine to use globally (i.e. 1 or
93+
* 2)
8594
*/
8695
public Vault(final VaultConfig vaultConfig, final Integer engineVersion) {
8796
if (engineVersion < 1 || engineVersion > 2) {
88-
throw new IllegalArgumentException("The Engine version must be '1' or '2', the version supplied was: '"
89-
+ engineVersion + "'.");
97+
throw new IllegalArgumentException(
98+
"The Engine version must be '1' or '2', the version supplied was: '"
99+
+ engineVersion + "'.");
90100
}
91101
vaultConfig.setEngineVersion(engineVersion);
92102
this.vaultConfig = vaultConfig;
93103
if (this.vaultConfig.getNameSpace() != null && !this.vaultConfig.getNameSpace().isEmpty()) {
94-
logger.info(String.format("The Namespace %s has been bound to this Vault instance. Please keep this in mind when running operations.", this.vaultConfig.getNameSpace()));
104+
logger.info(String.format(
105+
"The Namespace %s has been bound to this Vault instance. Please keep this in mind when running operations.",
106+
this.vaultConfig.getNameSpace()));
95107
}
96108
}
97109

98110
/**
99111
* Construct a Vault driver instance with the provided config settings.
100112
*
101-
* @param vaultConfig Configuration settings for Vault interaction (e.g. server address, token, etc)
102-
* If the Secrets engine version path map is not provided, or does not contain the
103-
* requested secret, fall back to the global version supplied.
104-
* @param useSecretsEnginePathMap Whether to use a provided KV Engine version map from the Vault config, or generate one.
105-
* If a secrets KV Engine version map is not supplied, use Vault APIs to determine the
106-
* KV Engine version for each secret. This call requires admin rights.
107-
* @param globalFallbackVersion The Integer version of the KV Engine to use as a global fallback.
108-
*
109-
* @throws VaultException If any error occurs
113+
* @param vaultConfig Configuration settings for Vault interaction (e.g. server address, token,
114+
* etc) If the Secrets engine version path map is not provided, or does not contain the
115+
* requested secret, fall back to the global version supplied.
116+
* @param useSecretsEnginePathMap Whether to use a provided KV Engine version map from the Vault
117+
* config, or generate one. If a secrets KV Engine version map is not supplied, use Vault APIs
118+
* to determine the KV Engine version for each secret. This call requires admin rights.
119+
* @param globalFallbackVersion The Integer version of the KV Engine to use as a global
120+
* fallback.
121+
* @throws VaultException If any error occurs
110122
*/
111-
public Vault(final VaultConfig vaultConfig, final Boolean useSecretsEnginePathMap, final Integer globalFallbackVersion)
123+
public Vault(final VaultConfig vaultConfig, final Boolean useSecretsEnginePathMap,
124+
final Integer globalFallbackVersion)
112125
throws VaultException {
113126
this.vaultConfig = vaultConfig;
114127
if (this.vaultConfig.getNameSpace() != null && !this.vaultConfig.getNameSpace().isEmpty()) {
115-
logger.info(String.format("The Namespace %s has been bound to this Vault instance. Please keep this in mind when running operations.", this.vaultConfig.getNameSpace()));
128+
logger.info(String.format(
129+
"The Namespace %s has been bound to this Vault instance. Please keep this in mind when running operations.",
130+
this.vaultConfig.getNameSpace()));
116131
}
117132
this.vaultConfig.setEngineVersion(globalFallbackVersion);
118133
if (useSecretsEnginePathMap && this.vaultConfig.getSecretsEnginePathMap().isEmpty()) {
119134
try {
120-
logger.info("No secrets Engine version map was supplied, attempting to generate one.");
135+
logger.info(
136+
"No secrets Engine version map was supplied, attempting to generate one.");
121137
final Map<String, String> secretsEnginePathMap = collectSecretEngineVersions();
122138
assert secretsEnginePathMap != null;
123139
this.vaultConfig.getSecretsEnginePathMap().putAll(secretsEnginePathMap);
124140
} catch (Exception e) {
125-
throw new VaultException(String.format("An Engine KV version map was not supplied, and unable to determine " +
126-
"KV Engine " +
127-
"version, " + "due to exception: %s", e.getMessage() + ". Do you have admin rights?"));
141+
throw new VaultException(String.format(
142+
"An Engine KV version map was not supplied, and unable to determine " +
143+
"KV Engine " +
144+
"version, " + "due to exception: %s",
145+
e.getMessage() + ". Do you have admin rights?"));
128146
}
129147
}
130148
}
@@ -133,8 +151,10 @@ public Vault(final VaultConfig vaultConfig, final Boolean useSecretsEnginePathMa
133151
* This method is chained ahead of endpoints (e.g. <code>logical()</code>, <code>auth()</code>,
134152
* etc... to specify retry rules for any API operations invoked on that endpoint.
135153
*
136-
* @param maxRetries The number of times that API operations will be retried when a failure occurs
137-
* @param retryIntervalMilliseconds The number of milliseconds that the driver will wait in between retries
154+
* @param maxRetries The number of times that API operations will be retried when a failure
155+
* occurs
156+
* @param retryIntervalMilliseconds The number of milliseconds that the driver will wait in
157+
* between retries
138158
* @return This object, with maxRetries and retryIntervalMilliseconds populated
139159
*/
140160
public Vault withRetries(final int maxRetries, final int retryIntervalMilliseconds) {
@@ -153,7 +173,8 @@ public Logical logical() {
153173
}
154174

155175
/**
156-
* Returns the implementing class for operations on Vault's <code>/v1/auth/*</code> REST endpoints
176+
* Returns the implementing class for operations on Vault's <code>/v1/auth/*</code> REST
177+
* endpoints
157178
*
158179
* @return The implementing class for Vault's auth operations.
159180
*/
@@ -162,7 +183,8 @@ public Auth auth() {
162183
}
163184

164185
/**
165-
* Returns the implementing class for Vault's PKI secret backend (i.e. <code>/v1/pki/*</code> REST endpoints).
186+
* Returns the implementing class for Vault's PKI secret backend (i.e. <code>/v1/pki/*</code>
187+
* REST endpoints).
166188
*
167189
* @return The implementing class for Vault's PKI secret backend.
168190
*/
@@ -171,10 +193,11 @@ public Pki pki() {
171193
}
172194

173195
/**
174-
* <p>Returns the implementing class for Vault's PKI secret backend, using a custom path when that backend is
175-
* mounted on something other than the default (i.e. <code>/v1/pki</code>).</p>
196+
* <p>Returns the implementing class for Vault's PKI secret backend, using a custom path when
197+
* that backend is mounted on something other than the default (i.e. <code>/v1/pki</code>).</p>
176198
*
177-
* <p>For instance, if your PKI backend is instead mounted on <code>/v1/root-ca</code>, then <code>"root-ca"</code>
199+
* <p>For instance, if your PKI backend is instead mounted on <code>/v1/root-ca</code>, then
200+
* <code>"root-ca"</code>
178201
* would be passed via the <code>mountPath</code> parameter. Example usage:</p>
179202
*
180203
* <blockquote>
@@ -187,16 +210,21 @@ public Pki pki() {
187210
* }</pre>
188211
* </blockquote>
189212
*
190-
* @param mountPath The path on which your Vault PKI backend is mounted, without the <code>/v1/</code> prefix
213+
* @param mountPath The path on which your Vault PKI backend is mounted, without the
214+
* <code>/v1/</code> prefix
191215
* @return The implementing class for Vault's PKI secret backend.
192216
*/
193217
public Pki pki(final String mountPath) {
194218
return new Pki(vaultConfig, mountPath);
195219
}
196220

197-
public Database database() { return new Database(vaultConfig); }
221+
public Database database() {
222+
return new Database(vaultConfig);
223+
}
198224

199-
public Database database(final String mountPath) { return new Database(vaultConfig, mountPath); }
225+
public Database database(final String mountPath) {
226+
return new Database(vaultConfig, mountPath);
227+
}
200228

201229
/**
202230
* Returns the implementing class for Vault's lease operations (e.g. revoke, revoke-prefix).
@@ -217,7 +245,8 @@ public Debug debug() {
217245
}
218246

219247
/**
220-
* Returns the implementing class for Vault's sys mounts operations (i.e. <code>/v1/sys/mounts/*</code> REST endpoints).
248+
* Returns the implementing class for Vault's sys mounts operations (i.e.
249+
* <code>/v1/sys/mounts/*</code> REST endpoints).
221250
*
222251
* @return the implementing class for Vault's sys mounts operations
223252
*/
@@ -235,17 +264,21 @@ public Seal seal() {
235264
}
236265

237266
/**
238-
* Makes a REST call to Vault, to collect information on which secret engine version (if any) is used by each available
239-
* mount point. Possibilities are:
267+
* Makes a REST call to Vault, to collect information on which secret engine version (if any) is
268+
* used by each available mount point. Possibilities are:
240269
*
241270
* <ul>
242-
* <li>"2" - A mount point running on Vault 0.10 or higher, configured to use the engine 2 API</li>
243-
* <li>"1" - A mount point running on Vault 0.10 or higher, configured to use the engine 1 API</li>
244-
* <li>"unknown" - A mount point running on an older version of Vault. Can more or less be treated as "1".</li>
271+
* <li>"2" - A mount point running on Vault 0.10 or higher, configured to use the engine 2
272+
* API</li>
273+
* <li>"1" - A mount point running on Vault 0.10 or higher, configured to use the engine 1
274+
* API</li>
275+
* <li>"unknown" - A mount point running on an older version of Vault. Can more or less be
276+
* treated as "1".</li>
245277
* </ul>
246278
* <p>
247-
* IMPORTANT: Whichever authentication mechanism is being used with the <code>VaultConfig</code> object, that principal
248-
* needs permission to access the <code>/v1/sys/mounts</code> REST endpoint.
279+
* IMPORTANT: Whichever authentication mechanism is being used with the
280+
* <code>VaultConfig</code> object, that principal needs permission to access the
281+
* <code>/v1/sys/mounts</code> REST endpoint.
249282
*
250283
* @return A map of mount points (e.g. "/secret") to secret engine version numbers (e.g. "2")
251284
*/
@@ -283,7 +316,9 @@ private Map<String, String> collectSecretEngineVersions() {
283316
}
284317
return data;
285318
} catch (RestException e) {
286-
System.err.print(String.format("Unable to retrieve the KV Engine secrets, due to exception: %s", e.getMessage()));
319+
System.err.print(
320+
String.format("Unable to retrieve the KV Engine secrets, due to exception: %s",
321+
e.getMessage()));
287322
return null;
288323
}
289324
}

0 commit comments

Comments
 (0)