aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorIoannis Sotiropoulos <Ioannis.Sotiropoulos@amdocs.com>2018-08-23 14:49:09 +0100
committerIoannis Sotiropoulos <Ioannis.Sotiropoulos@amdocs.com>2018-08-23 14:49:09 +0100
commit1bb47af61f827c9c3a32374b0056c20dd2d37fec (patch)
tree35a509aa0d55b6136a24f11ec09c9a73c63b7e9a /src/main
parent20c07d33b4b614588481708b4f8f8ff5308b0e43 (diff)
Set trust store
Set required system parameters to specify the correct trust store to use for outgoing HTTPS connections. Change-Id: If1fa9139ae2bc83cba6a8281c59114fdaadb07f7 Issue-ID: AAI-1537 Signed-off-by: Ioannis Sotiropoulos <Ioannis.Sotiropoulos@amdocs.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/aai/spike/SpikeApplication.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main/java/org/onap/aai/spike/SpikeApplication.java b/src/main/java/org/onap/aai/spike/SpikeApplication.java
index da9a433..426731b 100644
--- a/src/main/java/org/onap/aai/spike/SpikeApplication.java
+++ b/src/main/java/org/onap/aai/spike/SpikeApplication.java
@@ -21,11 +21,14 @@
package org.onap.aai.spike;
import java.util.HashMap;
+import javax.annotation.PostConstruct;
import org.eclipse.jetty.util.security.Password;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ImportResource;
+import org.springframework.core.env.Environment;
/**
* Spike service Spring Boot Application
@@ -33,7 +36,9 @@ import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@ImportResource({"file:${SERVICE_BEANS}/*.xml"})
public class SpikeApplication extends SpringBootServletInitializer {
-
+ @Autowired
+ private Environment env;
+
public static void main(String[] args) {
String keyStorePassword = System.getProperty("KEY_STORE_PASSWORD");
if (keyStorePassword == null || keyStorePassword.isEmpty()) {
@@ -45,4 +50,21 @@ public class SpikeApplication extends SpringBootServletInitializer {
.run(args);
}
+ /**
+ * Set required trust store system properties using values from application.properties
+ */
+ @PostConstruct
+ public void setSystemProperties() {
+ String trustStorePath = env.getProperty("server.ssl.key-store");
+ if (trustStorePath != null) {
+ String trustStorePassword = env.getProperty("server.ssl.key-store-password");
+
+ if (trustStorePassword != null) {
+ System.setProperty("javax.net.ssl.trustStore", trustStorePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
+ } else {
+ throw new IllegalArgumentException("Env property server.ssl.key-store-password not set");
+ }
+ }
+ }
}