diff --git a/build.gradle b/build.gradle index 5cb1cfd2..770f791f 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,24 @@ compileJava { targetCompatibility = 1.8 } +sourceSets { + main { + java { + exclude 'module-info.java' + } + } + mainModuleInfo { + java { + srcDirs = ['src/main/java'] + outputDir = file("$buildDir/classes/java/main") + include 'module-info.java' + } + } +} + +classes.dependsOn mainModuleInfoClasses +compileMainModuleInfoJava.options.compilerArgs.addAll(['--release', '9']) + compileTestJava { sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -22,8 +40,6 @@ repositories { } dependencies { - compileOnly('org.projectlombok:lombok:1.18.4') - testCompile('junit:junit:4.12') testCompile('org.mockito:mockito-core:2.23.4') testCompile('org.testcontainers:testcontainers:1.6.0') diff --git a/src/main/java/com/bettercloud/vault/SslConfig.java b/src/main/java/com/bettercloud/vault/SslConfig.java index e2349ba3..9f29cfe4 100644 --- a/src/main/java/com/bettercloud/vault/SslConfig.java +++ b/src/main/java/com/bettercloud/vault/SslConfig.java @@ -1,15 +1,12 @@ package com.bettercloud.vault; import com.bettercloud.vault.api.Auth; -import lombok.AccessLevel; -import lombok.Getter; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; -import javax.xml.bind.DatatypeConverter; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -33,6 +30,7 @@ import java.security.cert.X509Certificate; import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; +import java.util.Base64; /** *
A container for SSL-related configuration options, meant to be stored within a {@link VaultConfig} instance.
@@ -47,12 +45,12 @@ public class SslConfig implements Serializable { private static final String VAULT_SSL_VERIFY = "VAULT_SSL_VERIFY"; private static final String VAULT_SSL_CERT = "VAULT_SSL_CERT"; - @Getter private boolean verify; - @Getter private transient SSLContext sslContext; + private boolean verify; + private transient SSLContext sslContext; private transient KeyStore trustStore; private transient KeyStore keyStore; private String keyStorePassword; - @Getter(AccessLevel.PROTECTED) private String pemUTF8; // exposed to unit tests + private String pemUTF8; // exposed to unit tests private String clientPemUTF8; private String clientKeyPemUTF8; private Boolean verifyObject; @@ -464,6 +462,18 @@ public SslConfig build() throws VaultException { return this; } + public boolean isVerify() { + return verify; + } + + public SSLContext getSslContext() { + return sslContext; + } + + protected String getPemUTF8() { + return pemUTF8; + } + /** *Constructs the {@link this#sslContext} member field, if SSL verification is enabled and any JKS or PEM-based
* 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 {
// Convert the client private key into a PrivateKey
final String strippedKey = clientKeyPemUTF8.replace("-----BEGIN PRIVATE KEY-----", "")
.replace("-----END PRIVATE KEY-----", "");
- final byte[] keyBytes = DatatypeConverter.parseBase64Binary(strippedKey);
+ final byte[] keyBytes = Base64.getDecoder().decode(strippedKey);
final PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(keyBytes);
final KeyFactory factory = KeyFactory.getInstance("RSA");
final PrivateKey privateKey = factory.generatePrivate(pkcs8EncodedKeySpec);
diff --git a/src/main/java/com/bettercloud/vault/VaultConfig.java b/src/main/java/com/bettercloud/vault/VaultConfig.java
index d34990c6..8925cf54 100644
--- a/src/main/java/com/bettercloud/vault/VaultConfig.java
+++ b/src/main/java/com/bettercloud/vault/VaultConfig.java
@@ -1,7 +1,5 @@
package com.bettercloud.vault;
-import lombok.Getter;
-
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -32,25 +30,15 @@ public class VaultConfig implements Serializable {
private static final String VAULT_OPEN_TIMEOUT = "VAULT_OPEN_TIMEOUT";
private static final String VAULT_READ_TIMEOUT = "VAULT_READ_TIMEOUT";
- @Getter
private Map