summaryrefslogtreecommitdiffstats
path: root/so-cnf-adapter-application
diff options
context:
space:
mode:
authorGrzegorz Wielgosinski <g.wielgosins@samsung.com>2021-08-31 12:47:00 +0200
committerGrzegorz Wielgosinski <g.wielgosins@samsung.com>2021-09-01 13:10:24 +0200
commit35448f02967790cf1487ba2898dfaea1e0d7da54 (patch)
tree76ab178875c40cd99572d2028d1921f0fda13b14 /so-cnf-adapter-application
parent29c1e826c4f02259fd7843fdd1fed16538cacc44 (diff)
Add basic auth for connection with so-bpmn-infra
Issue-ID: SO-3747 Signed-off-by: Grzegorz Wielgosinski <g.wielgosins@samsung.com> Change-Id: I30fb38c6cb229ddedeb379bebf417793e372639c
Diffstat (limited to 'so-cnf-adapter-application')
-rw-r--r--so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/BpmnInfraConfiguration.java15
-rw-r--r--so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/SoCallbackClient.java9
-rw-r--r--so-cnf-adapter-application/src/main/resources/application.yaml4
3 files changed, 26 insertions, 2 deletions
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
index 0000000..a06ad92
--- /dev/null
+++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/BpmnInfraConfiguration.java
@@ -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;
+ }
+}
diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/SoCallbackClient.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/SoCallbackClient.java
index f6e39e8..9372983 100644
--- a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/SoCallbackClient.java
+++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/client/SoCallbackClient.java
@@ -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);
}
diff --git a/so-cnf-adapter-application/src/main/resources/application.yaml b/so-cnf-adapter-application/src/main/resources/application.yaml
index c9b786d..dc277e5 100644
--- a/so-cnf-adapter-application/src/main/resources/application.yaml
+++ b/so-cnf-adapter-application/src/main/resources/application.yaml
@@ -61,4 +61,8 @@ multicloud:
# security:
# enabled: false
# basic:
+mso:
+ adapters:
+ requestDb:
+ auth:
# enabled: false \ No newline at end of file