summaryrefslogtreecommitdiffstats
path: root/CdtProxyService/src/main
diff options
context:
space:
mode:
authorPatrick Brady <patrick.brady@att.com>2020-03-26 16:14:17 -0700
committerPatrick Brady <patrick.brady@att.com>2020-03-26 16:14:53 -0700
commitaa60945d2903ff60c4cdeebae76fbf569c91e444 (patch)
tree3569bf253b35703194e97ebb888caf152d3e39e0 /CdtProxyService/src/main
parent0141df20b1f533cd2acabdf7ea986aebab8d6868 (diff)
Revert "Authentication support for cdt"
There appear to be problems with some fields saving in cdt caused by this change. This reverts commit 0141df20b1f533cd2acabdf7ea986aebab8d6868. Change-Id: Iee40058de9870afdac608db7851fcfc206102822 Signed-off-by: Patrick Brady <patrick.brady@att.com> Issue-ID: APPC-1854
Diffstat (limited to 'CdtProxyService/src/main')
-rw-r--r--CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java36
-rw-r--r--CdtProxyService/src/main/resources/application.properties2
2 files changed, 20 insertions, 18 deletions
diff --git a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java
index bdb12e5..78a94f6 100644
--- a/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java
+++ b/CdtProxyService/src/main/java/org/onap/appc/cdt/service/controller/CdtController.java
@@ -1,7 +1,7 @@
/*
============LICENSE_START==========================================
===================================================================
-Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
===================================================================
Unless otherwise specified, all software contained herein is licensed
@@ -41,7 +41,6 @@ import org.springframework.web.client.RestTemplate;
import java.net.UnknownHostException;
import java.util.Base64;
-import java.util.List;
/**
* Created by Amaresh Kumar on 09/May/2018.
@@ -63,6 +62,11 @@ public class CdtController {
@Value("${restConf.backend.port}")
private String restConfPort;
+ @Value("${restConf.username}")
+ private String restConfUsername;
+
+ @Value("${restConf.password}")
+ private String restConfPassword;
@ApiOperation(value = "Return All Test Data for a given user", response = CdtController.class)
@ApiResponses(value = {
@@ -83,8 +87,8 @@ public class CdtController {
})
@RequestMapping(value = "/getDesigns", method = RequestMethod.POST)
@CrossOrigin(origins = "*", allowedHeaders = "*")
- public String getDesigns(@RequestBody String getDesignsRequest, @RequestHeader HttpHeaders requestHeader) throws UnknownHostException {
- HttpEntity<String> entity = getStringHttpEntity(getDesignsRequest, requestHeader);
+ public String getDesigns(@RequestBody String getDesignsRequest) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(getDesignsRequest);
HttpClient httpClient = HttpClientBuilder.create().build();
ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
restTemplate.setRequestFactory(factory);
@@ -99,8 +103,8 @@ public class CdtController {
})
@RequestMapping(value = "/testVnf", method = RequestMethod.POST)
@CrossOrigin(origins = "*", allowedHeaders = "*")
- public String testVnf(@RequestParam String urlAction, @RequestBody String testVnf, @RequestHeader HttpHeaders requestHeader) throws UnknownHostException {
- HttpEntity<String> entity = getStringHttpEntity(testVnf, requestHeader);
+ public String testVnf(@RequestParam String urlAction, @RequestBody String testVnf) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(testVnf);
String testVnfResponse = restTemplate.postForObject(getUrl("testVnf")+urlAction, entity, String.class);
return testVnfResponse;
}
@@ -112,8 +116,8 @@ public class CdtController {
})
@RequestMapping(value = "/checkTestStatus", method = RequestMethod.POST)
@CrossOrigin(origins = "*", allowedHeaders = "*")
- public String checkTestStatus(@RequestBody String checkTestStatusRequest, @RequestHeader HttpHeaders requestHeader) throws UnknownHostException {
- HttpEntity<String> entity = getStringHttpEntity(checkTestStatusRequest, requestHeader);
+ public String checkTestStatus(@RequestBody String checkTestStatusRequest) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(checkTestStatusRequest);
String checkTestStatusResponse = restTemplate.postForObject(getUrl("checkTestStatus"), entity, String.class);
return checkTestStatusResponse;
}
@@ -125,23 +129,19 @@ public class CdtController {
})
@RequestMapping(value = "/validateTemplate", method = RequestMethod.POST)
@CrossOrigin(origins = "*", allowedHeaders = "*")
- public String validateTemplate(@RequestBody String validateTemplateRequest, @RequestHeader HttpHeaders requestHeader) throws UnknownHostException {
- HttpEntity<String> entity = getStringHttpEntity(validateTemplateRequest, requestHeader);
+ public String validateTemplate(@RequestBody String validateTemplateRequest) throws UnknownHostException {
+ HttpEntity<String> entity = getStringHttpEntity(validateTemplateRequest);
String validateTemplateResponse = restTemplate.postForObject(getUrl("validateTemplate"), entity, String.class);
return validateTemplateResponse;
}
- private HttpEntity<String> getStringHttpEntity(@RequestBody String getDesignsRequest, @RequestHeader HttpHeaders requestHeader) {
-
+ private HttpEntity<String> getStringHttpEntity(@RequestBody String getDesignsRequest) {
HttpHeaders headers = new HttpHeaders();
- if(requestHeader.containsKey("authorization")) {
- List<String> headerAuthValue = requestHeader.get("authorization");
- if(headerAuthValue != null && headerAuthValue.size() > 0) {
- headers.set("authorization", headerAuthValue.get(0));
- }
- }
headers.setAccessControlAllowCredentials(true);
headers.setContentType(MediaType.APPLICATION_JSON);
+ String planCredentials = restConfUsername + ":" + restConfPassword;
+ String base64Credentails = Base64.getEncoder().encodeToString(planCredentials.getBytes());
+ headers.set("Authorization", "Basic " + base64Credentails);
return new HttpEntity<String>(getDesignsRequest, headers);
}
diff --git a/CdtProxyService/src/main/resources/application.properties b/CdtProxyService/src/main/resources/application.properties
index 3b21458..d33188a 100644
--- a/CdtProxyService/src/main/resources/application.properties
+++ b/CdtProxyService/src/main/resources/application.properties
@@ -13,6 +13,8 @@ Djavax.net.debug=ssl;
#=========RestConf Backend properties START==================
restConf.backend.hostname=localhost
restConf.backend.port=8181
+restConf.username=admin
+restConf.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
#=========RestConf Backend properties END==================
#====Allowed origins======================