From c7d44853b881daadccc6c05cddcbb89743f1bffc Mon Sep 17 00:00:00 2001 From: vasraz Date: Tue, 6 Sep 2022 13:08:14 +0100 Subject: Update SDC with new 'security-util-lib' version Signed-off-by: Vasyl Razinkov Change-Id: Iece4430f2ebceb8bfb1ea1a89c541335e2f35b11 Issue-ID: SDC-4165 --- .../distribution/engine/DmaapClientFactory.java | 4 ++-- .../org/openecomp/sdc/be/filters/ThreadLocalUtils.java | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'catalog-be/src/main/java/org/openecomp') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapClientFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapClientFactory.java index 0f4836ea1c..6549b54d4e 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapClientFactory.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapClientFactory.java @@ -70,7 +70,7 @@ public class DmaapClientFactory { private Properties buildProperties(DmaapConsumerConfiguration parameters) throws GeneralSecurityException, IOException { Properties props = new Properties(); - Either passkey = SecurityUtil.INSTANCE.decrypt(parameters.getCredential().getPassword()); + Either passkey = SecurityUtil.decrypt(parameters.getCredential().getPassword()); if (passkey.isRight()) { throw new GeneralSecurityException("invalid password, cannot build properties"); } @@ -119,7 +119,7 @@ public class DmaapClientFactory { private Properties buildProducerProperties(DmaapProducerConfiguration parameters) throws GeneralSecurityException, IOException { logger.info("The DmaapProducerConfiguration is {} ", parameters); Properties props = new Properties(); - Either passkey = SecurityUtil.INSTANCE.decrypt(parameters.getCredential().getPassword()); + Either passkey = SecurityUtil.decrypt(parameters.getCredential().getPassword()); if (passkey.isRight()) { throw new GeneralSecurityException("invalid password, cannot build properties"); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/filters/ThreadLocalUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/filters/ThreadLocalUtils.java index 1cd84d02a7..42b0291c89 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/filters/ThreadLocalUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/filters/ThreadLocalUtils.java @@ -21,6 +21,8 @@ package org.openecomp.sdc.be.filters; import java.util.Arrays; import java.util.HashSet; +import java.util.List; +import java.util.Optional; import java.util.Set; import javax.servlet.http.HttpServletRequest; import org.onap.sdc.security.AuthenticationCookie; @@ -52,18 +54,19 @@ public class ThreadLocalUtils implements IUsersThreadLocalHolder { } protected void setUserContext(HttpServletRequest httpRequest) { - String user_id = httpRequest.getHeader(Constants.USER_ID_HEADER); - if (user_id != null) { - String userRolesFromPortal = null; + final String userId = httpRequest.getHeader(Constants.USER_ID_HEADER); + if (userId != null) { Set roles = null; try { - userRolesFromPortal = portalClient.fetchUserRolesFromPortal(user_id); - roles = new HashSet<>(Arrays.asList(userRolesFromPortal)); + final Optional userRolesFromPortalOptional = portalClient.fetchUserRolesFromPortal(userId); + if (userRolesFromPortalOptional.isPresent()){ + roles = new HashSet<>(List.of(userRolesFromPortalOptional.get())); + } } catch (RestrictionAccessFilterException e) { - log.debug("Failed to fetch user ID - {} from portal", user_id); + log.debug("Failed to fetch user ID - {} from portal", userId); log.debug(e.getMessage()); } - UserContext userContext = new UserContext(user_id, roles, null, null); + final UserContext userContext = new UserContext(userId, roles, null, null); ThreadLocalsHolder.setUserContext(userContext); } else { log.debug("user_id value in req header is null, userContext will not be initialized"); -- cgit 1.2.3-korg