From 7d05e16f0ab24ba8918bd4466d50a9fb77571552 Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Wed, 10 Oct 2018 14:52:54 +0300 Subject: update sdc portal integration Change-Id: I6e17434f753c2eaa562da80c1eade8688601f510 Issue-ID: SDC-1749 Signed-off-by: Tal Gitelman --- .../org/openecomp/sdc/be/ecomp/EcompIntImpl.java | 39 +++++++++++++++++----- .../be/ecomp/converters/EcompRoleConverter.java | 2 +- .../be/ecomp/converters/EcompUserConverter.java | 5 +-- 3 files changed, 34 insertions(+), 12 deletions(-) (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java index 757c3a48d4..50d48d4ca7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java @@ -21,10 +21,16 @@ package org.openecomp.sdc.be.ecomp; import fj.data.Either; -import org.openecomp.portalsdk.core.onboarding.crossapi.IPortalRestAPIService; -import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException; -import org.openecomp.portalsdk.core.restful.domain.EcompRole; -import org.openecomp.portalsdk.core.restful.domain.EcompUser; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestAPIService; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; +import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; +import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; +import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; +import org.onap.portalsdk.core.restful.domain.EcompRole; +import org.onap.portalsdk.core.restful.domain.EcompUser; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -40,8 +46,10 @@ import org.springframework.context.ApplicationContext; import org.springframework.web.context.ContextLoader; import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; public class EcompIntImpl implements IPortalRestAPIService { @@ -265,7 +273,7 @@ public class EcompIntImpl implements IPortalRestAPIService { } @Override - public List getAvailableRoles() throws PortalAPIException { + public List getAvailableRoles(String requestedLoginId) throws PortalAPIException { log.debug("Start handle request of ECOMP getAvailableRoles"); try { List ecompRolesList = new LinkedList<>(); @@ -372,14 +380,21 @@ public class EcompIntImpl implements IPortalRestAPIService { @Override public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException { - // TODO Validation should be changed completely + final String portal_key = PortalApiProperties.getProperty("portal_pass"); + final String portal_user = PortalApiProperties.getProperty("portal_user"); final String USERNAME = request.getHeader("username"); final String PASSWORD = request.getHeader("password"); if (USERNAME != null && PASSWORD != null) { - if (!USERNAME.equals("") && !PASSWORD.equals("")) { - log.debug("User authenticated - Username: ,Password: {}", USERNAME, PASSWORD); - return true; + try { + if (CipherUtil.decryptPKC(USERNAME).equals(CipherUtil.decryptPKC(portal_user)) && + CipherUtil.decryptPKC(PASSWORD).equals(CipherUtil.decryptPKC(portal_key))) { + log.debug("User authenticated - Username: {}", USERNAME); + return true; + } + } catch (CipherUtilException e) { + log.debug("User authentication failed - Decryption failed", e); + return false; } } @@ -415,4 +430,10 @@ public class EcompIntImpl implements IPortalRestAPIService { public String getUserId(HttpServletRequest request) throws PortalAPIException { return request.getHeader(Constants.USER_ID_HEADER); } + + //TODO for what the following method stands for + @Override + public Map getCredentials() throws PortalAPIException { + return null; + } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java index aebc9170f1..df20351fd8 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java @@ -20,7 +20,7 @@ package org.openecomp.sdc.be.ecomp.converters; -import org.openecomp.portalsdk.core.restful.domain.EcompRole; +import org.onap.portalsdk.core.restful.domain.EcompRole; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.common.log.wrappers.Logger; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java index 0297abeacb..61b29a3986 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java @@ -21,8 +21,9 @@ package org.openecomp.sdc.be.ecomp.converters; import fj.data.Either; -import org.openecomp.portalsdk.core.restful.domain.EcompRole; -import org.openecomp.portalsdk.core.restful.domain.EcompUser; + +import org.onap.portalsdk.core.restful.domain.EcompRole; +import org.onap.portalsdk.core.restful.domain.EcompUser; import org.openecomp.sdc.be.dao.utils.UserStatusEnum; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.user.Role; -- cgit 1.2.3-korg