summaryrefslogtreecommitdiffstats
path: root/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/SslContextFactory.java
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2017-11-10 18:50:24 +0100
committerGitHub <noreply@github.com>2017-11-10 18:50:24 +0100
commitc56091ffa4da34a2913b73f860cff2b6fa746c43 (patch)
tree1d7b53c77e927688fb041157de68797187620163 /jdisc_http_service/src/test/java/com/yahoo/jdisc/http/SslContextFactory.java
parentef22b222d1862f6b5a56521f43830abae30eec70 (diff)
Revert "Bjorncs/jdisc http service cleanup"
Diffstat (limited to 'jdisc_http_service/src/test/java/com/yahoo/jdisc/http/SslContextFactory.java')
-rw-r--r--jdisc_http_service/src/test/java/com/yahoo/jdisc/http/SslContextFactory.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/SslContextFactory.java b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/SslContextFactory.java
index 5dd5dca1667..e71bd190a37 100644
--- a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/SslContextFactory.java
+++ b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/SslContextFactory.java
@@ -1,11 +1,16 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http;
-import com.yahoo.jdisc.http.ssl.jks.JksKeyStore;
+import com.yahoo.jdisc.http.ssl.SslKeyStore;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -27,16 +32,16 @@ public class SslContextFactory {
return this.sslContext;
}
- public static SslContextFactory newInstanceFromTrustStore(JksKeyStore trustStore) {
+ public static SslContextFactory newInstanceFromTrustStore(SslKeyStore trustStore) {
return newInstance(DEFAULT_ALGORITHM, DEFAULT_PROTOCOL, null, trustStore);
}
- public static SslContextFactory newInstance(JksKeyStore trustStore, JksKeyStore keyStore) {
+ public static SslContextFactory newInstance(SslKeyStore trustStore, SslKeyStore keyStore) {
return newInstance(DEFAULT_ALGORITHM, DEFAULT_PROTOCOL, keyStore, trustStore);
}
public static SslContextFactory newInstance(String sslAlgorithm, String sslProtocol,
- JksKeyStore keyStore, JksKeyStore trustStore) {
+ SslKeyStore keyStore, SslKeyStore trustStore) {
log.fine("Configuring SSLContext...");
log.fine("Using " + sslAlgorithm + " algorithm.");
try {
@@ -55,14 +60,15 @@ public class SslContextFactory {
/**
* Used for the key store, which contains the SSL cert and private key.
*/
- public static javax.net.ssl.KeyManager[] getKeyManagers(JksKeyStore keyStore,
- String sslAlgorithm) throws Exception {
+ public static javax.net.ssl.KeyManager[] getKeyManagers(SslKeyStore keyStore,
+ String sslAlgorithm)
+ throws NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException,
+ KeyStoreException {
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(sslAlgorithm);
- String keyStorePassword = keyStore.getKeyStorePassword();
keyManagerFactory.init(
keyStore.loadJavaKeyStore(),
- keyStorePassword != null ? keyStorePassword.toCharArray() : null);
+ keyStore.getKeyStorePassword().map(String::toCharArray).orElse(null));
log.fine("KeyManagerFactory initialized with keystore");
return keyManagerFactory.getKeyManagers();
}
@@ -71,9 +77,9 @@ public class SslContextFactory {
* Used for the trust store, which contains certificates from other parties that you expect to communicate with,
* or from Certificate Authorities that you trust to identify other parties.
*/
- public static javax.net.ssl.TrustManager[] getTrustManagers(JksKeyStore trustStore,
+ public static javax.net.ssl.TrustManager[] getTrustManagers(SslKeyStore trustStore,
String sslAlgorithm)
- throws Exception {
+ throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException {
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(sslAlgorithm);
trustManagerFactory.init(trustStore.loadJavaKeyStore());