|
1 | 1 | package com.bettercloud.vault; |
2 | 2 |
|
3 | 3 | import com.bettercloud.vault.api.Auth; |
4 | | - |
5 | | -import javax.net.ssl.KeyManager; |
6 | | -import javax.net.ssl.KeyManagerFactory; |
7 | | -import javax.net.ssl.SSLContext; |
8 | | -import javax.net.ssl.TrustManager; |
9 | | -import javax.net.ssl.TrustManagerFactory; |
10 | 4 | import java.io.BufferedReader; |
11 | 5 | import java.io.ByteArrayInputStream; |
12 | 6 | import java.io.File; |
|
31 | 25 | import java.security.spec.InvalidKeySpecException; |
32 | 26 | import java.security.spec.PKCS8EncodedKeySpec; |
33 | 27 | import java.util.Base64; |
| 28 | +import javax.net.ssl.KeyManager; |
| 29 | +import javax.net.ssl.KeyManagerFactory; |
| 30 | +import javax.net.ssl.SSLContext; |
| 31 | +import javax.net.ssl.TrustManager; |
| 32 | +import javax.net.ssl.TrustManagerFactory; |
34 | 33 |
|
35 | 34 | /** |
36 | 35 | * <p>A container for SSL-related configuration options, meant to be stored within a {@link VaultConfig} instance.</p> |
@@ -444,13 +443,13 @@ public SslConfig build() throws VaultException { |
444 | 443 | this.environmentLoader = new EnvironmentLoader(); |
445 | 444 | } |
446 | 445 | if (this.verifyObject == null && environmentLoader.loadVariable(VAULT_SSL_VERIFY) != null) { |
447 | | - this.verify = Boolean.valueOf(environmentLoader.loadVariable(VAULT_SSL_VERIFY)); |
| 446 | + this.verify = Boolean.parseBoolean(environmentLoader.loadVariable(VAULT_SSL_VERIFY)); |
448 | 447 | } else if (this.verifyObject != null) { |
449 | 448 | this.verify = verifyObject; |
450 | 449 | } else { |
451 | 450 | this.verify = true; |
452 | 451 | } |
453 | | - if (this.verify == true && this.pemUTF8 == null && environmentLoader.loadVariable(VAULT_SSL_CERT) != null) { |
| 452 | + if (this.verify && this.pemUTF8 == null && environmentLoader.loadVariable(VAULT_SSL_CERT) != null) { |
454 | 453 | final File pemFile = new File(environmentLoader.loadVariable(VAULT_SSL_CERT)); |
455 | 454 | try (final InputStream input = new FileInputStream(pemFile)) { |
456 | 455 | this.pemUTF8 = inputStreamToUTF8(input); |
@@ -487,7 +486,7 @@ protected String getPemUTF8() { |
487 | 486 | * @throws VaultException |
488 | 487 | */ |
489 | 488 | private void buildSsl() throws VaultException { |
490 | | - if (verify == true) { |
| 489 | + if (verify) { |
491 | 490 | if (keyStore != null || trustStore != null) { |
492 | 491 | this.sslContext = buildSslContextFromJks(); |
493 | 492 | } else if (pemUTF8 != null || clientPemUTF8 != null || clientKeyPemUTF8 != null) { |
@@ -625,7 +624,7 @@ private KeyStore inputStreamToKeyStore(final InputStream inputStream, final Stri |
625 | 624 | */ |
626 | 625 | private static String inputStreamToUTF8(final InputStream input) throws IOException { |
627 | 626 | final BufferedReader in = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)); |
628 | | - final StringBuilder utf8 = new StringBuilder(""); |
| 627 | + final StringBuilder utf8 = new StringBuilder(); |
629 | 628 | String str; |
630 | 629 | while ((str = in.readLine()) != null) { |
631 | 630 | // String concatenation is less efficient, but for some reason the line-breaks (which are necessary |
|
0 commit comments