aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2023-06-02 11:38:36 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-06-02 16:21:12 +0000
commit222555c7995645416a47bc52ed8837e3afde8e21 (patch)
tree0eae25247dfbc06538a9170dc5ab9a8addeb5bb3 /common
parent9fb750f15ee84c4318d729c91c4ba50b61d73b3e (diff)
Revert "Support SIP TLS"
This reverts commit a2feaf9b65cbba66181fb560b5815a62427d65cc. Reason for revert: deployment issue Change-Id: Ic21e213493f51d0c11778187ab054881bba7c21e Issue-ID: SDC-4483 Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'common')
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-api/pom.xml5
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/JettySSLUtils.java79
2 files changed, 40 insertions, 44 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-api/pom.xml b/common/onap-common-configuration-management/onap-configuration-management-api/pom.xml
index aa6a43e12d..e45218442b 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-api/pom.xml
+++ b/common/onap-common-configuration-management/onap-configuration-management-api/pom.xml
@@ -24,11 +24,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- <version>${lombok.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
diff --git a/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/JettySSLUtils.java b/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/JettySSLUtils.java
index ad3395f720..44280cf105 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/JettySSLUtils.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/JettySSLUtils.java
@@ -19,61 +19,59 @@
*/
package org.onap.config.api;
-import lombok.AccessLevel;
-import lombok.AllArgsConstructor;
-import lombok.NoArgsConstructor;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-import org.apache.http.ssl.SSLContexts;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.net.ssl.SSLContext;
+import java.io.File;
import java.io.FileInputStream;
-import java.io.InputStream;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.util.Properties;
+import javax.net.ssl.SSLContext;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.ssl.SSLContexts;
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class JettySSLUtils {
- private static final Logger LOGGER = LoggerFactory.getLogger(JettySSLUtils.class);
- private static final String JETTY_BASE = System.getenv("JETTY_BASE");
- public static JettySslConfig getSSLConfig() {
- final Properties sslProperties = new Properties();
- final String sslPropsPath = JETTY_BASE + "/start.d/ssl.ini";
- try (final InputStream fis = new FileInputStream(sslPropsPath)) {
+ private JettySSLUtils() {
+ }
+
+ public static JettySslConfig getSSLConfig() throws IOException {
+ Properties sslProperties = new Properties();
+ String sslPropsPath = System.getenv("JETTY_BASE") + File.separator + "/start.d/ssl.ini";
+ File sslPropsFile = new File(sslPropsPath);
+ try (FileInputStream fis = new FileInputStream(sslPropsFile)) {
sslProperties.load(fis);
- } catch (Exception e) {
- LOGGER.error("Failed to read '{}'", sslPropsPath, e);
}
return new JettySslConfig(sslProperties);
}
- public static SSLContext getSslContext() throws Exception {
- final JettySslConfig sslProperties = getSSLConfig();
- final KeyStore trustStore = KeyStore.getInstance(sslProperties.getTruststoreType());
- try (final InputStream fis = new FileInputStream(sslProperties.getTruststorePath())) {
- trustStore.load(fis, (sslProperties.getTruststorePass()).toCharArray());
+ public static SSLContext getSslContext() throws GeneralSecurityException, IOException {
+ JettySslConfig sslProperties = JettySSLUtils.getSSLConfig();
+ KeyStore trustStore = KeyStore.getInstance(sslProperties.getTruststoreType());
+ try (FileInputStream instream = new FileInputStream(new File(sslProperties.getTruststorePath()));) {
+ trustStore.load(instream, (sslProperties.getTruststorePass()).toCharArray());
}
-
- final KeyStore keystore = KeyStore.getInstance(sslProperties.getKeystoreType());
- try (final InputStream fis = new FileInputStream(sslProperties.getKeystorePath())) {
- keystore.load(fis, sslProperties.getKeystorePass().toCharArray());
+ KeyStore keystore = KeyStore.getInstance(sslProperties.getKeystoreType());
+ try (FileInputStream instream = new FileInputStream(new File(sslProperties.getKeystorePath()));) {
+ keystore.load(instream, sslProperties.getKeystorePass().toCharArray());
}
// Trust own CA and all self-signed certs
- return SSLContexts.custom()
- .loadKeyMaterial(keystore, sslProperties.getKeystorePass().toCharArray())
- .loadTrustMaterial(trustStore, new TrustSelfSignedStrategy())
- .build();
+ return SSLContexts.custom().loadKeyMaterial(keystore, sslProperties.getKeystorePass().toCharArray())
+ .loadTrustMaterial(trustStore, new TrustSelfSignedStrategy()).build();
}
- @AllArgsConstructor
public static class JettySslConfig {
- private final Properties sslProperties;
+ static final String JETTY_BASE = System.getenv("JETTY_BASE");
+ static final String KEY_STORE_TYPE_PROPERTY_NAME = "jetty.sslContext.keyStoreType";
+ static final String TRUST_STORE_TYPE_PROPERTY_NAME = "jetty.sslContext.trustStoreType";
+ Properties sslProperties;
- public String getJettyBase(){
- return JETTY_BASE;
+ JettySslConfig(Properties sslProperties) {
+ this.sslProperties = sslProperties;
+ }
+
+ public String getJettyBase() {
+ return JettySslConfig.JETTY_BASE;
}
public String getKeystorePath() {
@@ -85,7 +83,7 @@ public class JettySSLUtils {
}
public String getKeystoreType() {
- return sslProperties.getProperty("jetty.sslContext.keyStoreType", KeyStore.getDefaultType());
+ return sslProperties.getProperty(KEY_STORE_TYPE_PROPERTY_NAME, KeyStore.getDefaultType());
}
public String getTruststorePath() {
@@ -97,10 +95,10 @@ public class JettySSLUtils {
}
public String getTruststoreType() {
- return sslProperties.getProperty("jetty.sslContext.trustStoreType", KeyStore.getDefaultType());
+ return sslProperties.getProperty(TRUST_STORE_TYPE_PROPERTY_NAME, KeyStore.getDefaultType());
}
- public String getKeyManagerPassword() {
+ public String getKeyStoreManager() {
return sslProperties.getProperty("jetty.sslContext.keyManagerPassword");
}
@@ -112,5 +110,8 @@ public class JettySSLUtils {
}
}
+ public String getProperty(String key) {
+ return sslProperties.getProperty(key);
+ }
}
}