Add basic auth for connection with so-bpmn-infra 17/123717/5
authorGrzegorz Wielgosinski <g.wielgosins@samsung.com>
Tue, 31 Aug 2021 10:47:00 +0000 (12:47 +0200)
committerGrzegorz Wielgosinski <g.wielgosins@samsung.com>
Wed, 1 Sep 2021 11:10:24 +0000 (13:10 +0200)
Issue-ID: SO-3747

Signed-off-by: Grzegorz Wielgosinski <g.wielgosins@samsung.com>
Change-Id: I30fb38c6cb229ddedeb379bebf417793e372639c

so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/BpmnInfraConfiguration.java [new file with mode: 0644]
so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/SoCallbackClient.java
so-cnf-adapter-application/src/main/resources/application.yaml

diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/BpmnInfraConfiguration.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/BpmnInfraConfiguration.java
new file mode 100644 (file)
index 0000000..a06ad92
--- /dev/null
@@ -0,0 +1,15 @@
+package org.onap.so.adapters.cnf;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class BpmnInfraConfiguration {
+
+    @Value("${mso.adapters.requestDb.auth}")
+    private String auth;
+
+    public String getAuth() {
+        return auth;
+    }
+}
index f6e39e8..9372983 100644 (file)
@@ -1,6 +1,7 @@
 package org.onap.so.adapters.cnf.client;
 
 import com.google.gson.Gson;
+import org.onap.so.adapters.cnf.BpmnInfraConfiguration;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
@@ -17,12 +18,15 @@ import static org.springframework.http.HttpMethod.POST;
 @Component
 public class SoCallbackClient {
 
-    private final RestTemplate restTemplate;
     private final static Gson gson = new Gson();
 
+    private final RestTemplate restTemplate;
+    private final BpmnInfraConfiguration bpmnInfraConfiguration;
+
     @Autowired
-    public SoCallbackClient(RestTemplate restTemplate) {
+    public SoCallbackClient(RestTemplate restTemplate, BpmnInfraConfiguration bpmnInfraConfiguration) {
         this.restTemplate = restTemplate;
+        this.bpmnInfraConfiguration = bpmnInfraConfiguration;
     }
 
     public ResponseEntity<String> sendPostCallback(String url, Object body) {
@@ -35,6 +39,7 @@ public class SoCallbackClient {
         acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
         headers.setAccept(acceptableMediaTypes);
         headers.setContentType(MediaType.APPLICATION_JSON);
+        headers.add(HttpHeaders.AUTHORIZATION, bpmnInfraConfiguration.getAuth());
 
         return new HttpEntity<>(gson.toJson(body), headers);
     }
index c9b786d..dc277e5 100644 (file)
@@ -61,4 +61,8 @@ multicloud:
 #  security:
  #   enabled: false
  #   basic:
+mso:
+  adapters:
+    requestDb:
+      auth:
 #      enabled: false
\ No newline at end of file