summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java2
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java10
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIDSLQueryClient.java3
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java3
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryQueryClient.java4
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java4
-rw-r--r--common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java15
8 files changed, 42 insertions, 11 deletions
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
index 65c7d093a9..59884f25b8 100644
--- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
+++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
@@ -6,6 +6,7 @@
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Modifications Copyright (C) 2018 IBM.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,6 +91,7 @@ public class SDNCRestClient{
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
+ Thread.currentThread().interrupt();
}
String action = bpelRequest.getRequestHeader().getSvcAction();
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
index 076a9f3c6a..01fa3db960 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -30,6 +32,7 @@ import org.junit.Test;
import org.onap.so.adapters.sdnc.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.junit.Assert.assertTrue;
public class SDNCRestClientTest extends BaseTest {
@@ -51,4 +54,11 @@ public class SDNCRestClientTest extends BaseTest {
SDNCResponse response = sdncClient.getSdncResp("", rt);
assertNotNull(response);
}
+
+ @Test
+ public void executeRequestInterrupted() {
+ Thread.currentThread().interrupt();
+ sdncClient.executeRequest(null);
+ assertTrue(Thread.interrupted());
+ }
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIDSLQueryClient.java b/common/src/main/java/org/onap/so/client/aai/AAIDSLQueryClient.java
index e9b58b469d..4cee4f3df7 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIDSLQueryClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIDSLQueryClient.java
@@ -22,9 +22,10 @@ package org.onap.so.client.aai;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.GraphInventoryQueryClient;
+import org.onap.so.client.graphinventory.entities.DSLQuery;
import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
-public class AAIDSLQueryClient extends GraphInventoryQueryClient<AAIDSLQueryClient> {
+public class AAIDSLQueryClient extends GraphInventoryQueryClient<AAIDSLQueryClient, DSLQuery> {
public AAIDSLQueryClient() {
super(new AAIClient());
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java b/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java
index c3523e94c2..66d5d1f5cb 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java
@@ -20,11 +20,12 @@
package org.onap.so.client.aai;
+import org.onap.so.client.aai.entities.CustomQuery;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.GraphInventoryQueryClient;
import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
-public class AAIQueryClient extends GraphInventoryQueryClient<AAIQueryClient> {
+public class AAIQueryClient extends GraphInventoryQueryClient<AAIQueryClient, CustomQuery> {
public AAIQueryClient() {
super(new AAIClient());
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryQueryClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryQueryClient.java
index aa4842fe2a..c4bf0f0beb 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryQueryClient.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryQueryClient.java
@@ -25,7 +25,7 @@ import java.util.Optional;
import org.onap.so.client.aai.entities.CustomQuery;
import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
-public abstract class GraphInventoryQueryClient<S> {
+public abstract class GraphInventoryQueryClient<S, I> {
private Optional<String> depth = Optional.empty();
private boolean nodesOnly = false;
@@ -38,7 +38,7 @@ public abstract class GraphInventoryQueryClient<S> {
protected abstract GraphInventoryUri getQueryUri();
- public String query(Format format, CustomQuery query) {
+ public String query(Format format, I query) {
return client.createClient(setupQueryParams(getQueryUri().queryParam("format", format.toString()))).put(query, String.class);
}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
index cc1ce0063b..2f71358f04 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -59,7 +61,7 @@ public class GraphInventoryResultWrapper implements Serializable {
try {
return mapper.writeValueAsString(aaiObject);
} catch (JsonProcessingException e) {
- logger.warn("could not parse object into json - defaulting to {}");
+ logger.warn("could not parse object into json - defaulting to empty object");
return "{}";
}
}
diff --git a/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java b/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java
index 5433681b83..88a83db7e2 100644
--- a/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java
+++ b/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -59,6 +61,10 @@ public class EqualsAndHashCodeTester implements Tester {
this.onlyDeclaredMethods = true;
return this;
}
+
+ // Marks sonar warnings about object being compared to itself as false positive
+ // https://sonar.onap.org/coding_rules#rule_key=squid%3AS1764
+ @SuppressWarnings("squid:S1764")
@Override
public void run(PojoClass pojoClass) {
Class<?> clazz = pojoClass.getClazz();
@@ -104,9 +110,9 @@ public class EqualsAndHashCodeTester implements Tester {
Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals(classInstanceTwo));
- Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals(
- classInstanceOne));
-
+ Affirm.affirmTrue("Expected true for comparison of the same references [" + classInstanceOne.getClass().getName() + "]",
+ classInstanceOne.equals(classInstanceOne));
+
Affirm.affirmTrue("HashCode test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.hashCode() == classInstanceTwo.hashCode());
Affirm.affirmFalse("Expected false for comparison of two unlike objects", classInstanceOne.equals("test"));
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 66b04b6fdb..312db9a338 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
@@ -81,6 +81,7 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
import org.onap.so.serviceinstancebeans.VfModules;
import org.onap.so.serviceinstancebeans.Vnfs;
+import org.onap.so.utils.CryptoUtils;
import org.onap.so.utils.UUIDChecker;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
@@ -111,6 +112,7 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.net.URL;
+import java.security.GeneralSecurityException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
@@ -1176,7 +1178,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.getProperty("mso.camundaAuth"));
+ HttpHeaders headers = setHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
try{
@@ -1200,12 +1202,19 @@ public class ServiceInstances {
}
return false;
}
- private HttpHeaders setHeaders(String auth) {
+ private HttpHeaders setHeaders(String auth, String msoKey) {
HttpHeaders headers = new HttpHeaders();
List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
headers.setAccept(acceptableMediaTypes);
- headers.add(HttpHeaders.AUTHORIZATION, auth);
+ try {
+ String userCredentials = CryptoUtils.decrypt(auth, msoKey);
+ if(userCredentials != null) {
+ headers.add(HttpHeaders.AUTHORIZATION, userCredentials);
+ }
+ } catch(GeneralSecurityException e) {
+ msoLogger.error("Security exception", e);
+ }
return headers;
}