summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler
diff options
context:
space:
mode:
authorst782s <statta@research.att.com>2018-01-30 17:29:36 -0500
committerst782s <statta@research.att.com>2018-02-01 15:10:02 -0500
commit21a8761f684745bb300e075c7e98ad897ace9eed (patch)
tree6d585c3fe39fbb42a314941dbc8646e6ccf188cf /ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler
parent3af8af1310d5a27cb58be29505573f0bbdc1717c (diff)
Security/ Package Name changes
Issue-ID: PORTAL-174, PORTAL-157, PORTAL-156, PORTAL-148, PORTAL-145, PORTAL-140, PORTAL-133, PORTAL-121, PORTAL-111, PORTAL-88 Includes security fixes, Role Centralization, replace certain ECOMP occurrences etc Change-Id: I3c8b706709c6b92e646e3cbe50c2d660e8a46ef4 Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler')
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java136
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java86
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java125
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java110
4 files changed, 0 insertions, 457 deletions
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java
deleted file mode 100644
index 8fd70a2b..00000000
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/FunctionalMenuHandler.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal
- * ===================================================================
- * 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============================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.openecomp.portalapp.uebhandler;
-
-import java.util.List;
-
-import org.openecomp.portalapp.portal.domain.EPUser;
-import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
-import org.openecomp.portalapp.portal.service.AdminRolesService;
-import org.openecomp.portalapp.portal.service.FunctionalMenuService;
-import org.openecomp.portalapp.portal.service.SearchService;
-import org.openecomp.portalapp.portal.transport.FunctionalMenuItem;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebException;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
-import org.openecomp.portalsdk.core.service.DataAccessService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Component;
-
-import com.google.gson.Gson;
-
-@Component
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-@EPAuditLog
-public class FunctionalMenuHandler {
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FunctionalMenuHandler.class);
-
- @Autowired
- private AdminRolesService adminRolesService;
-
- @Autowired
- private FunctionalMenuService functionalMenuService;
-
- @Autowired
- private SearchService searchSvc;
-
- @Async
- public Boolean getFunctionalMenu(UebMsg requestMsg) {
- UebMsg returnMsg = new UebMsg();
-
- if (requestMsg == null) {
- logger.error(EELFLoggerDelegate.errorLogger, "handleMenuRequest received null message");
- return false;
- } else if (requestMsg.getSourceTopicName() == null) {
- logger.error(EELFLoggerDelegate.errorLogger,
- "A source topic name is required and not found in this msg:" + requestMsg.toString());
- return false;
- } else if (requestMsg.getUserId() == null) {
- logger.debug(EELFLoggerDelegate.debugLogger,
- "Error getting functional menu. A userId is required and not found in this msg: "
- + requestMsg.toString());
- returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response
- returnMsg.putPayload("Error: A userId is required. Call msg.putUserId() with an userId");
- } else {
- logger.debug(EELFLoggerDelegate.debugLogger,
- "Getting functional menu for user = " + requestMsg.getUserId());
- EPUser user = searchSvc.searchUserByUserId(requestMsg.getUserId());
-
- List<FunctionalMenuItem> menuItems = null;
- if (user == null) {
- logger.debug(EELFLoggerDelegate.debugLogger,
- "Error getting functional menu. userId not found in directory or is guest: "
- + requestMsg.toString());
- } else if (adminRolesService.isSuperAdmin(user)) {
- logger.debug(EELFLoggerDelegate.debugLogger,
- "FunctionalMenuHandler: SuperUser, about to call getFunctionalMenuItems()");
- menuItems = functionalMenuService.getFunctionalMenuItems();
- } else {
- logger.debug(EELFLoggerDelegate.debugLogger,
- "getMenuItemsForAuthUser: about to call getFunctionalMenuItemsForUser()");
- menuItems = functionalMenuService.getFunctionalMenuItemsForUser(requestMsg.getUserId());
- }
-
- if (menuItems != null) {
- String functionalMenuJsonString = new Gson().toJson(menuItems);
- logger.debug(EELFLoggerDelegate.debugLogger, "returning functional menu : " + functionalMenuJsonString);
- returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response
- returnMsg.putPayload(functionalMenuJsonString);
- } else {
- returnMsg.putMsgId(requestMsg.getMsgId()); // echo tells requester this is a response
- returnMsg.putPayload("Error: Not found for userId = " + requestMsg.getUserId());
- }
- }
-
- try {
- UebManager.getInstance().publishReplyEP(returnMsg, requestMsg.getSourceTopicName());
- } catch (UebException e) {
- logger.error(EELFLoggerDelegate.errorLogger,
- "getFunctionalMenu failed to publish reply", e);
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,
- "getFunctionalMenu failed", e);
- }
-
- return true;
- }
-}
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java
deleted file mode 100644
index db60c89f..00000000
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/InitUebHandler.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal
- * ===================================================================
- * 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============================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.openecomp.portalapp.uebhandler;
-
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
-
-//
-// Adding this class for the sole purpose of insuring that the MainUebHandler really
-// honors @Async and kicks off a thread. For more info google @Async and read about
-// @Async only working if called from different class.
-//
-//@Configuration
-//@EnableAspectJAutoProxy
-//@EPMetricsLog
-public class InitUebHandler {
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(InitUebHandler.class);
-
- // @Autowired
- private MainUebHandler mainUebHandler;
-
- public InitUebHandler() {
-
- }
-
- // @PostConstruct
- public void initUeb() {
- try {
- String enableListenerThread = PortalApiProperties.getProperty(PortalApiConstants.UEB_LISTENERS_ENABLE);
- if (enableListenerThread.equalsIgnoreCase("true")) {
- ConcurrentLinkedQueue<UebMsg> inboxQueue = new ConcurrentLinkedQueue<UebMsg>();
- UebManager.getInstance().initListener(inboxQueue);
- mainUebHandler.runHandler(inboxQueue);
- logger.info(EELFLoggerDelegate.errorLogger, "Returned from initiating mainUebHandler...");
- } else {
- logger.info(EELFLoggerDelegate.errorLogger,
- "Not starting UEB listening thread because ueb_listeners_enable is not set to true in the properties file.");
- }
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "initUeb failed", e);
- logger.info(EELFLoggerDelegate.errorLogger,
- "Not starting UEB listening thread because property could not be read "
- + PortalApiConstants.UEB_LISTENERS_ENABLE + e.getMessage());
- }
- }
-}
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java
deleted file mode 100644
index 9e2bfff7..00000000
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/MainUebHandler.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal
- * ===================================================================
- * 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============================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.openecomp.portalapp.uebhandler;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import org.openecomp.portalapp.portal.ueb.EPUebMsgTypes;
-import org.openecomp.portalapp.portal.utils.EPSystemProperties;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebMsgTypes;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Component;
-
-import com.att.eelf.configuration.Configuration;
-
-//-------------------------------------------------------------------------
-// Listens for received UEB messages and handles the messages
-//
-// Note: To implement a synchronous reply call getMsgId on the request
-// and putMsgId on the reply (echoing the request MsgId).
-//
-//-------------------------------------------------------------------------
-@Component("MainUebHandler")
-public class MainUebHandler {
- final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MainUebHandler.class);
-
- private ConcurrentLinkedQueue<UebMsg> inboxQueue = null;
-
- @Autowired
- private FunctionalMenuHandler funcMenuHandler;
-
- @Autowired
- private WidgetNotificationHandler widgetNotificationHandler;
-
- @Async
- public void runHandler(ConcurrentLinkedQueue<UebMsg> queue) {
- inboxQueue = queue;
- logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "==> MainUebHandler started");
- while (true) {
- UebMsg msg = null;
- while ((msg = inboxQueue.poll()) != null) {
- if ((msg.getMsgType() != null)
- && (!msg.getMsgType().equalsIgnoreCase(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK))) {
- // TODO: switch this back to debug
- logger.info(EELFLoggerDelegate.errorLogger,
- dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString());
- logger.info(EELFLoggerDelegate.debugLogger,
- dateFormat.format(new Date()) + "<== Received UEB message : " + msg.toString());
- MDC.put(EPSystemProperties.PARTNER_NAME, msg.getSourceTopicName());
- MDC.put(Configuration.MDC_SERVICE_NAME, msg.getMsgType().toString());
- switch (msg.getMsgType()) {
- case UebMsgTypes.UEB_MSG_TYPE_GET_FUNC_MENU: {
- funcMenuHandler.getFunctionalMenu(msg);
- break;
- }
- case UebMsgTypes.UEB_MSG_TYPE_WIDGET_NOTIFICATION: {
- widgetNotificationHandler.handleWidgetNotification(msg);
- break;
- }
- default: {
- logger.info(EELFLoggerDelegate.debugLogger,
- dateFormat.format(new Date()) + "Unknown UEB message type " + msg.toString());
- break;
- }
- }
- }
- }
-
- if (Thread.interrupted()) {
- logger.info(EELFLoggerDelegate.errorLogger, "==> UebMainHandler exiting");
- break;
- }
-
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "runHandler interrupted during sleep", e);
- } catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "runHandler failed", e);
- }
- }
- }
-}
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java
deleted file mode 100644
index 1f964437..00000000
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/uebhandler/WidgetNotificationHandler.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal
- * ===================================================================
- * 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============================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.openecomp.portalapp.uebhandler;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-import org.openecomp.portalapp.portal.domain.EPApp;
-import org.openecomp.portalapp.portal.domain.EPUser;
-import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
-import org.openecomp.portalapp.portal.service.EPAppService;
-import org.openecomp.portalapp.portal.service.SearchService;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebException;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebMsg;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Component;
-
-@Component
-@org.springframework.context.annotation.Configuration
-@EnableAspectJAutoProxy
-@EPMetricsLog
-public class WidgetNotificationHandler {
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetNotificationHandler.class);
-
- final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- @Autowired
- EPAppService appSvc;
-
- @Autowired
- SearchService searchSvc;
-
- public WidgetNotificationHandler() {
- }
-
- @Async
- public void handleWidgetNotification(UebMsg requestMsg) {
- if (requestMsg.getUserId() != null) {
- logger.debug(EELFLoggerDelegate.debugLogger,
- "handleWidgetNotification: getting widgets/apps for user = " + requestMsg.getUserId());
- EPUser user = searchSvc.searchUserByUserId(requestMsg.getUserId());
- if (user != null && (appSvc != null)) {
- logger.debug(EELFLoggerDelegate.debugLogger, "Debug mytag: " + appSvc);
- List<EPApp> apps = appSvc.getUserApps(user);
- for (EPApp app : apps) {
- if (app.getUebTopicName() != null) {
- UebMsg widgetMsg = new UebMsg();
- widgetMsg.putSourceTopicName(app.getUebTopicName());
- logger.debug(EELFLoggerDelegate.debugLogger, "app.getUebTopicName was invoked");
- widgetMsg.putPayload(requestMsg.getPayload());
- try {
- logger.debug(EELFLoggerDelegate.debugLogger, "Sending widget notification from "
- + requestMsg.getSourceTopicName() + " to " + app.getUebTopicName());
- UebManager.getInstance().publishEP(widgetMsg, app.getUebTopicName());
- } catch (UebException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "handleWidgetNotification failed", e);
- }
- }
- }
- } else {
- logger.error(EELFLoggerDelegate.errorLogger,
- dateFormat.format(new Date()) + "handleWidgetNotification: user " + requestMsg.getUserId()
- + " not found" + " source = " + requestMsg.getSourceTopicName()
- + ". This widget notification cannot be posted to other widgets");
- }
- }
- }
-
-}