summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-19 17:48:46 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-19 17:49:04 -0500
commit52b79b57892d03dfe92b6423c77b8f51f0a1ca8d (patch)
treedefa73faea84b65e08527f7c26d5bef652109f1e /mso-api-handlers
parentfb37bbac02e3e404e61fbae88c17d91a8172d874 (diff)
Added the conversion of decrypted value
Added jUnit test for the conversion of decrypted value to Basic Base64Binary. Added the conversion of decrypted value as Basic Base64Binary. Change-Id: I361cbe3dac61df2728c9f58c314a21b3cc764a9f Issue-ID: SO-1531 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java12
2 files changed, 16 insertions, 3 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 312db9a338..e3b218b90a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -110,6 +110,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
+import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.URL;
import java.security.GeneralSecurityException;
@@ -1178,7 +1179,7 @@ public class ServiceInstances {
String requestId = duplicateRecord.getRequestId();
String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
String targetUrl = env.getProperty("mso.camundaURL") + path;
- HttpHeaders headers = setHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
+ HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
try{
@@ -1202,7 +1203,7 @@ public class ServiceInstances {
}
return false;
}
- private HttpHeaders setHeaders(String auth, String msoKey) {
+ protected HttpHeaders setCamundaHeaders(String auth, String msoKey) {
HttpHeaders headers = new HttpHeaders();
List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
@@ -1210,7 +1211,7 @@ public class ServiceInstances {
try {
String userCredentials = CryptoUtils.decrypt(auth, msoKey);
if(userCredentials != null) {
- headers.add(HttpHeaders.AUTHORIZATION, userCredentials);
+ headers.add(HttpHeaders.AUTHORIZATION, "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
}
} catch(GeneralSecurityException e) {
msoLogger.error("Security exception", e);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 5603ee8380..83b5a49e8c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -2620,4 +2620,16 @@ public class ServiceInstancesTest extends BaseTest{
String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
assertEquals(serviceType, "networkModelName");
}
+ @Test
+ public void setCamundaHeadersTest()throws ContactCamundaException, RequestDbFailureException{
+ String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
+ String key = "07a7159d3bf51a0e53be7a8f89699be7";
+ HttpHeaders headers = servInstances.setCamundaHeaders(encryptedAuth, key);
+ List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
+ String expectedAcceptedType = "application/json";
+ assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
+ String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
+ String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
+ assertEquals(expectedBasicAuth, basicAuth);
+ }
}