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 +- catalog-be/src/main/resources/key.properties | 41 +++++++++ catalog-be/src/main/resources/portal.properties | 97 +++++++++++++++++----- .../src/main/resources/portal.properties.old | 25 ++++++ catalog-be/src/main/webapp/WEB-INF/web.xml | 2 +- .../openecomp/sdc/be/ecomp/EcompIntImplTest.java | 10 +-- .../ecomp/converters/EcompRoleConverterTest.java | 2 +- .../ecomp/converters/EcompUserConverterTest.java | 6 +- 10 files changed, 183 insertions(+), 46 deletions(-) create mode 100644 catalog-be/src/main/resources/key.properties create mode 100644 catalog-be/src/main/resources/portal.properties.old (limited to 'catalog-be/src') 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; diff --git a/catalog-be/src/main/resources/key.properties b/catalog-be/src/main/resources/key.properties new file mode 100644 index 0000000000..0315075e53 --- /dev/null +++ b/catalog-be/src/main/resources/key.properties @@ -0,0 +1,41 @@ +### +# ============LICENSE_START========================================== +# ONAP Portal SDK +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# +### + +# Properties read by the ECOMP Framework library (epsdk-fw) + +cipher.enc.key = AGLDdG4D04BKm2IxIWEr8o== \ No newline at end of file diff --git a/catalog-be/src/main/resources/portal.properties b/catalog-be/src/main/resources/portal.properties index c67261f962..fbedd05028 100644 --- a/catalog-be/src/main/resources/portal.properties +++ b/catalog-be/src/main/resources/portal.properties @@ -1,25 +1,76 @@ -# Portal REST URL, ends "/auxapi" -ecomp_rest_url = https://ecomp.homer.att.com/ecompportal/auxapi - -# Java implementation of interface +### +# ============LICENSE_START========================================== +# ONAP Portal SDK +# =================================================================== +# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the “License”); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ +# +# +### +# Properties read by ECOMP Framework library, ecompFW.jar + +########################################################################## +# The following properties should NOT be changed by partner applications. +########################################################################## + +portal.api.prefix = /api +max.idle.time = 5 +user.attribute.name = user_attribute + +#Use REST API instead of UEB to fetch the functional menu data +use_rest_for_functional_menu=true + +########################################################################## +# The following properties MUST be changed by partner applications. +########################################################################## + +# Name of java class that implements the OnBoardingApiService interface. portal.api.impl.class = org.openecomp.sdc.be.ecomp.EcompIntImpl -# CSP-SSO URL -ecomp_redirect_url = https://www.e-access.att.com/ecomp_portal_ist/ecompportal/process_csp -# Cookie set by CSP-SSO -csp_cookie_name = attESSec -# CSP setting, most use PROD; DEV also recognized -csp_gate_keeper_prod_key = PROD - -# Comma-separated list of UEB server names -ueb_url_list = uebsb91kcdc.it.att.com,uebsb92kcdc.it.att.com,uebsb93kcdc.it.att.com -# UEB topic where Portal listens -ecomp_portal_inbox_name = ECOMP-PORTAL-INBOX-TEST -# UEB key generated while on-boarding -ueb_app_key = app_key_here -# UEB secret generated while on-boarding -ueb_app_secret = app_secret_here -# UEB topic where App listens -ueb_app_mailbox_name = app_topic_name_here -# Consumer group name; most Apps should use {UUID} -ueb_app_consumer_group_name = {UUID} \ No newline at end of file +# URL of the Portal where this app is onboarded +ecomp_redirect_url = http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm + +# URL of the ECOMP Portal REST API +ecomp_rest_url = http://portal.api.simpledemo.onap.org:8989/ecompportal/auxapi + +# Applications do not need to run a UEB listener after 1607. +ueb_listeners_enable = false + +#Portal user & key +portal_user = Ipwxi2oLvDxctMA1royaRw1W0jhucLx+grHzci3ePIA= +portal_pass = j85yNhyIs7zKYbR1VlwEfNhS6b7Om4l0Gx5O8931sCI= + +# UEB Configuration +# If key ueb_listeners_enable is set to false, +# then only the ueb_app_key is required. +ueb_app_key = REPLACE-ME-UEB-APP-KEY-EPSDK-APP-OS + + diff --git a/catalog-be/src/main/resources/portal.properties.old b/catalog-be/src/main/resources/portal.properties.old new file mode 100644 index 0000000000..df59ba392d --- /dev/null +++ b/catalog-be/src/main/resources/portal.properties.old @@ -0,0 +1,25 @@ +# Portal REST URL, ends "/auxapi" +ecomp_rest_url = https://ecomp.homer.att.com/ecompportal/auxapi + +# Java implementation of interface +portal.api.impl.class = org.openecomp.sdc.be.ecomp.EcompIntImpl + +# CSP-SSO URL +ecomp_redirect_url = https://www.e-access.att.com/ecomp_portal_ist/ecompportal/process_csp +# Cookie set by CSP-SSO +csp_cookie_name = attESSec +# CSP setting, most use PROD; DEV also recognized +csp_gate_keeper_prod_key = PROD + +# Comma-separated list of UEB server names +ueb_url_list = uebsb91kcdc.it.att.com,uebsb92kcdc.it.att.com,uebsb93kcdc.it.att.com +# UEB topic where Portal listens +ecomp_portal_inbox_name = ECOMP-PORTAL-INBOX-TEST +# UEB key generated while on-boarding +ueb_app_key = app_key_here +# UEB secret generated while on-boarding +ueb_app_secret = app_secret_here +# UEB topic where App listens +ueb_app_mailbox_name = app_topic_name_here +# Consumer group name; most Apps should use {UUID} +ueb_app_consumer_group_name = {UUID} \ No newline at end of file diff --git a/catalog-be/src/main/webapp/WEB-INF/web.xml b/catalog-be/src/main/webapp/WEB-INF/web.xml index 74092fe9cb..93c5194c0c 100644 --- a/catalog-be/src/main/webapp/WEB-INF/web.xml +++ b/catalog-be/src/main/webapp/WEB-INF/web.xml @@ -151,7 +151,7 @@ ECOMPServlet - org.openecomp.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy + org.onap.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy 3 true diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java index e4e13d6477..fd5bbdb74a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java @@ -2,9 +2,9 @@ package org.openecomp.sdc.be.ecomp; import org.junit.Test; import org.mockito.Mockito; -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.exception.PortalAPIException; +import org.onap.portalsdk.core.restful.domain.EcompRole; +import org.onap.portalsdk.core.restful.domain.EcompUser; import javax.servlet.http.HttpServletRequest; import java.util.List; @@ -64,10 +64,10 @@ public class EcompIntImplTest { // default test testSubject = createTestSubject(); - result = testSubject.getAvailableRoles(); + result = testSubject.getAvailableRoles("Mock"); } - @Test(expected=PortalAPIException.class) + @Test(expected= PortalAPIException.class) public void testGetUserRoles() throws Exception { EcompIntImpl testSubject; String loginId = ""; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java index 528b9b6b69..53d8d5f7c6 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java @@ -1,7 +1,7 @@ package org.openecomp.sdc.be.ecomp.converters; import org.junit.Test; -import org.openecomp.portalsdk.core.restful.domain.EcompRole; +import org.onap.portalsdk.core.restful.domain.EcompRole; import org.openecomp.sdc.be.user.Role; public class EcompRoleConverterTest { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java index 91cf1417dd..301de32f6f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java @@ -1,13 +1,11 @@ package org.openecomp.sdc.be.ecomp.converters; -import fj.data.Either; import fj.data.Either; import org.junit.Test; -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.model.User; - import java.util.Collections; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -- cgit 1.2.3-korg