Skip to content

Commit a404206

Browse files
Merge pull request #165 from pjriot/master
Drop lombok & jaxb dependencies & package module-info for JDK9+
2 parents 8c0b01a + 8d270ec commit a404206

File tree

5 files changed

+118
-31
lines changed

5 files changed

+118
-31
lines changed

build.gradle

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ compileJava {
1212
targetCompatibility = 1.8
1313
}
1414

15+
sourceSets {
16+
main {
17+
java {
18+
exclude 'module-info.java'
19+
}
20+
}
21+
mainModuleInfo {
22+
java {
23+
srcDirs = ['src/main/java']
24+
outputDir = file("$buildDir/classes/java/main")
25+
include 'module-info.java'
26+
}
27+
}
28+
}
29+
30+
classes.dependsOn mainModuleInfoClasses
31+
compileMainModuleInfoJava.options.compilerArgs.addAll(['--release', '9'])
32+
1533
compileTestJava {
1634
sourceCompatibility = 1.8
1735
targetCompatibility = 1.8
@@ -22,8 +40,6 @@ repositories {
2240
}
2341

2442
dependencies {
25-
compileOnly('org.projectlombok:lombok:1.18.4')
26-
2743
testCompile('junit:junit:4.12')
2844
testCompile('org.mockito:mockito-core:2.23.4')
2945
testCompile('org.testcontainers:testcontainers:1.6.0')

src/main/java/com/bettercloud/vault/SslConfig.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package com.bettercloud.vault;
22

33
import com.bettercloud.vault.api.Auth;
4-
import lombok.AccessLevel;
5-
import lombok.Getter;
64

75
import javax.net.ssl.KeyManager;
86
import javax.net.ssl.KeyManagerFactory;
97
import javax.net.ssl.SSLContext;
108
import javax.net.ssl.TrustManager;
119
import javax.net.ssl.TrustManagerFactory;
12-
import javax.xml.bind.DatatypeConverter;
1310
import java.io.BufferedReader;
1411
import java.io.ByteArrayInputStream;
1512
import java.io.File;
@@ -33,6 +30,7 @@
3330
import java.security.cert.X509Certificate;
3431
import java.security.spec.InvalidKeySpecException;
3532
import java.security.spec.PKCS8EncodedKeySpec;
33+
import java.util.Base64;
3634

3735
/**
3836
* <p>A container for SSL-related configuration options, meant to be stored within a {@link VaultConfig} instance.</p>
@@ -47,12 +45,12 @@ public class SslConfig implements Serializable {
4745
private static final String VAULT_SSL_VERIFY = "VAULT_SSL_VERIFY";
4846
private static final String VAULT_SSL_CERT = "VAULT_SSL_CERT";
4947

50-
@Getter private boolean verify;
51-
@Getter private transient SSLContext sslContext;
48+
private boolean verify;
49+
private transient SSLContext sslContext;
5250
private transient KeyStore trustStore;
5351
private transient KeyStore keyStore;
5452
private String keyStorePassword;
55-
@Getter(AccessLevel.PROTECTED) private String pemUTF8; // exposed to unit tests
53+
private String pemUTF8; // exposed to unit tests
5654
private String clientPemUTF8;
5755
private String clientKeyPemUTF8;
5856
private Boolean verifyObject;
@@ -464,6 +462,18 @@ public SslConfig build() throws VaultException {
464462
return this;
465463
}
466464

465+
public boolean isVerify() {
466+
return verify;
467+
}
468+
469+
public SSLContext getSslContext() {
470+
return sslContext;
471+
}
472+
473+
protected String getPemUTF8() {
474+
return pemUTF8;
475+
}
476+
467477
/**
468478
* <p>Constructs the {@link this#sslContext} member field, if SSL verification is enabled and any JKS or PEM-based
469479
* data was populated. This method is broken off from {@link this#build()}, because the same process must
@@ -561,7 +571,7 @@ private SSLContext buildSslContextFromPem() throws VaultException {
561571
// Convert the client private key into a PrivateKey
562572
final String strippedKey = clientKeyPemUTF8.replace("-----BEGIN PRIVATE KEY-----", "")
563573
.replace("-----END PRIVATE KEY-----", "");
564-
final byte[] keyBytes = DatatypeConverter.parseBase64Binary(strippedKey);
574+
final byte[] keyBytes = Base64.getDecoder().decode(strippedKey);
565575
final PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(keyBytes);
566576
final KeyFactory factory = KeyFactory.getInstance("RSA");
567577
final PrivateKey privateKey = factory.generatePrivate(pkcs8EncodedKeySpec);

src/main/java/com/bettercloud/vault/VaultConfig.java

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.bettercloud.vault;
22

3-
import lombok.Getter;
4-
53
import java.io.Serializable;
64
import java.util.Map;
75
import java.util.concurrent.ConcurrentHashMap;
@@ -32,25 +30,15 @@ public class VaultConfig implements Serializable {
3230
private static final String VAULT_OPEN_TIMEOUT = "VAULT_OPEN_TIMEOUT";
3331
private static final String VAULT_READ_TIMEOUT = "VAULT_READ_TIMEOUT";
3432

35-
@Getter
3633
private Map<String, String> secretsEnginePathMap = new ConcurrentHashMap<>();
37-
@Getter
3834
private String address;
39-
@Getter
4035
private String token;
41-
@Getter
4236
private SslConfig sslConfig;
43-
@Getter
4437
private Integer openTimeout;
45-
@Getter
4638
private Integer readTimeout;
47-
@Getter
4839
private int maxRetries;
49-
@Getter
5040
private int retryIntervalMilliseconds;
51-
@Getter
5241
private Integer globalEngineVersion;
53-
@Getter
5442
private String nameSpace;
5543
private EnvironmentLoader environmentLoader;
5644

@@ -285,5 +273,45 @@ public VaultConfig build() throws VaultException {
285273
return this;
286274
}
287275

276+
public Map<String, String> getSecretsEnginePathMap() {
277+
return secretsEnginePathMap;
278+
}
279+
280+
public String getAddress() {
281+
return address;
282+
}
283+
284+
public String getToken() {
285+
return token;
286+
}
287+
288+
public SslConfig getSslConfig() {
289+
return sslConfig;
290+
}
291+
292+
public Integer getOpenTimeout() {
293+
return openTimeout;
294+
}
295+
296+
public Integer getReadTimeout() {
297+
return readTimeout;
298+
}
299+
300+
public int getMaxRetries() {
301+
return maxRetries;
302+
}
303+
304+
public int getRetryIntervalMilliseconds() {
305+
return retryIntervalMilliseconds;
306+
}
307+
308+
public Integer getGlobalEngineVersion() {
309+
return globalEngineVersion;
310+
}
311+
312+
public String getNameSpace() {
313+
return nameSpace;
314+
}
315+
288316
}
289317

src/main/java/com/bettercloud/vault/api/Auth.java

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.bettercloud.vault.response.LookupResponse;
1111
import com.bettercloud.vault.rest.Rest;
1212
import com.bettercloud.vault.rest.RestResponse;
13-
import lombok.Getter;
1413

1514
import java.io.Serializable;
1615
import java.nio.charset.StandardCharsets;
@@ -40,23 +39,14 @@ public class Auth {
4039
*/
4140
public static class TokenRequest implements Serializable {
4241

43-
@Getter
4442
private UUID id;
45-
@Getter
4643
private List<String> polices;
47-
@Getter
4844
private Map<String, String> meta;
49-
@Getter
5045
private Boolean noParent;
51-
@Getter
5246
private Boolean noDefaultPolicy;
53-
@Getter
5447
private String ttl;
55-
@Getter
5648
private String displayName;
57-
@Getter
5849
private Long numUses;
59-
@Getter
6050
private String role;
6151

6252
/**
@@ -139,6 +129,42 @@ public TokenRequest role(final String role) {
139129
this.role = role;
140130
return this;
141131
}
132+
133+
public UUID getId() {
134+
return id;
135+
}
136+
137+
public List<String> getPolices() {
138+
return polices;
139+
}
140+
141+
public Map<String, String> getMeta() {
142+
return meta;
143+
}
144+
145+
public Boolean getNoParent() {
146+
return noParent;
147+
}
148+
149+
public Boolean getNoDefaultPolicy() {
150+
return noDefaultPolicy;
151+
}
152+
153+
public String getTtl() {
154+
return ttl;
155+
}
156+
157+
public String getDisplayName() {
158+
return displayName;
159+
}
160+
161+
public Long getNumUses() {
162+
return numUses;
163+
}
164+
165+
public String getRole() {
166+
return role;
167+
}
142168
}
143169

144170
private final VaultConfig config;

src/main/java/module-info.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module vault.java.driver {
2+
exports com.bettercloud.vault;
3+
exports com.bettercloud.vault.api;
4+
exports com.bettercloud.vault.json;
5+
exports com.bettercloud.vault.response;
6+
exports com.bettercloud.vault.rest;
7+
}

0 commit comments

Comments
 (0)