From f4f1318b19c90016c70a0af457020361733b69f3 Mon Sep 17 00:00:00 2001 From: Maciej Wejs Date: Tue, 6 Nov 2018 16:38:46 +0100 Subject: Names change of SSL config params Change-Id: I719b38b76fec976c459bfca6ffdc6dd9c1d7b00c Issue-ID: DCAEGEN2-953 Signed-off-by: Maciej Wejs --- .../onap/dcaegen2/services/prh/ssl/SslFactory.java | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'prh-commons/src/main/java') diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/ssl/SslFactory.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/ssl/SslFactory.java index 6ffff1b9..891bcb73 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/ssl/SslFactory.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/ssl/SslFactory.java @@ -38,16 +38,16 @@ public class SslFactory { private static final Logger LOGGER = LoggerFactory.getLogger(SslFactory.class); - public SslContext createSecureContext(String keyStoreFilename, - String keyStorePassword, - String trustStoreFilename, - String trustStorePassword) throws SSLException { - LOGGER.info("Creating secure ssl context for: {} {}", keyStoreFilename, trustStoreFilename); + public SslContext createSecureContext(String keyStorePath, + String keyStorePasswordPath, + String trustStorePath, + String trustStorePasswordPath) throws SSLException { + LOGGER.info("Creating secure ssl context for: {} {}", keyStorePath, trustStorePath); try { return SslContextBuilder .forClient() - .keyManager(keyManagerFactory(keyStoreFilename, loadPasswordFromFile(keyStorePassword))) - .trustManager(trustManagerFactory(trustStoreFilename, loadPasswordFromFile(trustStorePassword))) + .keyManager(keyManagerFactory(keyStorePath, loadPasswordFromFile(keyStorePasswordPath))) + .trustManager(trustManagerFactory(trustStorePath, loadPasswordFromFile(trustStorePasswordPath))) .build(); } catch (Exception ex) { throw new SSLException(ex); @@ -62,27 +62,27 @@ public class SslFactory { .build(); } - private KeyManagerFactory keyManagerFactory(String fileName, String password) throws Exception { + private KeyManagerFactory keyManagerFactory(String path, String password) throws Exception { KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - kmf.init(loadKeyStoreFromFile(fileName, password), + kmf.init(loadKeyStoreFromFile(path, password), password.toCharArray()); return kmf; } - private TrustManagerFactory trustManagerFactory(String fileName, String password) throws Exception { + private TrustManagerFactory trustManagerFactory(String path, String password) throws Exception { TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - tmf.init(loadKeyStoreFromFile(fileName, password)); + tmf.init(loadKeyStoreFromFile(path, password)); return tmf; } - private KeyStore loadKeyStoreFromFile(String fileName, String keyStorePassword) throws Exception { + private KeyStore loadKeyStoreFromFile(String path, String keyStorePassword) throws Exception { KeyStore ks = KeyStore.getInstance("jks"); - ks.load(getResource(fileName), keyStorePassword.toCharArray()); + ks.load(getResource(path), keyStorePassword.toCharArray()); return ks; } - private InputStream getResource(String fileName) throws Exception { - return new FileInputStream(fileName); + private InputStream getResource(String path) throws Exception { + return new FileInputStream(path); } private String loadPasswordFromFile(String path) throws Exception { -- cgit 1.2.3-korg