From a0b9152f19c4f8dbd925635129d75af9785a1d4a Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Mon, 31 Jul 2017 18:20:49 -0400 Subject: Repair widget micro service, onboarding of widgets Issue: PORTAL-30, PORTAL-40, PORTAL-45, PORTAL-46, PORTAL-47 Change-Id: I97de4cc038f7167d5e368249f9ea5e47e8fc1b09 Signed-off-by: Christopher Lott (cl778h) --- .../portalapp/portal/controller/CommonWidgetController.java | 6 ++++-- .../portalapp/portal/service/MicroserviceProxyServiceImpl.java | 2 ++ .../portalapp/portal/service/MicroserviceServiceImpl.java | 8 +++++++- .../portalapp/portal/service/UserRolesCommonServiceImpl.java | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) (limited to 'ecomp-portal-BE-common') diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/CommonWidgetController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/CommonWidgetController.java index 68e32a16..7faea5d9 100644 --- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/CommonWidgetController.java +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/CommonWidgetController.java @@ -20,6 +20,8 @@ package org.openecomp.portalapp.portal.controller; import javax.servlet.http.HttpServletRequest; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; import org.openecomp.portalapp.portal.controller.DashboardController.WidgetCategory; import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; @@ -33,7 +35,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController -public class CommonWidgetController implements BasicAuthenticationController{ +public class CommonWidgetController extends EPRestrictedBaseController implements BasicAuthenticationController{ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CommonWidgetController.class); @@ -63,7 +65,7 @@ public class CommonWidgetController implements BasicAuthenticationController{ * Request parameter. * @return Rest response wrapped around a CommonWidgetMeta object. */ - @RequestMapping(value = "/widgetData", method = RequestMethod.GET, produces = "application/json") + @RequestMapping(value = "/commonWidgets", method = RequestMethod.GET, produces = "application/json") public PortalRestResponse getWidgetData(HttpServletRequest request, @RequestParam String resourceType) { if (!isValidResourceType(resourceType)){ diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java index 6b9a4416..ff8ee424 100644 --- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java @@ -108,6 +108,8 @@ public class MicroserviceProxyServiceImpl implements MicroserviceProxyService { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Basic " + base64Creds); headers.setContentType(MediaType.APPLICATION_JSON); + String rawCookie = request.getHeader("Cookie"); + headers.add("Cookie", rawCookie); HttpEntity entity = new HttpEntity(headers); String url = microserviceUrlConverter(data, params); diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceServiceImpl.java index aaadfa18..520bef98 100644 --- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceServiceImpl.java @@ -24,6 +24,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.crypto.BadPaddingException; + import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; import org.openecomp.portalapp.portal.domain.MicroserviceData; @@ -82,7 +84,11 @@ public class MicroserviceServiceImpl implements MicroserviceService { List list = (List) dataAccessService.getList(MicroserviceData.class, null); for (int i = 0; i < list.size(); i++) { if (list.get(i).getPassword() != null) - list.get(i).setPassword(decryptedPassword(list.get(i).getPassword())); + try{ + list.get(i).setPassword(decryptedPassword(list.get(i).getPassword())); + } catch(BadPaddingException bpe){ + logger.error(EELFLoggerDelegate.errorLogger, "Couldn't decrypt - Check decryption key in system.properties - looks wrong. Still going ahead with list population though", bpe); + } list.get(i).setParameterList(getServiceParameters(list.get(i).getId())); } return list; diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java index 80408954..58809210 100644 --- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java @@ -1242,7 +1242,7 @@ public class UserRolesCommonServiceImpl { protected EPUser getUser(String userId, EPApp app, ApplicationsRestClientService applicationsRestClientService) throws HTTPException { - return applicationsRestClientService.get(EPUser.class, app.getId(), String.format("/user/%s", userId), true); + return applicationsRestClientService.get(EPUser.class, app.getId(), String.format("/user/%s", userId)); } -- cgit 1.2.3-korg