Fix Rest client of policy agent
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / configuration / ApplicationConfig.java
index 052a96c..5e02098 100644 (file)
@@ -24,46 +24,72 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Properties;
 
 import javax.validation.constraints.NotEmpty;
 
 import lombok.Getter;
 
 import org.oransc.policyagent.exceptions.ServiceException;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import reactor.core.publisher.Flux;
 
 @EnableConfigurationProperties
-@ConfigurationProperties("app")
+@ConfigurationProperties()
 public class ApplicationConfig {
     @NotEmpty
-    private String filepath;
+    @Getter
+    @Value("${app.filepath}")
+    private String localConfigurationFilePath;
+
+    @Value("${server.ssl.key-store-type}")
+    private String sslKeyStoreType = "";
+
+    @Value("${server.ssl.key-store-password}")
+    private String sslKeyStorePassword = "";
+
+    @Value("${server.ssl.key-store}")
+    private String sslKeyStore = "";
+
+    @Value("${server.ssl.key-password}")
+    private String sslKeyPassword = "";
+
+    @Value("${app.webclient.trust-store-used}")
+    private boolean sslTrustStoreUsed = false;
+
+    @Value("${app.webclient.trust-store-password}")
+    private String sslTrustStorePassword = "";
+
+    @Value("${app.webclient.trust-store}")
+    private String sslTrustStore = "";
 
     private Map<String, RicConfig> ricConfigs = new HashMap<>();
+
     @Getter
-    private Properties dmaapPublisherConfig;
+    private String dmaapConsumerTopicUrl;
+
     @Getter
-    private Properties dmaapConsumerConfig;
+    private String dmaapProducerTopicUrl;
 
     private Map<String, ControllerConfig> controllerConfigs = new HashMap<>();
 
-    public String getLocalConfigurationFilePath() {
-        return this.filepath;
-    }
-
-    /*
-     * Do not remove, used by framework!
-     */
-    public synchronized void setFilepath(String filepath) {
-        this.filepath = filepath;
-    }
-
     public synchronized Collection<RicConfig> getRicConfigs() {
         return this.ricConfigs.values();
     }
 
+    public WebClientConfig getWebClientConfig() {
+        return ImmutableWebClientConfig.builder() //
+            .keyStoreType(this.sslKeyStoreType) //
+            .keyStorePassword(this.sslKeyStorePassword) //
+            .keyStore(this.sslKeyStore) //
+            .keyPassword(this.sslKeyPassword) //
+            .isTrustStoreUsed(this.sslTrustStoreUsed) //
+            .trustStore(this.sslTrustStore) //
+            .trustStorePassword(this.sslTrustStorePassword) //
+            .build();
+    }
+
     public synchronized ControllerConfig getControllerConfig(String name) throws ServiceException {
         ControllerConfig controllerConfig = this.controllerConfigs.get(name);
         if (controllerConfig == null) {
@@ -100,10 +126,11 @@ public class ApplicationConfig {
         ApplicationConfigParser.ConfigParserResult parserResult) {
 
         Collection<RicConfigUpdate> modifications = new ArrayList<>();
-        this.dmaapPublisherConfig = parserResult.dmaapPublisherConfig();
-        this.dmaapConsumerConfig = parserResult.dmaapConsumerConfig();
         this.controllerConfigs = parserResult.controllerConfigs();
 
+        this.dmaapConsumerTopicUrl = parserResult.dmaapConsumerTopicUrl();
+        this.dmaapProducerTopicUrl = parserResult.dmaapProducerTopicUrl();
+
         Map<String, RicConfig> newRicConfigs = new HashMap<>();
         for (RicConfig newConfig : parserResult.ricConfigs()) {
             RicConfig oldConfig = this.ricConfigs.get(newConfig.name());