diff options
author | st782s <statta@research.att.com> | 2018-01-30 17:29:36 -0500 |
---|---|---|
committer | st782s <statta@research.att.com> | 2018-02-01 15:10:02 -0500 |
commit | 21a8761f684745bb300e075c7e98ad897ace9eed (patch) | |
tree | 6d585c3fe39fbb42a314941dbc8646e6ccf188cf /ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp | |
parent | 3af8af1310d5a27cb58be29505573f0bbdc1717c (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')
43 files changed, 0 insertions, 5498 deletions
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.java deleted file mode 100644 index 6cdcb6ba..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/LoginStrategy.java +++ /dev/null @@ -1,45 +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.authentication; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public interface LoginStrategy { - public boolean login(HttpServletRequest request, HttpServletResponse response) throws Exception; -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.java deleted file mode 100644 index 02cd340a..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/OpenIdConnectLoginStrategy.java +++ /dev/null @@ -1,123 +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.authentication; - -import java.util.HashSet; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.mitre.openid.connect.model.UserInfo; -import org.openecomp.portalapp.command.EPLoginBean; -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalapp.util.SessionCookieUtil; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.util.StringUtils; -import org.springframework.web.servlet.ModelAndView; - -public class OpenIdConnectLoginStrategy extends org.openecomp.portalsdk.core.auth.LoginStrategy implements org.openecomp.portalapp.authentication.LoginStrategy { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(OpenIdConnectLoginStrategy.class); - - private static final String GLOBAL_LOCATION_KEY = "Location"; - - @SuppressWarnings("rawtypes") - public boolean login(HttpServletRequest request, HttpServletResponse response){ - - logger.info("Attempting Login"); - - //check both authentication cookie and authentication header - UserInfo userInfo = (UserInfo) request.getAttribute("userInfo"); - - if (userInfo != null && !StringUtils.isEmpty(userInfo.getPreferredUsername())) { - //package the userid in the login form for processing - EPLoginBean commandBean = new EPLoginBean(); - commandBean.setOrgUserId(userInfo.getPreferredUsername()); - - EPUser user = new EPUser(); - - user.setOrgUserId(userInfo.getPreferredUsername()); - user.setEmail(userInfo.getEmail()); - user.setFirstName(userInfo.getName()); - user.setLastName(userInfo.getFamilyName()); - - //store the currently logged in user's information in the session - EPUserUtils.setUserSession(request, user, new HashSet(), new HashSet(), SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM),null); - - logger.info(EELFLoggerDelegate.errorLogger, request.getContextPath()); - SessionCookieUtil.preSetUp(request, response); - return true; - } else { - // in case authentication cookie is missing, send 401 UNAUTHORIZED to client and it will redirect to Logon - try { - String authentication = SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM); - String loginUrl = SystemProperties.getProperty(EPSystemProperties.LOGIN_URL_NO_RET_VAL); - logger.info(EELFLoggerDelegate.errorLogger, "Authentication Mechanism: '" + authentication + "'."); - - if (authentication == null || authentication.equals("") || authentication.trim().equals("OIDC")) { - response.sendRedirect("oid-login"); - } else { - logger.info(EELFLoggerDelegate.errorLogger, "No cookies are found, redirecting the request to '" + loginUrl + "'."); - response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); - response.setHeader(GLOBAL_LOCATION_KEY, loginUrl); - } - } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "login failed", e); - } - } - return false; - } - - @Override - public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { - String message = "Method not implmented; Cannot be called"; - logger.error(EELFLoggerDelegate.errorLogger, message); - throw new Exception(message); - } - - @Override - public String getUserId(HttpServletRequest request) throws PortalAPIException { - String message = "Method not implmented; Cannot be called"; - logger.error(EELFLoggerDelegate.errorLogger, message); - throw new PortalAPIException(message); - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.java deleted file mode 100644 index b7e16443..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/authentication/SimpleLoginStrategy.java +++ /dev/null @@ -1,131 +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.authentication; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalapp.command.EPLoginBean; -import org.openecomp.portalapp.portal.service.EPLoginService; -import org.openecomp.portalapp.portal.service.EPRoleFunctionService; -import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalapp.util.SessionCookieUtil; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.menu.MenuProperties; -import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.StringUtils; -import org.springframework.web.servlet.ModelAndView; - -public class SimpleLoginStrategy extends org.openecomp.portalsdk.core.auth.LoginStrategy implements LoginStrategy{ - - @Autowired - private EPLoginService loginService; - - @Autowired - private EPRoleFunctionService ePRoleFunctionService; - - private static final String GLOBAL_LOCATION_KEY = "Location"; - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SimpleLoginStrategy.class); - - public boolean login(HttpServletRequest request, HttpServletResponse response) throws Exception{ - logger.info("Attempting 'Simple' Login"); - - //check both authentication cookie and authentication header - String orgUserId = SessionCookieUtil.getUserIdFromCookie(request, response); - - if (!StringUtils.isEmpty(orgUserId)) { - // package the userid in the login form for processing - EPLoginBean commandBean = new EPLoginBean(); - commandBean.setOrgUserId(orgUserId); - commandBean = loginService.findUser(commandBean, (String)request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), null); - - // in case authentication has passed but user is not in the ECOMP data base, return a Guest User to the home page. - if (commandBean.getUser() == null) { - } - else { - // store the currently logged in user's information in the session - EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), commandBean.getBusinessDirectMenu(), "", ePRoleFunctionService); - logger.info(EELFLoggerDelegate.debugLogger, commandBean.getUser().getOrgUserId() + " exists in the the system."); - } - - logger.info(EELFLoggerDelegate.errorLogger, request.getContextPath()); - SessionCookieUtil.preSetUp(request, response); - return true; - } else { - // in case authentication cookie is missing, send 401 UNAUTHORIZED to client and it will redirect to Logon - try { - String authentication = SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM); - String loginUrl = SystemProperties.getProperty(EPSystemProperties.LOGIN_URL_NO_RET_VAL); - logger.info(EELFLoggerDelegate.errorLogger, "Authentication Mechanism: '" + authentication + "'."); - if (authentication == null || authentication.equals("") || authentication.trim().equals("BOTH")) { - - logger.info(EELFLoggerDelegate.errorLogger, "No cookies are found, redirecting the request to '" + loginUrl + "'."); - response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); - response.setHeader(GLOBAL_LOCATION_KEY, loginUrl); //returnUrl + "/index.htm"); - }else { - logger.info(EELFLoggerDelegate.errorLogger, "No cookies are found, redirecting the request to '" + loginUrl + "'."); - response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); - response.setHeader(GLOBAL_LOCATION_KEY, loginUrl); //returnUrl + "/index.htm"); - } - } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "login failed", e); - } - } - - return false; - - } - - @Override - public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { - String message = "Method not implmented; Cannot be called"; - logger.error(EELFLoggerDelegate.errorLogger, message); - throw new Exception(message); - } - - @Override - public String getUserId(HttpServletRequest request) throws PortalAPIException { - String message = "Method not implmented; Cannot be called"; - logger.error(EELFLoggerDelegate.errorLogger, message); - throw new PortalAPIException(message); - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java deleted file mode 100644 index 7b44add9..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java +++ /dev/null @@ -1,335 +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.conf; - -import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY; -import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID; -import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN; -import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS; -import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID; -import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; - -import java.net.InetAddress; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import javax.annotation.PostConstruct; - -import org.openecomp.portalapp.authentication.LoginStrategy; -import org.openecomp.portalapp.authentication.OpenIdConnectLoginStrategy; -import org.openecomp.portalapp.authentication.SimpleLoginStrategy; -import org.openecomp.portalapp.controller.core.LogoutController; -import org.openecomp.portalapp.controller.core.SDKLoginController; -import org.openecomp.portalapp.portal.interceptor.PortalResourceInterceptor; -import org.openecomp.portalapp.portal.interceptor.SessionTimeoutInterceptor; -import org.openecomp.portalapp.portal.listener.HealthMonitor; -import org.openecomp.portalapp.portal.service.EPLoginService; -import org.openecomp.portalapp.portal.service.EPLoginServiceImpl; -import org.openecomp.portalapp.portal.ueb.EPUebHelper; -import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalapp.scheduler.RegistryAdapter; -import org.openecomp.portalapp.uebhandler.FunctionalMenuHandler; -import org.openecomp.portalapp.uebhandler.InitUebHandler; -import org.openecomp.portalapp.uebhandler.MainUebHandler; -import org.openecomp.portalapp.uebhandler.WidgetNotificationHandler; -import org.openecomp.portalsdk.core.conf.AppConfig; -import org.openecomp.portalsdk.core.conf.Configurable; -import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager; -import org.openecomp.portalsdk.core.service.DataAccessService; -import org.openecomp.portalsdk.core.service.FnMenuService; -import org.openecomp.portalsdk.core.service.FnMenuServiceImpl; -import org.openecomp.portalsdk.core.util.CacheManager; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.ComponentScan.Filter; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.FilterType; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; - -@Configuration -@EnableWebMvc -@ComponentScan(basePackages = { "org.openecomp" }, excludeFilters = { - @Filter(value = { LogoutController.class, SDKLoginController.class }, type = FilterType.ASSIGNABLE_TYPE) }) -@Profile("src") -@EnableAsync -@EnableScheduling -public class ExternalAppConfig extends AppConfig implements Configurable { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppConfig.class); - - private RegistryAdapter schedulerRegistryAdapter; - - public ViewResolver viewResolver() { - return super.viewResolver(); - } - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/app/fusion/**").addResourceLocations("/app/fusion/"); - registry.addResourceHandler("/static/**").addResourceLocations("/static/"); - registry.addResourceHandler("/images/**").addResourceLocations("/images/"); - registry.addResourceHandler("/**").addResourceLocations("/public/"); - } - - @PostConstruct - private void init() { - try { - // Loading defaults - MDC.put(MDC_SERVICE_NAME, EPSystemProperties.ECOMP_PORTAL_BE); - MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName()); - MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress()); - MDC.put(MDC_SERVICE_INSTANCE_ID, ""); - MDC.put(MDC_ALERT_SEVERITY, AlarmSeverityEnum.INFORMATIONAL.toString()); - MDC.put(MDC_INSTANCE_UUID, SystemProperties.getProperty(SystemProperties.INSTANCE_UUID)); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "init failed", e); - } - } - - /* - * / - * - * @PostConstruct // file://${catalina.home}/conf/log4j.properties public - * void initLog4j() throws FileNotFoundException { try { URL[] classpathurls - * = ((URLClassLoader) - * (Thread.currentThread().getContextClassLoader())).getURLs(); for (URL url - * : classpathurls) { System.out.println(url.getFile().toString()); } - * Log4jConfigurer.initLogging( - * "file://${catalina.home}/conf/log4j.properties"); } catch - * (FileNotFoundException e) { ((URLClassLoader) - * (Thread.currentThread().getContextClassLoader())).getURLs(); - * Log4jConfigurer.initLogging("classpath:../conf/log4j.properties"); } } / - **/ - - public DataAccessService dataAccessService() { - return super.dataAccessService(); - } - - public String[] tileDefinitions() { - return super.tileDefinitions(); - } - - public List<String> addTileDefinitions() { - List<String> definitions = new ArrayList<String>(); - definitions.add("/WEB-INF/defs/definitions.xml"); - return definitions; - } - - @Bean - public AbstractCacheManager cacheManager() { - return new CacheManager(); - } - - @Bean - public SessionTimeoutInterceptor sessionTimeoutInterceptor() { - return new SessionTimeoutInterceptor(); - } - - @Bean - public PortalResourceInterceptor portalResourceInterceptor() { - return new PortalResourceInterceptor(); - } - - @Bean - public EPLoginService eploginService() { - return new EPLoginServiceImpl(); - } - - @Bean - public org.openecomp.portalsdk.core.auth.LoginStrategy coreLoginStrategy() { - if (SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) - return new OpenIdConnectLoginStrategy(); - else - return new SimpleLoginStrategy(); - } - - @Bean - public LoginStrategy loginStrategy() { - - if (SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) - return new OpenIdConnectLoginStrategy(); - else - return new SimpleLoginStrategy(); - } - - public FnMenuService fnMenuService() { - return new FnMenuServiceImpl(); - } - - @Override - public void addInterceptors(InterceptorRegistry registry) { - // registry.addInterceptor(new - // StaticResourcesInterceptor()).addPathPatterns("/index.htm", - // "/applicationsHome", "/widgetsHome", "/admins", "/users", - // "/applications", "/widgets"); - // Excludes login/logout pages and REST endpoints used by other - // application servers. - - registry.addInterceptor(sessionTimeoutInterceptor()).excludePathPatterns("/oid-login", "/portalApi/healthCheck", - "/portalApi/healthCheck/", "/portalApi/healthCheckSuspend", "/portalApi/healthCheckSuspend/", - "/portalApi/healthCheckResume", "/portalApi/healthCheckResume/", "/login_external", - "/login_external.htm*", "login", "/login.htm*","/auxapi/*","/context/*", "/api*", - "/single_signon.htm", "/single_signon", "/dashboard", "/OpenSourceLogin.htm"); - - registry.addInterceptor(portalResourceInterceptor()); - - } - - /** - * Creates and returns a new instance of a {@link SchedulerFactoryBean} and - * populates it with triggers. - * - * @return New instance of {@link SchedulerFactoryBean} - */ - - @Bean - public EPUebHelper epUebHelper() { - return new EPUebHelper(); - } - - @Bean - public HealthMonitor healthMonitor() { - return new HealthMonitor(); - } - - /** - * Creates and returns a new instance of a {@link MainUebHandler}. - * - * @return New instance of {@link MainUebHandler}. - */ - @Bean - public MainUebHandler mainUebHandler() { - return new MainUebHandler(); - } - - /** - * Creates and returns a new instance of a {@link InitUebHandler}. - * - * @return New instance of {@link InitUebHandler}. - */ - @Bean - public InitUebHandler initUebHandler() { - return new InitUebHandler(); - } - - /** - * Creates and returns a new instance of a {@link WidgetNotificationHandler} - * . - * - * @return New instance of {@link WidgetNotificationHandler}. - */ - @Bean - public WidgetNotificationHandler widgetNotificationHandler() { - return new WidgetNotificationHandler(); - } - - /** - * Creates and returns a new instance of a {@link FunctionalMenuHandler} . - * - * @return New instance of {@link FunctionalMenuHandler}. - */ - @Bean - public FunctionalMenuHandler functionalMenuHandler() { - return new FunctionalMenuHandler(); - } - - /** - * Creates and returns a new instance of a {@link SchedulerFactoryBean} and - * populates it with triggers. - * - * @return New instance of {@link SchedulerFactoryBean} - * @throws Exception if dataSource fails - */ - // APPLICATIONS REQUIRING QUARTZ SHOULD RESTORE ANNOTATION - @Bean // ANNOTATION COMMENTED OUT - public SchedulerFactoryBean schedulerFactoryBean() throws Exception { - SchedulerFactoryBean scheduler = new SchedulerFactoryBean(); - scheduler.setConfigLocation(appApplicationContext.getResource("WEB-INF/conf/quartz.properties")); - scheduler.setDataSource(dataSource()); - scheduler.setTriggers(schedulerRegistryAdapter.getTriggers()); - scheduler.setSchedulerName(getScheduleName()); - return scheduler; - } - - protected String getScheduleName() { - final String CRON_SITE_NAME = "cron_site_name"; - String cronSiteVal = "Default"; - try { - cronSiteVal = SystemProperties.getProperty(CRON_SITE_NAME); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getScheduleName failed", e); - logger.warn(EELFLoggerDelegate.errorLogger, - "Cron site name not added in property file, using Default value"); - } - - String cronSiteName = cronSiteVal != null ? cronSiteVal : ""; - - SimpleDateFormat dateFormat = new SimpleDateFormat(); - dateFormat.applyPattern("YYYYMMdd"); - String currentDateStr = dateFormat.format(Calendar.getInstance().getTime()); - - return "Scheduler" + "_" + currentDateStr + "_" + cronSiteName; - } - - /** - * Sets the scheduler registry adapter. - * - * @param schedulerRegistryAdapter - * Scheduler registry adapter - */ - @Autowired - public void setSchedulerRegistryAdapter(final RegistryAdapter schedulerRegistryAdapter) { - this.schedulerRegistryAdapter = schedulerRegistryAdapter; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.java deleted file mode 100644 index 121c4beb..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/ExternalAppInitializer.java +++ /dev/null @@ -1,78 +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.conf; - -import java.util.Arrays; - -import org.openecomp.portalsdk.core.conf.AppInitializer; - -public class ExternalAppInitializer extends AppInitializer{ - - - @Override - protected Class<?>[] getRootConfigClasses() { - return super.getRootConfigClasses(); - } - - @Override - protected Class<?>[] getServletConfigClasses() { -// Class<?>[] configClasses = super.getServletConfigClasses(); -// Class<?>[] additionalConfigClasses = Arrays.copyOf(configClasses, configClasses.length); -// addConfigClass(additionalConfigClasses, ExternalAppConfig.class); -// return additionalConfigClasses; -// - return new Class[] {ExternalAppConfig.class}; - } - - static Class<?>[] addConfigClass(Class<?>[] a, Class<?> e) { - a = Arrays.copyOf(a, a.length + 1); - a[a.length - 1] = e; - return a; - } - - /* - * URL request will direct to the Spring dispatcher for processing - */ - @Override - protected String[] getServletMappings() { - return super.getServletMappings(); - } - -} - - diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.java deleted file mode 100644 index 7f0e9569..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/conf/HibernateMappingLocations.java +++ /dev/null @@ -1,61 +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.conf; - -import org.openecomp.portalsdk.core.conf.HibernateMappingLocatable; -import org.springframework.context.annotation.Profile; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.stereotype.Component; - -@Component -@Profile("src") -public class HibernateMappingLocations implements HibernateMappingLocatable { - - public Resource[] getMappingLocations() { - return new Resource[] { new ClassPathResource("../fusion/orm/Fusion.hbm.xml"), - new ClassPathResource("../fusion/orm/EP.hbm.xml"), - new ClassPathResource("../fusion/orm/Workflow.hbm.xml") }; - } - - @Override - public String[] getPackagesToScan() { - return new String[] { "org.openecomp" }; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.java deleted file mode 100644 index 10ae7b9d..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ECOMPLogoutController.java +++ /dev/null @@ -1,132 +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.controller; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; -import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; -import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.servlet.ModelAndView; - -@Controller -@RequestMapping("/") -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@Profile("src") -public class ECOMPLogoutController extends EPUnRestrictedBaseController{ - - private EPUser user; - private static final String EP_SERVICE = "EPService"; - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECOMPLogoutController.class); - - @EPAuditLog - @RequestMapping(value = {"/logout.htm" }, method = RequestMethod.GET) - public ModelAndView logOut(HttpServletRequest request, - HttpServletResponse response) throws Exception { - - ModelAndView modelView = null; - - chatRoomLogout(request); - logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Logout request received."); - - modelView = new ModelAndView("redirect:login.htm"); - - /** - if (UserUtils.isClientMobileDevice(request)){ - modelView.setViewName(modelView.getViewName().concat("?viewType=mobile")); - } - */ - String cookieDoamin = EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN); - Cookie epCookie = new Cookie(EP_SERVICE, ""); - epCookie.setMaxAge(0); - epCookie.setDomain(cookieDoamin); - epCookie.setPath("/"); - - Cookie appHeaderCookie = new Cookie("show_app_header", ""); - appHeaderCookie.setMaxAge(0); - appHeaderCookie.setDomain(cookieDoamin); - appHeaderCookie.setPath("/"); - - Cookie appTabCookie = new Cookie("cookieTabs", ""); - appTabCookie.setMaxAge(0); - appTabCookie.setDomain(cookieDoamin); - appTabCookie.setPath("/"); - - Cookie appVisInvisTabCookie = new Cookie("visInVisCookieTabs", ""); - appVisInvisTabCookie.setMaxAge(0); - appVisInvisTabCookie.setDomain(cookieDoamin); - appVisInvisTabCookie.setPath("/"); - - response.addCookie(epCookie); - response.addCookie(appHeaderCookie); - response.addCookie(appTabCookie); - response.addCookie(appVisInvisTabCookie); - request.getSession().invalidate(); - - logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Successfully processed the logout request."); - - return modelView; - } - - @EPMetricsLog - public void chatRoomLogout(HttpServletRequest request){ - request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest(); - setUser(EPUserUtils.getUserSession(request)); - } - - public EPUser getUser() { - return user; - } - - public void setUser(EPUser user) { - this.user = user; - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginController.java deleted file mode 100644 index ce6cc530..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginController.java +++ /dev/null @@ -1,392 +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.controller; - -import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; - -import java.net.URLDecoder; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.json.JSONObject; -import org.openecomp.portalapp.command.EPLoginBean; -import org.openecomp.portalapp.portal.domain.SharedContext; -import org.openecomp.portalapp.portal.service.EPLoginService; -import org.openecomp.portalapp.portal.service.EPRoleFunctionService; -import org.openecomp.portalapp.portal.service.SharedContextService; -import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalapp.util.SessionCookieUtil; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.menu.MenuProperties; -import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.util.StopWatch; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.util.WebUtils; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@RequestMapping("/") -public class LoginController extends EPUnRestrictedBaseController implements LoginService { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LoginController.class); - - public static final String DEFAULT_SUCCESS_VIEW = "applicationsHome"; - public static final String DEFAULT_FAILURE_VIEW = "login"; - public static final String ERROR_MESSAGE_KEY = "error"; - public static final String REDIRECT_URL = "redirectUrl"; - public static final String REDIRECT_COLON = "redirect:"; - - @Autowired - private EPLoginService loginService; - @Autowired - private SharedContextService sharedContextService; - @Autowired - private EPRoleFunctionService ePRoleFunctionService; - - private String viewName = "login"; - - private String welcomeView; - - @RequestMapping(value = { "/login.htm" }, method = RequestMethod.GET) - public ModelAndView login(HttpServletRequest request) { - Map<String, Object> model = new HashMap<String, Object>(); - String authentication = SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM); - String loginPage; - if (authentication == null || "".equals(authentication) || "OICD".equals(authentication.trim())) - loginPage = "openIdLogin"; - else - loginPage = getViewName(); - return new ModelAndView(loginPage, "model", model); - } - - @SuppressWarnings("rawtypes") - @RequestMapping(value = { "/open_source/login" }, method = RequestMethod.POST) - @ResponseBody - public String loginValidate(HttpServletRequest request, HttpServletResponse response) throws Exception { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - JsonNode root = mapper.readTree(request.getReader()); - - EPLoginBean commandBean = new EPLoginBean(); - String loginId = root.get("loginId").textValue(); - String password = root.get("password").textValue(); - commandBean.setLoginId(loginId); - commandBean.setLoginPwd(CipherUtil.encrypt(password)); - HashMap additionalParamsMap = new HashMap(); - StringBuilder sbAdditionalInfo = new StringBuilder(); - - commandBean = getLoginService().findUser(commandBean, - (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), additionalParamsMap); - String fullURL = getFullURL(request); - if (commandBean.getUser() == null) { - String loginErrorMessage = (commandBean.getLoginErrorMessage() != null) ? commandBean.getLoginErrorMessage() - : "login.error.external.invalid"; - logger.info(EELFLoggerDelegate.debugLogger, "loginId {} does not exist in the the DB.", loginId); - sbAdditionalInfo.append(String.format("But the Login-Id: %s doesn't exist in the Database. Request-URL: %s", - loginId, fullURL)); - return loginErrorMessage; - } else { - // store the currently logged in user's information in the session - EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), - commandBean.getBusinessDirectMenu(), - SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM), ePRoleFunctionService); - - try { - logger.info(EELFLoggerDelegate.debugLogger, "loginValidate: store user info into share context begins"); - String sessionId = request.getSession().getId(); - List<SharedContext> existingSC = getSharedContextService().getSharedContexts(sessionId); - if (existingSC == null || existingSC.isEmpty()) { - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_FIRST_NAME, - commandBean.getUser().getFirstName()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_LAST_NAME, - commandBean.getUser().getLastName()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_EMAIL, - commandBean.getUser().getEmail()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_ORG_USERID, - commandBean.getLoginId()); - } - - } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, "loginValidate: failed the shared context adding process ", - e); - } - logger.info(EELFLoggerDelegate.debugLogger, - "loginValidate: PresetUp the EP service cookie and intial sessionManagement"); - - SessionCookieUtil.preSetUp(request, response); - SessionCookieUtil.setUpUserIdCookie(request, response, loginId); - - JSONObject j = new JSONObject("{success: success}"); - - return j.toString(); - } - } - - /* - * Work around a bug in ecompsdkos version 1.1.0 which hard-codes this endpoint. - */ - @RequestMapping(value = { "/process_csp" }, method = RequestMethod.GET) - public ModelAndView processCsp(HttpServletRequest request, HttpServletResponse response) throws Exception { - return processSingleSignOn(request, response); - } - /* - * Remove this method after epsdk-app-common/.../SingleSignOnController.java is - * repaired. - */ - - @RequestMapping(value = { "/processSingleSignOn" }, method = RequestMethod.GET) - public ModelAndView processSingleSignOn(HttpServletRequest request, HttpServletResponse response) throws Exception { - - Map<Object, Object> model = new HashMap<Object, Object>(); - HashMap<Object, Object> additionalParamsMap = new HashMap<Object, Object>(); - EPLoginBean commandBean = new EPLoginBean(); - MDC.put(MDC_KEY_REQUEST_ID, getRequestId(request)); - // get userId from cookie - String orgUserId = SessionCookieUtil.getUserIdFromCookie(request, response); - logger.info(EELFLoggerDelegate.debugLogger, "processSingleSignOn: begins with orgUserId {}", orgUserId); - - StringBuilder sbAdditionalInfo = new StringBuilder(); - if (orgUserId == null || orgUserId.length() == 0) { - model.put(ERROR_MESSAGE_KEY, SystemProperties.MESSAGE_KEY_LOGIN_ERROR_COOKIE_EMPTY); - if (request.getParameter(REDIRECT_URL) != null && request.getParameter(REDIRECT_URL).length() != 0) { - return new ModelAndView(REDIRECT_COLON + DEFAULT_FAILURE_VIEW + ".htm" + "?redirectUrl=" - + request.getParameter(REDIRECT_URL)); - } else { - return new ModelAndView(REDIRECT_COLON + DEFAULT_FAILURE_VIEW + ".htm"); - } - } else { - - StopWatch stopWatch = new StopWatch("LoginController.Login"); - stopWatch.start(); - - try { - logger.info(EELFLoggerDelegate.debugLogger, - "Operation findUser is started to locate user {} in the database.", orgUserId); - commandBean.setLoginId(orgUserId); - commandBean.setOrgUserId(orgUserId); - commandBean = getLoginService().findUser(commandBean, - (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), - additionalParamsMap); - - stopWatch.stop(); - MDC.put(EPSystemProperties.MDC_TIMER, stopWatch.getTotalTimeMillis() + "ms"); - logger.info(EELFLoggerDelegate.debugLogger, "Operation findUser is completed."); - } catch (Exception e) { - stopWatch.stop(); - MDC.put(EPSystemProperties.MDC_TIMER, stopWatch.getTotalTimeMillis() + "ms"); - logger.info(EELFLoggerDelegate.errorLogger, "processSingleSignOn failed on user " + orgUserId, e); - } finally { - MDC.remove(EPSystemProperties.MDC_TIMER); - } - - sbAdditionalInfo.append("Login attempt is succeeded. "); - String fullURL = getFullURL(request); - if (commandBean.getUser() == null) { - logger.info(EELFLoggerDelegate.debugLogger, - "processSingleSignOn: loginId {} does not exist in the the DB.", orgUserId); - - sbAdditionalInfo.append(String.format( - "But the Login-Id: %s doesn't exist in the Database. Created a Guest Session. Request-URL: %s", - orgUserId, fullURL)); - if (request.getParameter(REDIRECT_URL) != null && request.getParameter(REDIRECT_URL).length() != 0) { - return new ModelAndView(REDIRECT_COLON + DEFAULT_FAILURE_VIEW + ".htm" + "?redirectUrl=" - + request.getParameter(REDIRECT_URL)); - } else { - return new ModelAndView(REDIRECT_COLON + DEFAULT_FAILURE_VIEW + ".htm"); - } - } else { - - sbAdditionalInfo.append( - String.format("Login-Id: %s, Login-Method: %s, Request-URL: %s", orgUserId, "", fullURL)); - logger.info(EELFLoggerDelegate.debugLogger, "processSingleSignOn: now set up user session for {}", - orgUserId); - - EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), - commandBean.getBusinessDirectMenu(), - SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM), ePRoleFunctionService); - logger.info(EELFLoggerDelegate.debugLogger, - "processSingleSignOn: now set up user session for {} finished", orgUserId); - - // Store user's information into share context - try { - logger.info(EELFLoggerDelegate.debugLogger, - "processSingleSignOn: store user info into share context begins"); - String sessionId = request.getSession().getId(); - List<SharedContext> existingSC = getSharedContextService().getSharedContexts(sessionId); - if (existingSC == null || existingSC.isEmpty()) { - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_FIRST_NAME, - commandBean.getUser().getFirstName()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_LAST_NAME, - commandBean.getUser().getLastName()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_EMAIL, - commandBean.getUser().getEmail()); - getSharedContextService().addSharedContext(sessionId, EPSystemProperties.USER_ORG_USERID, - commandBean.getLoginId()); - } - } catch (Exception e) { - logger.info(EELFLoggerDelegate.errorLogger, - "processSingleSignOn: failed the shared context adding process", e); - } - - logger.info(EELFLoggerDelegate.debugLogger, - "processSingleSignOn: PresetUp the EP service cookie and intial sessionManagement"); - SessionCookieUtil.preSetUp(request, response); - SessionCookieUtil.setUpUserIdCookie(request, response, orgUserId); - logger.info(EELFLoggerDelegate.debugLogger, - "processSingleSignOn: PresetUp the EP service cookie and intial sessionManagement completed"); - logger.info(EELFLoggerDelegate.debugLogger, - commandBean.getUser().getOrgUserId() + " exists in the the system."); - - // get redirectUrl from URL parameter - if (request.getParameter(REDIRECT_URL) != null && request.getParameter(REDIRECT_URL).length() != 0) { - String forwardUrl = URLDecoder.decode(request.getParameter(REDIRECT_URL), "UTF-8"); - // clean cookie - Cookie cookie2 = new Cookie(REDIRECT_URL, ""); - // ONAP does not use https - cookie2.setSecure(false); - cookie2.setMaxAge(0); - cookie2.setDomain(EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN)); - cookie2.setPath("/"); - response.addCookie(cookie2); - return new ModelAndView(REDIRECT_COLON + forwardUrl); - } - - // first check if redirectUrl exists or not - if (WebUtils.getCookie(request, REDIRECT_URL) != null) { - String forwardUrl = WebUtils.getCookie(request, REDIRECT_URL).getValue(); - // clean cookie - Cookie cookie2 = new Cookie(REDIRECT_URL, ""); - // ONAP does not use https - cookie2.setSecure(false); - cookie2.setMaxAge(0); - cookie2.setDomain(EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN)); - cookie2.setPath("/"); - response.addCookie(cookie2); - - return new ModelAndView(REDIRECT_COLON + forwardUrl); - } - } - } - - // if user has been authenticated, now take them to the welcome page. - logger.info(EELFLoggerDelegate.debugLogger, "processSingleSignOn: Now return to application home page"); - return new ModelAndView(REDIRECT_COLON + SystemProperties.getProperty(EPSystemProperties.FE_URL)); - } - - private String getFullURL(HttpServletRequest request) { - if (request != null) { - String requestURL = request.getRequestURL().toString(); - String queryString = request.getQueryString(); - if (queryString == null) { - return requestURL; - } else { - return requestURL + "?" + queryString; - } - } - return ""; - } - - private String getRequestId(HttpServletRequest request) { - Enumeration<String> headerNames = request.getHeaderNames(); - String requestId = ""; - while (headerNames.hasMoreElements()) { - String headerName = headerNames.nextElement(); - logger.debug(EELFLoggerDelegate.debugLogger, "getRequestId: header {} has value {}", headerName, - request.getHeader(headerName)); - if (headerName.equalsIgnoreCase(SystemProperties.ECOMP_REQUEST_ID)) { - requestId = request.getHeader(headerName); - break; - } - } - return requestId.isEmpty() ? UUID.randomUUID().toString() : requestId; - } - - public String getWelcomeView() { - return welcomeView; - } - - public void setWelcomeView(String welcomeView) { - this.welcomeView = welcomeView; - } - - @Override - public String getViewName() { - return viewName; - } - - @Override - public void setViewName(String viewName) { - this.viewName = viewName; - } - - public EPLoginService getLoginService() { - return loginService; - } - - public void setLoginService(EPLoginService loginService) { - this.loginService = loginService; - } - - public SharedContextService getSharedContextService() { - return sharedContextService; - } - - public void setSharedContextService(SharedContextService sharedContextService) { - this.sharedContextService = sharedContextService; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginService.java deleted file mode 100644 index 4b5a8d96..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/LoginService.java +++ /dev/null @@ -1,54 +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.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.ModelAndView; - -public interface LoginService { - - public ModelAndView login(HttpServletRequest request); - - public @ResponseBody String loginValidate(HttpServletRequest request, HttpServletResponse response) throws Exception; - - public ModelAndView processSingleSignOn(HttpServletRequest request, HttpServletResponse response) throws Exception; - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPLoginController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPLoginController.java deleted file mode 100644 index 64f38c18..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPLoginController.java +++ /dev/null @@ -1,99 +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.controller; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalsdk.core.auth.LoginStrategy; -import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController; -import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler; -import org.openecomp.portalsdk.core.service.LoginService; -import org.openecomp.portalsdk.core.service.ProfileService; -import org.openecomp.portalsdk.core.web.support.AppUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -@Controller -@RequestMapping("/") -public class ONAPLoginController extends UnRestrictedBaseController { - @Autowired - ProfileService service; - @Autowired - private LoginService loginService; - @Autowired - private LoginStrategy loginStrategy; - String viewName; - - @RequestMapping(value = { "/doLogin" }, method = RequestMethod.GET) - public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { - return loginStrategy.doLogin(request, response); - } - - public String getJessionId(HttpServletRequest request) { - return request.getSession().getId(); - } - - protected void initateSessionMgtHandler(HttpServletRequest request) { - String jSessionId = getJessionId(request); - PortalTimeoutHandler.sessionCreated(jSessionId, jSessionId, AppUtils.getSession(request)); - } - - public String getViewName() { - return viewName; - } - - public void setViewName(String viewName) { - this.viewName = viewName; - } - - public LoginService getLoginService() { - return loginService; - } - - public void setLoginService(LoginService loginService) { - this.loginService = loginService; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java deleted file mode 100644 index 917d7713..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java +++ /dev/null @@ -1,102 +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.controller; - -import java.security.Principal; -import java.util.Set; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority; -import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.servlet.ModelAndView; - -@Controller -@RequestMapping("/") -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPAuditLog -public class ONAPWelcomeController extends EPRestrictedBaseController{ - String viewName; - - @RequestMapping(value = "/index.htm", method = RequestMethod.GET) - public String getIndexPage(HttpServletRequest request) { - return "/index"; - } - - @RequestMapping(value = {"/applicationsHome", "/dashboard", "/widgetsHome", "/kpidash*", "/admins", "/users", "/portalAdmins", "/applications", "/widgets", "/functionalMenu", "/contactUs", "/getAccess","/appCatalog", "/widgetOnboarding", "/accountOnboarding"}, method = RequestMethod.GET) - public String getEcompSinglePage(HttpServletRequest request, HttpServletResponse response) { - return "forward:/index.html"; - } - - protected String getViewName() { - return viewName; - } - - protected void setViewName(String viewName) { - this.viewName = viewName; - } - - - @Resource(name = "namedAdmins") - private Set<SubjectIssuerGrantedAuthority> admins; - - @RequestMapping("/user") - public String user(Principal p) { - return "oid-user"; - } - - @RequestMapping("/admin") - public String admin(Model model, Principal p) { - - model.addAttribute("admins", admins); - - return "oid-admin"; - } - @RequestMapping("/oid-login") - public ModelAndView login(Principal p) { - return new ModelAndView("openIdLogin"); - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.java deleted file mode 100644 index 9e87ae2e..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/OpenCollaborationController.java +++ /dev/null @@ -1,41 +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.controller; - -import java.util.HashMap; -import java.util.Map; diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.java deleted file mode 100644 index 9366b1e7..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/PeerBroadcastSocket.java +++ /dev/null @@ -1,124 +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.controller; - -import java.io.IOException; -import java.util.Hashtable; -import java.util.Map; - -import javax.websocket.OnClose; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import javax.websocket.server.ServerEndpoint; - -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import com.fasterxml.jackson.databind.ObjectMapper; - -@ServerEndpoint("/opencontact") -public class PeerBroadcastSocket { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerBroadcastSocket.class); - - public static Map<String, Object> channelMap = new Hashtable<String, Object>(); - public Map<String, String> sessionMap = new Hashtable<String, String>(); - ObjectMapper mapper = new ObjectMapper(); - - @OnMessage - public void message(String message, Session session) { - try { - // JSONObject jsonObject = new JSONObject(message); - @SuppressWarnings("unchecked") - Map<String, Object> jsonObject = mapper.readValue(message, Map.class); - try { - Object from = jsonObject.get("from"); - if (from != null) { - if(channelMap.get(from.toString()) == null) { - channelMap.put(from.toString(), session); - sessionMap.put(session.getId(), from.toString()); - } - } - } catch (Exception je) { - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read value" + je.getMessage()); - } - - try { - Object to = jsonObject.get("to"); - if (to == null) - return; - Object toSessionObj = channelMap.get(to); - if (toSessionObj != null) { - Session toSession = null; - toSession = (Session) toSessionObj; - toSession.getBasicRemote().sendText(message); - } - - } catch (Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "Failed to send text" + ex.getMessage()); - } - - } catch (Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "Failed" + ex.getMessage()); - } - - } - - @OnOpen - public void open(Session session) { - logger.info(EELFLoggerDelegate.debugLogger, "Channel opened"); - } - - @OnClose - public void close(Session session) { - String channel = sessionMap.get(session.getId()); - if (channel != null) { - Object sessObj = channelMap.get(channel); - if (sessObj != null) { - try { - ((Session) sessObj).close(); - } catch (IOException e) { - logger.error(EELFLoggerDelegate.errorLogger, "Failed to close" + e.getMessage()); - } - } - channelMap.remove(channel); - } - logger.info(EELFLoggerDelegate.debugLogger, "Channel closed"); - } - -} - diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/AppsOSController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/AppsOSController.java deleted file mode 100644 index 5cffe8cd..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/AppsOSController.java +++ /dev/null @@ -1,134 +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.portal.controller; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.json.JSONObject; -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; -import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; -import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; -import org.openecomp.portalapp.portal.service.AdminRolesService; -import org.openecomp.portalapp.portal.service.EPAppService; -import org.openecomp.portalapp.portal.service.PersUserAppService; -import org.openecomp.portalapp.portal.service.UserService; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPAuditLog -public class AppsOSController extends AppsController { - - static final String FAILURE = "failure"; - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsOSController.class); - - @Autowired - AdminRolesService adminRolesService; - @Autowired - EPAppService appService; - @Autowired - PersUserAppService persUserAppService; - @Autowired - UserService userService; - - - - /** - * Create new application's contact us details. - * - * @param contactUs - * @return - */ - @RequestMapping(value = "/portalApi/saveNewUser", method = RequestMethod.POST, produces = "application/json") - public PortalRestResponse<String> saveNewUser(HttpServletRequest request,@RequestBody EPUser newUser) { - EPUser user = EPUserUtils.getUserSession(request); - if (newUser == null) - return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, FAILURE, - "New User cannot be null or empty"); - - if (!(adminRolesService.isSuperAdmin(user) || adminRolesService.isAccountAdmin(user))){ - if(!user.getLoginId().equalsIgnoreCase(newUser.getLoginId())) - return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, FAILURE, - "UnAuthorized"); - } - - String checkDuplicate = request.getParameter("isCheck"); - String saveNewUser = FAILURE; - try { - saveNewUser = userService.saveNewUser(newUser,checkDuplicate); - } catch (Exception e) { - return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, saveNewUser, e.getMessage()); - } - return new PortalRestResponse<String>(PortalRestStatusEnum.OK, saveNewUser, ""); - } - - @RequestMapping(value = { "/portalApi/currentUserProfile/{loginId}" }, method = RequestMethod.GET, produces = "application/json") - public String getCurrentUserProfile(HttpServletRequest request, @PathVariable("loginId") String loginId) { - - Map<String,String> map = new HashMap<String,String>(); - EPUser user = null; - try { - user = (EPUser) userService.getUserByUserId(loginId).get(0); - map.put("firstName", user.getFirstName()); - map.put("lastName", user.getLastName()); - map.put("email", user.getEmail()); - map.put("loginId", user.getLoginId()); - map.put("loginPwd",user.getLoginPwd()); - map.put("middleInitial",user.getMiddleInitial()); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "Failed to get user info", e); - } - - JSONObject j = new JSONObject(map);; - return j.toString(); - } - -}
\ No newline at end of file diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java deleted file mode 100644 index 313ae683..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/DashboardSearchResultController.java +++ /dev/null @@ -1,261 +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.portal.controller; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalapp.controller.EPRestrictedBaseController; -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse; -import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum; -import org.openecomp.portalapp.portal.ecomp.model.SearchResultItem; -import org.openecomp.portalapp.portal.service.DashboardSearchService; -import org.openecomp.portalapp.portal.transport.CommonWidget; -import org.openecomp.portalapp.portal.transport.CommonWidgetMeta; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalsdk.core.domain.support.CollaborateList; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/portalApi/search") -public class DashboardSearchResultController extends EPRestrictedBaseController { - - private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardSearchResultController.class); - - @Autowired - private DashboardSearchService searchService; - - /** - * Gets all widgets by type: NEW or RESOURCE - * - * @param request - * @param resourceType - * Request parameter. - * @return Rest response wrapped around a CommonWidgetMeta object. - */ - @RequestMapping(value = "/widgetData", method = RequestMethod.GET, produces = "application/json") - public PortalRestResponse<CommonWidgetMeta> getWidgetData(HttpServletRequest request, - @RequestParam String resourceType) { - return new PortalRestResponse<CommonWidgetMeta>(PortalRestStatusEnum.OK, "success", - searchService.getWidgetData(resourceType)); - } - - /** - * Saves all: news and resources - * - * @param commonWidgetMeta - * read from POST body. - * @return Rest response wrapped around a String; e.g., "success" or "ERROR" - */ - @RequestMapping(value = "/widgetDataBulk", method = RequestMethod.POST, produces = "application/json") - public PortalRestResponse<String> saveWidgetDataBulk(@RequestBody CommonWidgetMeta commonWidgetMeta) { - logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetDataBulk: argument is {}", commonWidgetMeta); - if (commonWidgetMeta.getCategory() == null || commonWidgetMeta.getCategory().trim().equals("")) - return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "ERROR", - "Category cannot be null or empty"); - // validate dates - for (CommonWidget cw : commonWidgetMeta.getItems()) { - String err = validateCommonWidget(cw); - if (err != null) - return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, err, null); - } - return new PortalRestResponse<String>(PortalRestStatusEnum.OK, "success", - searchService.saveWidgetDataBulk(commonWidgetMeta)); - } - - /** - * Saves one: news or resource - * - * @param commonWidget - * read from POST body - * @return Rest response wrapped around a String; e.g., "success" or "ERROR" - */ - @RequestMapping(value = "/widgetData", method = RequestMethod.POST, produces = "application/json") - public PortalRestResponse<String> saveWidgetData(@RequestBody CommonWidget commonWidget) { - logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget); - if (commonWidget.getCategory() == null || commonWidget.getCategory().trim().equals("")) - return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "ERROR", - "Cateogry cannot be null or empty"); - String err = validateCommonWidget(commonWidget); - if (err != null) - return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, err, null); - return new PortalRestResponse<String>(PortalRestStatusEnum.OK, "success", - searchService.saveWidgetData(commonWidget)); - } - - /** - * Used by the validate function - */ - private final SimpleDateFormat yearMonthDayFormat = new SimpleDateFormat("yyyy-MM-dd"); - - /** - * Validates the content of a common widget. - * - * @param cw - * @return null on success; an error message if validation fails. - * @throws Exception - */ - private String validateCommonWidget(CommonWidget cw) { - try { - if (cw.getEventDate() != null && cw.getEventDate().trim().length() > 0) - yearMonthDayFormat.parse(cw.getEventDate()); - } catch (ParseException ex) { - return ex.toString(); - } - return null; - } - - /** - * Deletes one: news or resource - * - * @param commonWidget - * read from POST body - * @return Rest response wrapped around a String; e.g., "success" or "ERROR" - */ - @RequestMapping(value = "/deleteData", method = RequestMethod.POST, produces = "application/json") - public PortalRestResponse<String> deleteWidgetData(@RequestBody CommonWidget commonWidget) { - logger.debug(EELFLoggerDelegate.debugLogger, "deleteWidgetData: argument is {}", commonWidget); - return new PortalRestResponse<String>(PortalRestStatusEnum.OK, "success", - searchService.deleteWidgetData(commonWidget)); - } - - /** - * Searches all portal for the input string. - * - * @param request - * @param searchString - * @return Rest response wrapped around a Map of String to List of Search - * Result Item. - */ - @RequestMapping(value = "/allPortal", method = RequestMethod.GET, produces = "application/json") - public PortalRestResponse<Map<String, List<SearchResultItem>>> searchPortal(HttpServletRequest request, - @RequestParam String searchString) { - - EPUser user = EPUserUtils.getUserSession(request); - try { - if (user == null) { - return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, - "searchPortal: User object is null? - check logs", - new HashMap<String, List<SearchResultItem>>()); - } else if (searchString == null || searchString.trim().length() == 0) { - return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "searchPortal: String string is null", - new HashMap<String, List<SearchResultItem>>()); - } else { - logger.debug(EELFLoggerDelegate.debugLogger, "searchPortal: user {}, search string '{}'", - user.getLoginId(), searchString); - Map<String, List<SearchResultItem>> results = searchService.searchResults(user.getLoginId(), - searchString); - return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", results); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchPortal failed", e); - return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.getMessage() + " - check logs.", - new HashMap<String, List<SearchResultItem>>()); - } - } - - /** - * Gets all active users. - * - * TODO: should only the superuser be allowed to use this API? - * - * @param request - * @return Rest response wrapped around a list of String - */ - @RequestMapping(value = "/activeUsers", method = RequestMethod.GET, produces = "application/json") - public List<String> getActiveUsers(HttpServletRequest request) { - List<String> activeUsers = null; - List<String> onlineUsers = new ArrayList<>(); - try { - EPUser user = EPUserUtils.getUserSession(request); - String userId = user.getOrgUserId(); - - activeUsers = searchService.getRelatedUsers(userId); - HashSet<String> usersSet = CollaborateList.getInstance().getAllUserName(); - for (String users : activeUsers) { - if (usersSet.contains(users)) { - onlineUsers.add(users); - } - } - - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getActiveUsers failed", e); - } - return onlineUsers; - } - - /** - * Gets only those users that are 'related' to the currently logged-in user. - * - * @param request - * @return Rest response wrapped around a List of String - */ - @RequestMapping(value = "/relatedUsers", method = RequestMethod.GET, produces = "application/json") - public PortalRestResponse<List<String>> activeUsers(HttpServletRequest request) { - EPUser user = EPUserUtils.getUserSession(request); - try { - if (user == null) { - return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "User object is null? - check logs", - new ArrayList<>()); - } else { - logger.debug(EELFLoggerDelegate.debugLogger, "activeUsers: searching for user {}", user.getLoginId()); - return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", - searchService.getRelatedUsers(user.getLoginId())); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "activeUsers failed", e); - return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.getMessage() + " - check logs.", - new ArrayList<>()); - } - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java deleted file mode 100644 index 95623661..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/ExternalAppsRestfulController.java +++ /dev/null @@ -1,147 +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.portal.controller; - -import java.io.IOException; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalapp.controller.EPRestrictedRESTfulBaseController; -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.EPLoginService; -import org.openecomp.portalapp.portal.service.FunctionalMenuService; -import org.openecomp.portalapp.portal.transport.FavoritesFunctionalMenuItemJson; -import org.openecomp.portalapp.portal.transport.FieldsValidator; -import org.openecomp.portalapp.portal.transport.FunctionalMenuItem; -import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalapp.portal.utils.PortalConstants; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(PortalConstants.REST_AUX_API) -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPAuditLog -public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseController { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppsRestfulController.class); - - @Autowired - FunctionalMenuService functionalMenuService; - - @Autowired - EPLoginService epLoginService; - - @Autowired - AdminRolesService adminRolesService; - - @RequestMapping(value={"/getFavorites"}, method = RequestMethod.GET,produces = "application/json") - public List<FavoritesFunctionalMenuItemJson> getFavoritesForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { - String loginId = ""; - String userAgent = ""; - List<FavoritesFunctionalMenuItemJson> favorites = null; - - loginId = request.getHeader(EPSystemProperties.MDC_LOGIN_ID); - userAgent = MDC.get(EPSystemProperties.PARTNER_NAME); - - EPUser epUser = epLoginService.findUserWithoutPwd(loginId); - logger.info(EELFLoggerDelegate.errorLogger, "getFavorites request was received from " + userAgent + " for the user " + loginId + "."); - if (epUser==null || epUser.getId()==null) { - logger.error(EELFLoggerDelegate.errorLogger, "No User record found for the LoginId '" + loginId + "' in the database."); - throw new Exception("Received null for Login-Id."); - } else { - favorites = functionalMenuService.getFavoriteItems(epUser.getId()); - FieldsValidator fieldsValidator = new FieldsValidator(); - response.setStatus(fieldsValidator.httpStatusCode.intValue()); - - EcompPortalUtils.logAndSerializeObject("/auxapi/getFavorites", "result = ", favorites); - } - - return favorites; - } - - @RequestMapping(value={"/functionalMenuItemsForUser"}, method = RequestMethod.GET,produces = "application/json") - public List<FunctionalMenuItem> getFunctionalMenuItemsForUser(HttpServletRequest request, HttpServletResponse response) throws Exception { - String loginId = ""; - String userAgent = ""; - List<FunctionalMenuItem> fnMenuItems = null; - - loginId = request.getHeader("LoginId"); - userAgent = MDC.get(EPSystemProperties.PARTNER_NAME); - - EPUser epUser = epLoginService.findUserWithoutPwd(loginId); - logger.info(EELFLoggerDelegate.errorLogger, "getFunctionalMenuItemsForUser request was received from " + userAgent + " for the user " + loginId + "."); - if (epUser==null || epUser.getId()==null) { - logger.error(EELFLoggerDelegate.errorLogger, "No User record found for the LoginId '" + loginId + "' in the database."); - throw new Exception("Received null for Login-Id."); - } else if (adminRolesService.isSuperAdmin(epUser)) { - logger.debug(EELFLoggerDelegate.debugLogger, "FunctionalMenuHandler: SuperUser, about to call getFunctionalMenuItems()"); - fnMenuItems = functionalMenuService.getFunctionalMenuItems(); - } - else { - logger.debug(EELFLoggerDelegate.debugLogger, "getMenuItemsForAuthUser: about to call getFunctionalMenuItemsForUser()"); - fnMenuItems = functionalMenuService.getFunctionalMenuItemsForUser(epUser.getOrgUserId()); - } - - FieldsValidator fieldsValidator = new FieldsValidator(); - response.setStatus(fieldsValidator.httpStatusCode.intValue()); - - EcompPortalUtils.logAndSerializeObject("/auxapi/functionalMenuItemsForUser", "result = ", fnMenuItems); - - return fnMenuItems; - } - - @ExceptionHandler(Exception.class) - protected void handleBadRequests(Exception e, HttpServletResponse response) throws IOException { - logger.warn(EELFLoggerDelegate.errorLogger, "Handling bad request", e); - response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage()); - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java deleted file mode 100644 index d2585ab4..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/controller/PortalAdminController.java +++ /dev/null @@ -1,155 +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.portal.controller; - -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalapp.controller.EPRestrictedBaseController; -import org.openecomp.portalapp.portal.domain.EPRole; -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.PortalAdminService; -import org.openecomp.portalapp.portal.transport.FieldsValidator; -import org.openecomp.portalapp.portal.transport.PortalAdmin; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPAuditLog -public class PortalAdminController extends EPRestrictedBaseController { - @Autowired - PortalAdminService portalAdminService; - @Autowired - AdminRolesService adminRolesService; - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PortalAdminController.class); - - @RequestMapping(value = { "/portalApi/portalAdmins" }, method = RequestMethod.GET, produces = "application/json") - public List<PortalAdmin> getPortalAdmins(HttpServletRequest request, HttpServletResponse response) { - EPUser user = EPUserUtils.getUserSession(request); - List<PortalAdmin> portalAdmins = null; - if (user == null) { - logger.debug(EELFLoggerDelegate.debugLogger, "PortalAdminController.getPortalAdmins, null user"); - EcompPortalUtils.setBadPermissions(user, response, "getPortalAdmins"); - } else if (!adminRolesService.isSuperAdmin(user)) { - logger.debug(EELFLoggerDelegate.debugLogger, "PortalAdminController.getPortalAdmins, bad permissions"); - EcompPortalUtils.setBadPermissions(user, response, "createPortalAdmin"); - } else { - // return the list of portal admins - portalAdmins = portalAdminService.getPortalAdmins(); - logger.debug(EELFLoggerDelegate.debugLogger, "portalAdmins: called getPortalAdmins()"); - EcompPortalUtils.logAndSerializeObject("/portalApi/getPortalAdmins", "result =", portalAdmins); - } - - return portalAdmins; - } - - /** - * RESTful service method to create a new portal admin. Requirement: you - * must be the Ecomp portal super admin user. - */ - - @RequestMapping(value = { "/portalApi/portalAdmin" }, method = RequestMethod.POST) - public FieldsValidator createPortalAdmin(HttpServletRequest request, @RequestBody String userid, - HttpServletResponse response) { - EPUser user = EPUserUtils.getUserSession(request); - FieldsValidator fieldsValidator = null; - if (user == null) { - logger.debug(EELFLoggerDelegate.debugLogger, "PortalAdminController.createPortalAdmin, null user"); - EcompPortalUtils.setBadPermissions(user, response, "createPortalAdmin"); - } else if (!adminRolesService.isSuperAdmin(user)) { - logger.debug(EELFLoggerDelegate.debugLogger, "PortalAdminController.createPortalAdmin bad permissions"); - EcompPortalUtils.setBadPermissions(user, response, "createPortalAdmin"); - } else { - fieldsValidator = portalAdminService.createPortalAdmin(userid); - response.setStatus(fieldsValidator.httpStatusCode.intValue()); - } - EcompPortalUtils.logAndSerializeObject("/portalAdmin", "POST result =", response.getStatus()); - - return fieldsValidator; - } - - @RequestMapping(value = { "/portalApi/portalAdmin/{orgUserId}" }, method = RequestMethod.DELETE) - public FieldsValidator deletePortalAdmin(HttpServletRequest request, @PathVariable("orgUserId") Long orgUserId, - HttpServletResponse response) { - EPUser user = EPUserUtils.getUserSession(request); - FieldsValidator fieldsValidator = null; - if (!adminRolesService.isSuperAdmin(user)) { - EcompPortalUtils.setBadPermissions(user, response, "deletePortalAdmin"); - } else { - fieldsValidator = portalAdminService.deletePortalAdmin(orgUserId); - response.setStatus(fieldsValidator.httpStatusCode.intValue()); - } - EcompPortalUtils.logAndSerializeObject("/portalAdmin", "DELETE result =", response.getStatus()); - - return fieldsValidator; - } - - @RequestMapping(value = { "/portalApi/adminAppsRoles/{appId}" }, method = RequestMethod.GET, produces = "application/json") - public List<EPRole> getRolesByApp(HttpServletRequest request, @PathVariable("appId") Long appId, - HttpServletResponse response) { - EPUser user = EPUserUtils.getUserSession(request); - List<EPRole> rolesByApp = null; - - try { - if (user == null) { - EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); - } else { - rolesByApp = adminRolesService.getRolesByApp(user, appId); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getRolesByApp failed", e); - } - - return rolesByApp; - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.java deleted file mode 100644 index 61b98e4f..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/interceptor/SessionTimeoutInterceptor.java +++ /dev/null @@ -1,118 +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.portal.interceptor; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalapp.authentication.LoginStrategy; -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalapp.util.EPUserUtils; -import org.openecomp.portalapp.util.SessionCookieUtil; -import org.openecomp.portalsdk.core.controller.FusionBaseController; -import org.openecomp.portalsdk.core.domain.support.CollaborateList; -import org.openecomp.portalsdk.core.exception.SessionExpiredException; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; - -public class SessionTimeoutInterceptor extends HandlerInterceptorAdapter { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionTimeoutInterceptor.class); - - @Autowired - private LoginStrategy loginStrategy; - - public SessionTimeoutInterceptor() { - } - - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception { - - if (!isHandlerMethod(handler)) - return false; - - HandlerMethod method = (HandlerMethod) handler; - - if (!isFusionController(method.getBean())) - return false; - - if (method.getBean() instanceof FusionBaseController) { - FusionBaseController controller = (FusionBaseController) method.getBean(); - - if (!controller.isAccessible()) { - try { - EPUser user = EPUserUtils.getUserSession(request); - - if (request.getRequestURI().indexOf("logout.htm") > -1) { - CollaborateList.delUserName(user.getOrgUserId()); - throw new SessionExpiredException(); - } else { - resetSessionMaxIdleTimeOut(request); - CollaborateList.addUserName(user.getOrgUserId()); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "preHandle failed", e); - return false; - } - - } - - } - - return true; - } - - private void resetSessionMaxIdleTimeOut(HttpServletRequest request) { - SessionCookieUtil.resetSessionMaxIdleTimeOut(request); - - } - - private boolean isFusionController(Object controller) { - if (controller instanceof FusionBaseController) - return true; - return false; - } - - private boolean isHandlerMethod(Object controller) { - if (controller instanceof HandlerMethod) - return true; - return false; - } -}
\ No newline at end of file diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java deleted file mode 100644 index 0970ec45..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/logging/aop/EPEELFLoggerAspect.java +++ /dev/null @@ -1,222 +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.portal.logging.aop; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.openecomp.portalapp.portal.transport.FieldsValidator; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum; -import org.springframework.beans.factory.annotation.Autowired; - -@Aspect -@org.springframework.context.annotation.Configuration -public class EPEELFLoggerAspect { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPEELFLoggerAspect.class); - - @Autowired - EPEELFLoggerAdvice epAdvice; - - /* - * Point-cut expression to handle all INCOMING_REST_MESSAGES - */ - @Pointcut("execution(public * org.openecomp.portalapp.portal.controller.*.*(..))") - public void incomingAuditMessages() {} - - /* - * Handles all INCOMING_REST_MESSAGES from kpiDashboard - */ - @Pointcut("execution(public * org.openecomp.portalapp.kpidash.controller.*.*(..))") - public void kpiDashboardAuditMessages() {} - - /* - * Point-cut expression to handle all session management INCOMING_REST_MESSAGES - */ - @Pointcut("execution(public * org.openecomp.portalapp.controller.sessionmgt.*.*(..))") - public void sessionMgtIncomingAuditMessages() {} - - /* - * Point-cut expression to handle UserProfileController INCOMING_REST_MESSAGES - */ - @Pointcut("execution(public * org.openecomp.portalapp.controller.core.UserProfileController.*(..))") - public void userProfileIncomingAuditMessages() {} - - /* - * Point-cut expression to handle UserProfileController INCOMING_REST_MESSAGES - */ - @Pointcut("execution(public * org.openecomp.portalapp.controller.ONAPWelcomeController.*(..))") - public void welcomeIncomingAuditMessages() {} - - /* - * Point-cut expression to handle INCOMING Logout Rest Messages - */ - @Pointcut("execution(public * org.openecomp.portalapp.controller.ECOMPLogoutController.*(..))") - public void logoutAuditMessages() {} - - - /* - * Point-cut expression which handles all the OUTGOING_REST_MESSAGES. - */ - @Pointcut("execution(public * org.openecomp.portalapp.portal.service.ApplicationsRestClientServiceImpl.*(..))") - public void outgoingAuditMessages() {} - - /* - * Point-cut expression to handle all the session management OUTGOING_REST_MESSAGES. - */ - @Pointcut("execution(public * org.openecomp.portalapp.service.sessionmgt.SessionCommunication.*(..))") - public void sessionMgtOutgoingAuditMessages() {} - - /* - * Point-cut expression which handles all the LDAP_PHONEBOOK_USER_SEARCH calls. - */ - @Pointcut("execution(public * org.openecomp.portalapp.portal.service.EPLdapServiceImpl.*(..))") - public void phoneBookSearchAuditMessages() {} - - /* - * Handles Audit, Metrics & Debug logging for the point-cut - * expression defined at class-level - */ - @Around("(incomingAuditMessages() || kpiDashboardAuditMessages() || sessionMgtIncomingAuditMessages() || " - + "userProfileIncomingAuditMessages() || welcomeIncomingAuditMessages()) && @within(epAuditLog)") - public Object incomingAuditMessagesAroundClass(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.INCOMING_REST_MESSAGE); - } - - /* - * Handles Audit, Metrics & Debug logging for the point-cut - * expression defined at class-level - */ - @Around("(outgoingAuditMessages() || sessionMgtOutgoingAuditMessages()) && @within(epAuditLog)") - public Object outgoingAuditMessagesAroundClass(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.OUTGOING_REST_MESSAGE); - } - - - /* - * Handles Audit, Metrics & Debug logging for the point-cut - * expression defined at method-level - */ - @Around("(outgoingAuditMessages() || sessionMgtOutgoingAuditMessages()) && @annotation(epAuditLog)") - public Object outgoingAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.OUTGOING_REST_MESSAGE); - } - - /* - * Handles Audit, Metrics & Debug logging for the point-cut - * expression defined at method-level - */ - @Around("(incomingAuditMessages() || kpiDashboardAuditMessages() || sessionMgtIncomingAuditMessages() ||" - + "userProfileIncomingAuditMessages() || welcomeIncomingAuditMessages()) && @annotation(epAuditLog)") - public Object incomingAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.INCOMING_REST_MESSAGE); - } - - @Around("@annotation(epAuditLog)") - public Object loginAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.FE_LOGIN_ATTEMPT); - } - - @Around("logoutAuditMessages() && @annotation(epAuditLog)") - public Object logoutAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.FE_LOGOUT); - } - - @Around("phoneBookSearchAuditMessages() && @annotation(epAuditLog)") - public Object phonebookSearchAuditMessagesAroundMethod(ProceedingJoinPoint joinPoint, EPAuditLog epAuditLog) throws Throwable { - return this.logAroundMethod(joinPoint, SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH); - } - - private Object logAroundMethod(ProceedingJoinPoint joinPoint, SecurityEventTypeEnum securityEventType) throws Throwable { - //Before - Object[] passOnArgs = new Object[] {joinPoint.getSignature().getDeclaringType().getName(), joinPoint.getSignature().getName()}; - Object[] returnArgs = epAdvice.before(securityEventType, joinPoint.getArgs(), passOnArgs); - - //Call the actual method - Object result = null; - String statusCode = "COMPLETE"; - String responseCode = "200"; - try { - result = joinPoint.proceed(); - } catch(Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "logAroundMethod failed", e); - statusCode = "ERROR"; - responseCode = "500"; //Internal server error - } - - //Check the result - if (securityEventType!=null) { - if (result==null) { - statusCode = "ERROR"; - //Check if there is an internal response code - //and use it if the caller function has configured it. - responseCode = epAdvice.getInternalResponseCode(); - if (responseCode==null||responseCode=="") { - responseCode = "500"; //Internal server error - } - } else if (result instanceof FieldsValidator) { - FieldsValidator fieldsValidator = (FieldsValidator) result; - if (fieldsValidator!=null && fieldsValidator.httpStatusCode!=null) { - responseCode = fieldsValidator.httpStatusCode.toString(); - } - } - } - - //After - epAdvice.after(securityEventType, statusCode, responseCode, joinPoint.getArgs(), returnArgs, passOnArgs); - - return result; - } - - //Metrics Logging - @Pointcut("execution(* *(..))") - public void performMetricsLogging() {} - - @Around("performMetricsLogging() && @within(epMetricsLog)") - public Object metricsLoggingAroundClass(ProceedingJoinPoint joinPoint, EPMetricsLog epMetricsLog) throws Throwable { - return this.logAroundMethod(joinPoint, null); - } - - @Around("performMetricsLogging() && @annotation(epMetricsLog)") - public Object metricsLoggingAroundMethod(ProceedingJoinPoint joinPoint, EPMetricsLog epMetricsLog) throws Throwable { - return this.logAroundMethod(joinPoint, null); - } -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java deleted file mode 100644 index 20f4d59f..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheService.java +++ /dev/null @@ -1,58 +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.portal.service; - -import org.openecomp.portalapp.portal.domain.EPApp; - -public interface AppsCacheService { - - /** - * returns an app by id from the cache - * @param appId - * @return corresponding App - */ - EPApp getApp(Long appId); - - /** - * returns the corresponding application endpoint - * @param appId - * @return if appId exists in cache, then return corresponding application endpoint, null otherwise. - */ - String getAppEndpoint(Long appId); -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java deleted file mode 100644 index 09a78e85..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/AppsCacheServiceImple.java +++ /dev/null @@ -1,122 +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.portal.service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import org.openecomp.portalapp.portal.domain.EPApp; -import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; - -@Service("appsCacheService") -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPMetricsLog -public class AppsCacheServiceImple implements AppsCacheService { - @Autowired - EPAppService appsService; - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsCacheServiceImple.class); - - private static long updateTime = 0; - private static final int cacheUpdateIntervalInSeconds = 10; - - private static volatile Map<Long, EPApp> appsMap; - - @PostConstruct - public void init() { - this.refreshAppsMap(); - } - - private Map<Long, EPApp> refreshAppsMap() { - long now = System.currentTimeMillis(); - - if(noNeedToUpdate(now)) - return null; - - synchronized (this) { - if(noNeedToUpdate(now)) - return null; - List<EPApp> allApps = appsService.getAppsFullList(); - Map<Long, EPApp> newAppsMap = new HashMap<Long, EPApp>(); - for (EPApp app : allApps) { - newAppsMap.put(app.getId(), app); - } - // Switch cache with the new one. - appsMap = newAppsMap; - updateTime = now; - } - - return appsMap; - } - - private boolean noNeedToUpdate(long now) { - long secondsPassed = (now - updateTime)/1000; - if(secondsPassed < cacheUpdateIntervalInSeconds){ - logger.debug(EELFLoggerDelegate.debugLogger, "no need to refresh yet, seconds since last refresh: " + secondsPassed + ", refresh interval (sec) = " + cacheUpdateIntervalInSeconds); - return true; // no need to update cache - } - return false; // its time to update - } - - @Override - public String getAppEndpoint(Long appId) { - refreshAppsMap(); - EPApp app = appsMap.get(appId); - if(app != null) - return app.getAppRestEndpoint(); - return null; - } - - @Override - public EPApp getApp(Long appId) { - refreshAppsMap(); - EPApp app = appsMap.get(appId); - if(app != null) - return app; - return null; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java deleted file mode 100644 index ea92ca51..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/EPAppServiceImpl.java +++ /dev/null @@ -1,176 +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.portal.service; - -import java.net.MalformedURLException; -import java.security.GeneralSecurityException; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.TreeSet; -import java.util.UUID; - -import javax.servlet.http.HttpServletResponse; - -import org.hibernate.Session; -import org.hibernate.Transaction; -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.logging.format.EPAppMessagesEnum; -import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; -import org.openecomp.portalapp.portal.transport.FieldsValidator; -import org.openecomp.portalapp.portal.transport.OnboardingApp; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.DataAccessService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.att.nsa.cambria.client.CambriaClientFactory; -import com.att.nsa.cambria.client.CambriaTopicManager; - -@Service("epAppService") -@Transactional -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPMetricsLog -public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppService { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPAppServiceImpl.class); - - private static Object syncRests = new Object(); - - @Autowired - private DataAccessService dataAccessService; - - @Override - public List<EPApp> getUserRemoteApps(String id) { - StringBuilder query = new StringBuilder(); - query.append("SELECT * FROM FN_APP join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = FN_APP.APP_ID where "); - query.append("FN_USER_ROLE.USER_ID = " + id + " AND FN_USER_ROLE.ROLE_ID != " + SUPER_ADMIN_ROLE_ID); - query.append(" AND FN_APP.ENABLED = 'Y'"); - TreeSet<EPApp> distinctApps = new TreeSet<EPApp>(); - @SuppressWarnings("unchecked") - List<EPApp> adminApps = dataAccessService.executeSQLQuery(query.toString(), EPApp.class, null); - for (EPApp app : adminApps) { - distinctApps.add(app); - } - List<EPApp> userApps = new ArrayList<EPApp>(); - userApps.addAll(distinctApps); - return userApps; - } - - @Override - protected void updateRestrictedApp(Long appId, OnboardingApp onboardingApp, FieldsValidator fieldsValidator, - EPUser user) { - synchronized (syncRests) { - boolean result = false; - Session localSession = null; - Transaction transaction = null; - try { - localSession = sessionFactory.openSession(); - transaction = localSession.beginTransaction(); - EPApp app; - if (appId == null) { - app = new EPApp(); - /* - * In the parent class, the UEB code is responsible for generating the - * keys/secret/mailbox but UEB Messaging is not actually being used currently; - * may be used in future at which point we can just remove this method and - * depend on parent class's method So, using UUID generator to generate the - * unique key instead. - */ - String uuidStr = UUID.randomUUID().toString(); - String appKey = uuidStr; - String appSecret = uuidStr; - String appMailboxName = "ECOMP-PORTAL-OUTBOX"; - onboardingApp.setUebTopicName(appMailboxName); - onboardingApp.setUebKey(appKey); - onboardingApp.setUebSecret(appSecret); - } else { - app = (EPApp) localSession.get(EPApp.class, appId); - if (app == null || app.getId() == null) { - // App is already deleted! - transaction.commit(); - localSession.close(); - fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_NOT_FOUND); - return; - } - } - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: about to call createAppFromOnboarding"); - createAppFromOnboarding(app, onboardingApp, localSession); - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: finished calling createAppFromOnboarding"); - localSession.saveOrUpdate(app); - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: finished calling localSession.saveOrUpdate"); - // Enable or disable all menu items associated with this app - setFunctionalMenuItemsEnabled(localSession, onboardingApp.isEnabled, appId); - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: finished calling setFunctionalMenuItemsEnabled"); - transaction.commit(); - logger.debug(EELFLoggerDelegate.debugLogger, - "updateRestrictedApp: finished calling transaction.commit"); - result = true; - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "updateRestrictedApp failed", e); - EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebRegisterOnboardingAppError, e); - EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e); - EcompPortalUtils.rollbackTransaction(transaction, - "updateRestrictedApp rollback, exception = " + e.toString()); - } finally { - EcompPortalUtils.closeLocalSession(localSession, "updateRestrictedApp"); - } - if (!result) { - fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } - } - - } - - @Override - public CambriaTopicManager getTopicManager(List<String> urlList, String key, String secret) - throws MalformedURLException, GeneralSecurityException { - return CambriaClientFactory.createTopicManager(null, urlList, key, secret); - } - -}
\ No newline at end of file diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java deleted file mode 100644 index 07dc8cca..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchService.java +++ /dev/null @@ -1,58 +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.portal.service; - -import java.util.List; - -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.transport.UserWithNameSurnameTitle; - -public interface SearchService { - - - public String searchUsersInPhoneBook(String searchString); - - public String searchUsersInFnTable(String searchString); - - public List<UserWithNameSurnameTitle> searchUsersByName(EPUser attrUser); - - public List<UserWithNameSurnameTitle> searchUsersByUserId(EPUser attrUser); - - public EPUser searchUserByUserId(String orgUserId); - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java deleted file mode 100644 index 0929c480..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java +++ /dev/null @@ -1,211 +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.portal.service; - -import java.util.ArrayList; -import java.util.List; - -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; -import org.openecomp.portalapp.portal.transport.UserWithNameSurnameTitle; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Service("searchService") -@Transactional -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPMetricsLog -public class SearchServiceImpl implements SearchService { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SearchServiceImpl.class); - - // TODO: the values below should be defined in other place - private static final int maxSizeOfSearchResult = 100; - - @Autowired - UserService userService; - - @Override - public String searchUsersInPhoneBook(String searchString) { - return searchUsersInFnTable(searchString); - } - - @Override - public String searchUsersInFnTable(String searchString) { - String orgUserId = null; - List<String> tokens = EcompPortalUtils.parsingByRegularExpression(searchString, " "); - for (int i = 0; i < tokens.size(); i++) { // find userid if possible and remove it from tokens - if (tokens.get(i).matches(".*\\d+.*")) { - orgUserId = tokens.get(i); - tokens.remove(i); - } - } - while (tokens.size() > 2) { // we use no more then first 2 tokens (userId is removed, see above) - tokens.remove(tokens.size() - 1); - } - EPUser attrUser = new EPUser(); - attrUser.setOrgUserId(orgUserId); - List<UserWithNameSurnameTitle> resultOfSearch = new ArrayList<UserWithNameSurnameTitle>(), resultOfAdditionalSearch = null; - if (tokens.size() == 2) { - attrUser.setFirstName(tokens.get(0)); - attrUser.setLastName(tokens.get(1)); - resultOfSearch = this.searchUsersByName(attrUser); - resultOfSearch = this.removeWrongFirstNames(resultOfSearch, tokens.get(0)); - resultOfSearch = this.removeWrongLastNames(resultOfSearch, tokens.get(1)); - if (resultOfSearch.size() < maxSizeOfSearchResult) { - attrUser.setFirstName(tokens.get(1)); - attrUser.setLastName(tokens.get(0)); - resultOfAdditionalSearch = this.searchUsersByName(attrUser); - resultOfAdditionalSearch = this.removeWrongFirstNames(resultOfAdditionalSearch, tokens.get(1)); - resultOfAdditionalSearch = this.removeWrongLastNames(resultOfAdditionalSearch, tokens.get(0)); - } - } else if (tokens.size() == 1) { - attrUser.setFirstName(tokens.get(0)); - resultOfSearch = this.searchUsersByName(attrUser); - resultOfSearch = this.removeWrongFirstNames(resultOfSearch, tokens.get(0)); - if (resultOfSearch.size() < maxSizeOfSearchResult) { - attrUser.setFirstName(null); - attrUser.setLastName(tokens.get(0)); - resultOfAdditionalSearch = this.searchUsersByName(attrUser); - resultOfAdditionalSearch = this.removeWrongLastNames(resultOfAdditionalSearch, tokens.get(0)); - } - } else if (orgUserId != null) { - resultOfSearch = this.searchUsersByUserId(attrUser); - } - if (resultOfAdditionalSearch != null) { - resultOfSearch.addAll(resultOfAdditionalSearch); - } - resultOfSearch = this.cutSearchResultToMaximumSize(resultOfSearch); - ObjectMapper mapper = new ObjectMapper(); - String result = "[]"; - try { - result = mapper.writeValueAsString(resultOfSearch); - } catch (JsonProcessingException e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchUsersInFnTable failed", e); - } - return result; - } - - - @SuppressWarnings("rawtypes") - public List<UserWithNameSurnameTitle> searchUsersByUserId(EPUser attrUser) { - List<UserWithNameSurnameTitle> foundUsers = new ArrayList<UserWithNameSurnameTitle>(); - try { - List searchResult = this.userService.getUserByUserId(attrUser.getOrgUserId()); - for (Object obj : searchResult) { - EPUser user = (EPUser) obj; - UserWithNameSurnameTitle foundUser = new UserWithNameSurnameTitle(user.getOrgUserId(), user.getFirstName(), user.getLastName(), user.getJobTitle()); - foundUsers.add(foundUser); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchUsersByUserId failed", e); - } - return foundUsers; - } - - @SuppressWarnings("rawtypes") - public List<UserWithNameSurnameTitle> searchUsersByName(EPUser attrUser) { - List<UserWithNameSurnameTitle> foundUsers = new ArrayList<UserWithNameSurnameTitle>(); - try { - List searchResult = this.userService.getUserByFirstLastName(attrUser.getFirstName(),attrUser.getLastName()); - for (Object obj : searchResult) { - EPUser user = (EPUser) obj; - UserWithNameSurnameTitle foundUser = new UserWithNameSurnameTitle(user.getOrgUserId(), user.getFirstName(), user.getLastName(), user.getJobTitle()); - foundUsers.add(foundUser); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchUsersByName failed", e); - } - return foundUsers; - } - - private List<UserWithNameSurnameTitle> removeWrongFirstNames(List<UserWithNameSurnameTitle> resultOfSearch, String firstName) { - firstName = firstName.toUpperCase(); - for (int i = resultOfSearch.size() - 1; i >= 0; i--) { - UserWithNameSurnameTitle user = resultOfSearch.get(i); - if ((user.firstName == null) || !user.firstName.toUpperCase().startsWith(firstName)) { - resultOfSearch.remove(i); - } - } - return resultOfSearch; - } - - private List<UserWithNameSurnameTitle> removeWrongLastNames(List<UserWithNameSurnameTitle> resultOfSearch, String lastName) { - lastName = lastName.toUpperCase(); - for (int i = resultOfSearch.size() - 1; i >= 0; i--) { - UserWithNameSurnameTitle user = resultOfSearch.get(i); - if ((user.lastName == null) || !user.lastName.toUpperCase().startsWith(lastName)) { - resultOfSearch.remove(i); - } - } - return resultOfSearch; - } - - private List<UserWithNameSurnameTitle> cutSearchResultToMaximumSize(List<UserWithNameSurnameTitle> resultOfSearch) { - for (int i = resultOfSearch.size() - 1; i >= maxSizeOfSearchResult; i--) { - resultOfSearch.remove(i); - } - return resultOfSearch; - } - - - @SuppressWarnings("rawtypes") - @Override - public EPUser searchUserByUserId(String orgUserId) { - List<EPUser> foundUsers = new ArrayList<EPUser>(); - try { - List searchResult = this.userService.getUserByUserId(orgUserId); - for (Object obj : searchResult) { - EPUser user = (EPUser) obj; - foundUsers.add(user); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "searchUserByUserId failed", e); - return null; - } - return foundUsers.get(0); - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java deleted file mode 100644 index 446bb60e..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java +++ /dev/null @@ -1,55 +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.portal.service; - -import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.stereotype.Service; - -import com.fasterxml.jackson.databind.JsonNode; - -@Service("ticketService") -public class TicketEventServiceImpl implements TicketEventService{ - - @Override - public String getNotificationHyperLink(JsonNode application, String ticket, String eventSource) { - String hyperlink = SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_SYSTEM_NOTIFICATION_URL)+ticket; - return hyperlink; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java deleted file mode 100644 index 41b320c2..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserRolesServiceImpl.java +++ /dev/null @@ -1,121 +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.portal.service; - -import java.util.List; - -import org.apache.cxf.transport.http.HTTPException; -import org.openecomp.portalapp.portal.domain.EPApp; -import org.openecomp.portalapp.portal.domain.EPRole; -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.domain.EPUserApp; -import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.service.DataAccessService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Service("userRolesService") -@Transactional -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPMetricsLog -public class UserRolesServiceImpl extends UserRolesCommonServiceImpl implements UserRolesService { - - private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserRolesServiceImpl.class); - - @Autowired - private DataAccessService dataAccessService; - - private EPUser getUserFromRemoteApp(String orgUserId, EPApp app, - ApplicationsRestClientService applicationsRestClientService) throws HTTPException { - EPUser user = applicationsRestClientService.get(EPUser.class, app.getId(), - String.format("/user/%s", orgUserId)); - return user; - } - - private static void createNewUserOnRemoteApp(String orgUserId, EPApp app, - ApplicationsRestClientService applicationsRestClientService, SearchService searchService, - ObjectMapper mapper) throws Exception { - EPUser client = searchService.searchUserByUserId(orgUserId); - if (client == null) { - String msg = "cannot create user " + orgUserId + ", because he/she cannot be found in phonebook."; - logger.error(EELFLoggerDelegate.errorLogger, msg); - throw new Exception(msg); - } - client.setLoginId(orgUserId); - client.setActive(true); - // The remote doesn't care about other apps, and this has caused - // serialization problems - infinite recursion. - client.getEPUserApps().clear(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - String userAsString = mapper.writeValueAsString(client); - logger.debug(EELFLoggerDelegate.debugLogger, - "about to post new client to remote application, users json = " + userAsString); - applicationsRestClientService.post(EPUser.class, app.getId(), userAsString, String.format("/user", orgUserId)); - } - - public static void persistExternalRoleInEcompDb(EPRole externalAppRole, Long appId, EPRoleService roleService) { - externalAppRole.setAppId(appId); - externalAppRole.setAppRoleId(externalAppRole.getId()); - externalAppRole.setId(null); // We will persist a new role, with ecomp - // role id which will be different than - // external app role id. - - roleService.saveRole(externalAppRole); - logger.debug(EELFLoggerDelegate.debugLogger, - String.format("ECOMP persists role from app:%d, app roleId: %d, roleName: %s", appId, - externalAppRole.getAppRoleId(), externalAppRole.getName())); - } - - @Override - public List<EPUserApp> getCachedAppRolesForUser(Long appId, Long userId) { - // Find the records for this user-app combo, if any - String filter = " where user_id = " + Long.toString(userId) + " and app_id = " + Long.toString(appId); - @SuppressWarnings("unchecked") - List<EPUserApp> roleList = dataAccessService.getList(EPUserApp.class, filter, null, null); - logger.debug(EELFLoggerDelegate.debugLogger, "getCachedAppRolesForUser: list size is {}", roleList.size()); - return roleList; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserService.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserService.java deleted file mode 100644 index 69ea652c..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserService.java +++ /dev/null @@ -1,52 +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.portal.service; - -import java.util.List; - -import org.openecomp.portalapp.portal.domain.EPUser; - -public interface UserService { - - List getUserByUserId(String orgUserId); - - List getUserByFirstLastName(String firstName, String lastName); - - public String saveNewUser(EPUser newUser, String checkDuplicate) throws Exception; - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java deleted file mode 100644 index 9cc97460..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/UserServiceImpl.java +++ /dev/null @@ -1,273 +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.portal.service; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.openecomp.portalapp.portal.domain.EPUser; -import org.openecomp.portalapp.portal.utils.EPSystemProperties; -import org.openecomp.portalsdk.core.FusionObject.Utilities; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; -import org.openecomp.portalsdk.core.service.DataAccessService; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service("userService") -@Transactional -public class UserServiceImpl implements UserService { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserServiceImpl.class); - - @Autowired - private DataAccessService dataAccessService; - - public DataAccessService getDataAccessService() { - return dataAccessService; - } - - public void setDataAccessService(DataAccessService dataAccessService) { - this.dataAccessService = dataAccessService; - } - - @SuppressWarnings("rawtypes") - @Override - public List getUserByUserId(String userId) { - - if (SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) { - List<EPUser> users = new ArrayList<EPUser>(); - List<EPUser> filterdUsers = new ArrayList<EPUser>(); - BufferedReader in = null; - HttpURLConnection con = null; - try { - String url = EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER); - URL obj = new URL(url); - - con = (HttpURLConnection) obj.openConnection(); - - // optional default is GET - con.setRequestMethod("GET"); - con.setConnectTimeout(3000); - con.setReadTimeout(8000); - - StringBuffer response = new StringBuffer(); - - in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8")); - String inputLine; - while ((inputLine = in.readLine()) != null) - response.append(inputLine); - JSONObject jObject = new JSONObject(response.toString()); // json - JSONArray jsonUsers = jObject.getJSONArray("response"); // get data object - for (int i = 0; i < jsonUsers.length(); i++) { - JSONObject eachObject = jsonUsers.getJSONObject(i); - EPUser eachUser = new EPUser(); - eachUser.setOrgUserId(eachObject.get("id").toString());// getString("id")); - eachUser.setFirstName(eachObject.get("givenName").toString()); - eachUser.setLastName(eachObject.get("familyName").toString()); - eachUser.setEmail(eachObject.get("email").toString()); - users.add(eachUser); - } - - for (int i = 0; i < users.size(); i++) { - - if (Utilities.nvl(userId).length() > 0) { - if (!userId.equalsIgnoreCase(users.get(i).getOrgUserId())) { - continue; - } - } - filterdUsers.add(users.get(i)); - - } - - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getUserByUserId failed", e); - } finally { - try { - in.close(); - con.disconnect(); - } catch (IOException e) { - logger.error(EELFLoggerDelegate.errorLogger, "getUserByUserId 2 failed", e); - } - } - - return filterdUsers; - - } else { - - List list = null; - StringBuffer criteria = new StringBuffer(); - criteria.append(" where org_user_id = '").append(userId).append("'"); - list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); - return (list == null || list.size() == 0) ? null : list; - - } - - } - - @SuppressWarnings("rawtypes") - @Override - public List getUserByFirstLastName(String firstName, String lastName) { - - if (!SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) { - - List list = null; - StringBuffer criteria = new StringBuffer(); - if (firstName != null) - criteria.append(" where first_name = '").append(firstName).append("'"); - if (lastName != null) - criteria.append(" where last_name = '").append(lastName).append("'"); - list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); - return (list == null || list.size() == 0) ? null : list; - - } else { - - List<EPUser> users = new ArrayList<EPUser>(); - List<EPUser> filterdUsers = new ArrayList<EPUser>(); - BufferedReader in = null; - HttpURLConnection con = null; - try { - String url = EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER); - URL obj = new URL(url); - - con = (HttpURLConnection) obj.openConnection(); - - // optional default is GET - con.setRequestMethod("GET"); - con.setConnectTimeout(3000); - con.setReadTimeout(8000); - - StringBuffer response = new StringBuffer(); - - in = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8")); - String inputLine; - while ((inputLine = in.readLine()) != null) - response.append(inputLine); - JSONObject jObject = new JSONObject(response.toString()); // json - JSONArray jsonUsers = jObject.getJSONArray("response"); // get data object - for (int i = 0; i < jsonUsers.length(); i++) { - JSONObject eachObject = jsonUsers.getJSONObject(i); - EPUser eachUser = new EPUser(); - eachUser.setOrgUserId(eachObject.get("id").toString());// getString("id")); - eachUser.setFirstName(eachObject.get("givenName").toString()); - eachUser.setLastName(eachObject.get("familyName").toString()); - eachUser.setEmail(eachObject.get("email").toString()); - users.add(eachUser); - } - - for (int i = 0; i < users.size(); i++) { - - if (Utilities.nvl(firstName).length() > 0) { - if (!firstName.equalsIgnoreCase(users.get(i).getFirstName())) { - continue; - } - } - if (Utilities.nvl(lastName).length() > 0) { - if (!lastName.equalsIgnoreCase(users.get(i).getLastName())) { - continue; - } - } - - filterdUsers.add(users.get(i)); - - } - - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName failed", e); - } finally { - try { - in.close(); - con.disconnect(); - } catch (IOException e) { - logger.error(EELFLoggerDelegate.errorLogger, "getUserByFirstLastName 2 failed", e); - } - } - - return filterdUsers; - } - - } - - public String saveNewUser(EPUser newUser, String checkDuplicate) throws Exception { - try { - List list = null; - StringBuffer criteria = new StringBuffer(); - criteria.append(" where org_user_id = '").append(newUser.getLoginId()).append("'"); - list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); - if (list == null || list.size() == 0) { - newUser.setActive(true); - newUser.setOrgUserId(newUser.getLoginId()); - newUser.setLoginPwd(CipherUtil.encrypt(newUser.getLoginPwd())); - getDataAccessService().saveDomainObject(newUser, null); - } else { - if (checkDuplicate.equals("Yes")) { - // userId already exist in database - return "Record already exist"; - } else { - - EPUser oldUser = (EPUser) list.get(0); - oldUser.setFirstName(newUser.getFirstName()); - oldUser.setLastName(newUser.getLastName()); - oldUser.setMiddleInitial(newUser.getMiddleInitial()); - if (!oldUser.getLoginPwd().equals(newUser.getLoginPwd())) - oldUser.setLoginPwd(CipherUtil.encrypt(newUser.getLoginPwd())); - else - oldUser.setLoginPwd(newUser.getLoginPwd()); - getDataAccessService().saveDomainObject(oldUser, null); - - } - - } - - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "saveNewUser failed", e); - throw new Exception(e); - } - return "success"; - }; - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java deleted file mode 100644 index 4a156a1a..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/transport/OnboardingApp.java +++ /dev/null @@ -1,107 +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.portal.transport; - -public class OnboardingApp { - - public Long id; - - public String name; - - public String imageUrl; - - public String imageLink; - - public String description; - - public String notes; - - public String url; - - public String alternateUrl; - - public String restUrl; - - public Boolean isOpen; - - public Boolean isEnabled; - - public String username; - - public String appPassword; - - public String thumbnail; - - public String uebTopicName; - - public String uebKey; - - public String uebSecret; - - public Boolean restrictedApp; - - public Boolean isCentralAuth; - - public String nameSpace; - - public void normalize() { - this.name = (this.name == null) ? "" : this.name.trim(); - this.username = (this.username == null) ? "" : this.username.trim(); - this.appPassword = (this.appPassword == null) ? "" : this.appPassword.trim(); - } - - public void setUebTopicName(String topicName) { - this.uebTopicName = topicName; - } - - public void setUebKey(String key) { - this.uebKey = key; - } - - public void setUebSecret(String secret) { - this.uebSecret = secret; - } - - // Hide the implementation of restricted and normal app from the front end. - // The json sent and received will include restrictedApp but not appType. - - public void setRestrictedApp(Boolean restrictedApp) { - this.restrictedApp = restrictedApp; - } -} - diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java deleted file mode 100644 index 81b1c495..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebHelper.java +++ /dev/null @@ -1,221 +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.portal.ueb; - -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.LinkedList; -import java.util.List; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.openecomp.portalapp.portal.domain.EPApp; -import org.openecomp.portalapp.portal.domain.EcompApp; -import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; -import org.openecomp.portalapp.portal.logging.format.EPAppMessagesEnum; -import org.openecomp.portalapp.portal.logging.logic.EPLogUtil; -import org.openecomp.portalapp.portal.service.EPAppService; -import org.openecomp.portalapp.portal.utils.EcompPortalUtils; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.ueb.Helper; -import org.openecomp.portalsdk.core.onboarding.ueb.Publisher; -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.onboarding.util.PortalApiConstants; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -@Component -@Transactional -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -public class EPUebHelper { - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUebHelper.class); - - @Autowired - EPAppService appsService; - - @Autowired - private SessionFactory sessionFactory; - - @SuppressWarnings("unused") - private Publisher epPublisher; - - public EPUebHelper() { - - } - - // - // This should only be called by the ECOMP Portal App, other Apps have just one - // publisher and use appPublisher - // - @SuppressWarnings("unused") - @EPMetricsLog - public void refreshPublisherList() { - Session localSession = null; - boolean addedPublisher = false; - - try { - localSession = sessionFactory.openSession(); - - List<EcompApp> apps = appsService.getEcompAppAppsFullList(); - for (int i = 0; i < apps.size(); i++) { - if ((apps.get(i).isEnabled()) && (apps.get(i).getUebTopicName() != null) - && !(apps.get(i).getUebTopicName().toUpperCase().contains("ECOMP-PORTAL-INBOX"))) { - logger.debug(EELFLoggerDelegate.debugLogger, - "UEBManager adding publisher for " + apps.get(i).getUebTopicName()); - UebManager.getInstance().addPublisher(apps.get(i).getUebTopicName()); - addedPublisher = true; - } else if ((apps.get(i).getId() != 1) && // App may have been disabled, remove the publisher - !(apps.get(i).isEnabled())) { - if (apps.get(i).getUebTopicName() != null) { - UebManager.getInstance().removePublisher(apps.get(i).getUebTopicName()); - } - } - } - } catch (Exception e) { - EPLogUtil.logEcompError(EPAppMessagesEnum.BeUebSystemError, "add/remove Publisher"); - logger.error(EELFLoggerDelegate.errorLogger, "refreshPublisherList failed", e); - } - - // publisherList.print(); - - if (addedPublisher == true) // Give publishers time to initialize - { - Helper.sleep(400); - } - } - - // @PostConstruct - // @EPMetricsLog - public void initUeb() { - try { - epPublisher = new Publisher(PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY), - PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_SECRET), - PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME)); - } catch (Exception e) { - EPLogUtil.logEcompError(EPAppMessagesEnum.BeUebConnectionError, e.getMessage()); - logger.error(EELFLoggerDelegate.errorLogger, "initUeb failed", e); - } - - Thread thread = new Thread("EPUebManager: postConstructMethod - refreshPublisherList") { - public void run() { - refreshPublisherList(); - } - }; - if (thread != null) { - thread.start(); - } - } - - @EPMetricsLog - public void addPublisher(EPApp app) { - // TODO Auto-generated method stub - try { - UebManager.getInstance().addPublisher(app.getUebTopicName()); - } catch (UebException e) { - logger.error(EELFLoggerDelegate.errorLogger, "addPublisher failed", e); - } - } - - public boolean checkAvailability() { - - // - // Test existence of topic at UEB url - // - // - // - boolean available = true; - LinkedList<String> urlList = Helper.uebUrlList(); - if (!urlList.isEmpty()) { - String url = "http://" + urlList.getFirst() + ":3904/topics/" - + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME); - if (!url.isEmpty()) { - try { - URL siteURL = new URL(url); - HttpURLConnection connection = (HttpURLConnection) siteURL.openConnection(); - connection.setRequestMethod("GET"); - connection.connect(); - - int code = connection.getResponseCode(); - if (code == 200) { - available = true; - } else { - EPLogUtil.logEcompError(EPAppMessagesEnum.BeUebConnectionError, url); - available = false; - logger.warn(EELFLoggerDelegate.errorLogger, - "Warning! UEB topic existence check failed, topic = " + url); - logger.debug(EELFLoggerDelegate.debugLogger, - "Warning! UEB topic existence check failed, topic = " + url); - } - } catch (Exception e) { - available = false; - logger.error(EELFLoggerDelegate.errorLogger, "checkAvailability failed", e); - } - } - } - return available; - } - - public boolean MessageCanBeSentToTopic() { - - boolean sentMsgSuccessfully = false; - - UebMsg msg = new UebMsg(); - msg.putSourceTopicName(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME)); - msg.putPayload("Pinging topic for health check"); - msg.putMsgType(EPUebMsgTypes.UEB_MSG_TYPE_HEALTH_CHECK); - - try { - // epPublisher.send(msg); - sentMsgSuccessfully = true; - } catch (Exception e) { - EPLogUtil.logEcompError(EPAppMessagesEnum.BeHealthCheckUebClusterError); - sentMsgSuccessfully = false; - logger.warn(EELFLoggerDelegate.errorLogger, "Warning! could not successfully publish a UEB msg to " - + PortalApiProperties.getProperty(PortalApiConstants.ECOMP_PORTAL_INBOX_NAME), e); - } - - return sentMsgSuccessfully; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java deleted file mode 100644 index 720e0615..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/ueb/EPUebMsgTypes.java +++ /dev/null @@ -1,45 +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.portal.ueb; - -import org.openecomp.portalsdk.core.onboarding.ueb.UebMsgTypes; - -public interface EPUebMsgTypes extends UebMsgTypes { - - public static final String UEB_MSG_TYPE_HEALTH_CHECK = "uebHealthCheckPing"; -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.java deleted file mode 100644 index e8772677..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/utils/EPSystemProperties.java +++ /dev/null @@ -1,60 +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.portal.utils; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.PropertySources; - -@Configuration -@PropertySources({ - @PropertySource ("/WEB-INF/conf/system.properties"), - @PropertySource ("/WEB-INF/conf/sql.properties"), - @PropertySource ("/WEB-INF/fusion/conf/fusion.properties"), - @PropertySource (value = "file:${catalina.home}/conf/system.properties", ignoreResourceNotFound = true), - @PropertySource (value = "file:${catalina.home}/conf/fusion.properties", ignoreResourceNotFound = true) - }) - -/** - * Contains properties specific to the ONAP version of the ECOMP Portal. - */ -public class EPSystemProperties extends EPCommonSystemProperties { - public static final String CONTACT_US_URL = "contact_us_link"; - public static final String ECOMP_CONTEXT_ROOT = "context_root"; - -}
\ No newline at end of file diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java deleted file mode 100644 index 63b44027..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogJob.java +++ /dev/null @@ -1,63 +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.scheduler; - -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.quartz.DisallowConcurrentExecution; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.PersistJobDataAfterExecution; -import org.springframework.scheduling.quartz.QuartzJobBean; - -@PersistJobDataAfterExecution -@DisallowConcurrentExecution -public class LogJob extends QuartzJobBean { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LogJob.class); - - @Override - protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException { - // JobDataMap dataMap = ctx.getJobDetail().getJobDataMap(); - // int cnt = dataMap.getInt(""); - // JobKey jobKey = ctx.getJobDetail().getKey(); - logger.info(EELFLoggerDelegate.debugLogger, - (Runtime.getRuntime().maxMemory() + " " + Runtime.getRuntime().maxMemory())); - - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java deleted file mode 100644 index f502a564..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/LogRegistry.java +++ /dev/null @@ -1,75 +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.scheduler; - -import java.text.ParseException; -import java.util.HashMap; -import java.util.Map; - -import org.openecomp.portalsdk.core.scheduler.CronRegistry; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.context.annotation.DependsOn; -import org.springframework.scheduling.quartz.CronTriggerFactoryBean; -import org.springframework.scheduling.quartz.JobDetailFactoryBean; -import org.springframework.stereotype.Component; - -@Component -@DependsOn({ "systemProperties" }) -public class LogRegistry extends CronRegistry { - - private static final String groupName = "AppGroup"; - private static final String jobName = "LogJob"; - private static final String triggerName = "LogTrigger"; - - // @Autowired - // private SystemProperties systemProperties; - - // @Bean - public JobDetailFactoryBean jobDetailFactoryBean() { - Map<String, Object> map = new HashMap<String, Object>(); - map.put("units", "bytes"); - return jobDetailFactoryBean(groupName, jobName, LogJob.class, map); - } - - // @Bean - public CronTriggerFactoryBean cronTriggerFactoryBean() throws ParseException { - // "0 * * * * ? * - return cronTriggerFactoryBean(groupName, triggerName, SystemProperties.getProperty(SystemProperties.LOG_CRON)); - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/Register.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/Register.java deleted file mode 100644 index 00eb7b69..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/Register.java +++ /dev/null @@ -1,103 +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.scheduler; - -import java.util.ArrayList; -import java.util.List; - -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.scheduler.Registerable; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.quartz.Trigger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.DependsOn; -import org.springframework.stereotype.Component; - -@Component -@DependsOn({"logRegistry", "sessionMgtRegistry", "systemProperties"}) -public class Register implements Registerable { - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Register.class); - - private List<Trigger> scheduleTriggers = new ArrayList<Trigger>(); - Trigger trigger[] = new Trigger[0]; - - @Autowired - private LogRegistry logRegistry; - - @Autowired - private SessionMgtRegistry sessionMgtRegistry; - - @Override - public Trigger[] getTriggers() { - return getScheduleTriggers().toArray(trigger); - } - - @Override - public void registerTriggers() { - // if the property value is not available; the cron will not be added - // and can be ignored. its safe to ignore the exceptions - try { - if (SystemProperties.getProperty(SystemProperties.LOG_CRON) != null) - getScheduleTriggers().add(logRegistry.getTrigger()); - - } catch (IllegalStateException ies) { - logger.error(EELFLoggerDelegate.errorLogger, "registerTriggers log cron failed", ies); - logger.info(EELFLoggerDelegate.debugLogger, ("Log Cron not available")); - } - - try { - if(SystemProperties.getProperty(SystemProperties.SESSIONTIMEOUT_FEED_CRON) != null) - getScheduleTriggers().add(sessionMgtRegistry.getTrigger()); - - } catch(IllegalStateException ies) { - logger.error(EELFLoggerDelegate.errorLogger, "registerTriggers session timeout failed", ies); - logger.info(EELFLoggerDelegate.debugLogger, ("Session Cron not available")); - } - - } - - public List<Trigger> getScheduleTriggers() { - return scheduleTriggers; - } - - public void setScheduleTriggers(List<Trigger> scheduleTriggers) { - this.scheduleTriggers = scheduleTriggers; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.java deleted file mode 100644 index 542b0d88..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/RegistryAdapter.java +++ /dev/null @@ -1,118 +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.scheduler; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.openecomp.portalsdk.core.scheduler.Registerable; -import org.openecomp.portalsdk.workflow.services.WorkflowScheduleService; -import org.quartz.Trigger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.stereotype.Component; - -/** - * TODO REFACTOR moved from org.openecomp.portalsdk.core.scheduler to - * org.openecomp.portalapp.scheduler - * - */ -@Component -public class RegistryAdapter { - - @Autowired - private Registerable registry; - - @Autowired - private WorkflowScheduleService workflowScheduleService; - - private SchedulerFactoryBean schedulerBean; - - Trigger trigger[] = new Trigger[0]; - - public Trigger[] getTriggers() { - - registry.registerTriggers(); - - List<Trigger> allTriggers = new ArrayList<Trigger>(); - - List<Trigger> coreTriggers = addCoreTriggers(); - final Trigger[] extTriggerArray = registry.getTriggers(); - - allTriggers.addAll(Arrays.asList(extTriggerArray)); - allTriggers.addAll(coreTriggers); - - return allTriggers.toArray(trigger); - - } - - public List<Trigger> addCoreTriggers() { - // On startup of the application after crash recovery, invoke workflow - // schedule trigger - List<Trigger> triggers = getWorkflowScheduleService().triggerWorkflowScheduling(); - return triggers; - } - - public void setSchedulerBean(SchedulerFactoryBean _schedulerBean) { - schedulerBean = _schedulerBean; - - } - - public SchedulerFactoryBean getSchedulerBean() { - return schedulerBean; - - } - - public Registerable getRegistry() { - return registry; - } - - public void setRegistry(Registerable registry) { - this.registry = registry; - } - - public WorkflowScheduleService getWorkflowScheduleService() { - return workflowScheduleService; - } - - public void setWorkflowScheduleService(WorkflowScheduleService workflowScheduleService) { - this.workflowScheduleService = workflowScheduleService; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.java deleted file mode 100644 index c18b4b35..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/scheduler/SessionMgtRegistry.java +++ /dev/null @@ -1,105 +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.scheduler; - -import java.text.ParseException; -import java.util.HashMap; -import java.util.Map; - -import org.openecomp.portalapp.portal.listener.UserSessionListener; -import org.openecomp.portalapp.service.sessionmgt.TimeoutHandler; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.scheduler.CronRegistry; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.annotation.DependsOn; -import org.springframework.scheduling.quartz.CronTriggerFactoryBean; -import org.springframework.scheduling.quartz.JobDetailFactoryBean; -import org.springframework.stereotype.Component; - -/** - * Extra depends-on annotation tells Spring that the system properties object - * will be used in the constructor. - */ -@Component -// @DependsOn({ "manageService", "epAppService", "systemProperties" }) -@DependsOn({ "systemProperties" }) -public class SessionMgtRegistry extends CronRegistry implements ApplicationContextAware { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionMgtRegistry.class); - - private static final String groupName = "AppGroup"; - private static final String jobName = "PortalSessionTimeoutFeedJob"; - private static final String triggerName = "PortalSessionTimeoutFeedTrigger"; - - // Not strictly necessary, but preparing for the day - // when the getProperty method is not static. - @Autowired - private SystemProperties systemProperties; - - private ApplicationContext applicationContext; - - public JobDetailFactoryBean jobDetailFactoryBean() { - Map<String, Object> map = new HashMap<String, Object>(); - return jobDetailFactoryBean(groupName, jobName, TimeoutHandler.class, map); - } - - @SuppressWarnings("static-access") - public CronTriggerFactoryBean cronTriggerFactoryBean() throws ParseException { - String property = "* * * * * ? 2099"; - try { - property = systemProperties.getProperty(SystemProperties.SESSIONTIMEOUT_FEED_CRON); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, - "Failed to retrieve " + SystemProperties.SESSIONTIMEOUT_FEED_CRON + ", defaulting to " + property, - e); - } - return cronTriggerFactoryBean(groupName, triggerName, property); - } - - @Override - public void setApplicationContext(ApplicationContext _applicationContext) throws BeansException { - applicationContext = _applicationContext; - TimeoutHandler.setApplicationContext(applicationContext); - UserSessionListener.setApplicationContext(_applicationContext); - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallServiceImpl.java deleted file mode 100644 index 0b10caf6..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/service/RemoteWebServiceCallServiceImpl.java +++ /dev/null @@ -1,118 +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.service; - -import java.util.List; - -import org.openecomp.portalapp.portal.domain.EPApp; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; -import org.openecomp.portalsdk.core.service.WebServiceCallServiceImpl; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service("remoteWebServiceCallService") -@Transactional -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -public class RemoteWebServiceCallServiceImpl extends WebServiceCallServiceImpl implements RemoteWebServiceCallService { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RemoteWebServiceCallServiceImpl.class); - - /* - * (non-Javadoc) - * @see org.openecomp.portalapp.service.sessionmgt.RemoteWebServiceCallService#verifyRESTCredential(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - public boolean verifyRESTCredential(String secretKey, String requestUebKey, String requestAppName, - String requestPassword) throws Exception { - EPApp appRecord = findEpApp(requestUebKey); - if (appRecord == null) { - logger.warn(EELFLoggerDelegate.errorLogger, "Failed to find application with UEB key " + requestUebKey); - return false; - } - - String encryptedPwdDB = appRecord.getAppPassword(); - String appUserName = appRecord.getUsername(); - String decryptedPwd = CipherUtil.decrypt(encryptedPwdDB, - secretKey == null ? SystemProperties.getProperty(SystemProperties.Decryption_Key) : secretKey); - if (decryptedPwd.equals(requestPassword) && appUserName.equals(requestAppName)) - return true; - else - return false; - } - - /** - * currently this method only validates the application key to fetch the application - */ - public boolean verifyAppKeyCredential(String requestUebKey) throws Exception { - String failMessage = "Failed to find application with UEB key " + requestUebKey; - if(requestUebKey == null || requestUebKey.equals("")) { - logger.warn(EELFLoggerDelegate.errorLogger, failMessage); - return false; - } - - EPApp appRecord = findEpApp(requestUebKey); - if (appRecord == null) { - logger.warn(EELFLoggerDelegate.errorLogger, failMessage); - return false; - } - - return true; - } - - /** - * Searches the FN_APP table for the specified UEB key. - * - * @return EPApp object if the key is found; else null. - */ - public EPApp findEpApp(String uebKey) { - List<?> list = null; - StringBuffer criteria = new StringBuffer(); - criteria.append(" where ueb_key = '" + uebKey + "'"); - list = getDataAccessService().getList(EPApp.class, criteria.toString(), null, null); - return (list == null || list.size() == 0) ? null : (EPApp) list.get(0); - } - - public static void main(String args[]) throws Exception { - String decryptedPwd = CipherUtil.decrypt("okYTaDrhzibcbGVq5mjkVQ==", "AGLDdG4D04BKm2IxIWEr8o=="); - System.out.print(decryptedPwd); - } - -} 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"); - } - } - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java deleted file mode 100644 index 7ae34aed..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/util/SessionCookieUtil.java +++ /dev/null @@ -1,146 +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.util; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties; -import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler; -import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; -import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; -import org.openecomp.portalsdk.core.util.SystemProperties; -import org.openecomp.portalsdk.core.web.support.AppUtils; - -public class SessionCookieUtil { - - //private static final String JSESSIONID = "JSESSIONID"; - private static final String EP_SERVICE = "EPService"; - private static final String USER_ID = "UserId"; - private static Integer cookieMaxAge = -1; - private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionCookieUtil.class); - - public static void preSetUp(HttpServletRequest request, - HttpServletResponse response) { - initateSessionMgtHandler(request); - //set up EPService cookie - setUpEPServiceCookie(request, response); - } - - public static void setUpEPServiceCookie(HttpServletRequest request, - HttpServletResponse response) { - String jSessionId = getJessionId(request); - Cookie cookie1 = new Cookie(EP_SERVICE, jSessionId); - cookie1.setMaxAge(cookieMaxAge); - cookie1.setDomain(EPCommonSystemProperties.getProperty(EPCommonSystemProperties.COOKIE_DOMAIN)); - cookie1.setPath("/"); - response.addCookie(cookie1); - } - - public static void setUpUserIdCookie(HttpServletRequest request, - HttpServletResponse response,String userId) throws Exception { - logger.info("************** session cookie util set up UserId cookie begins"); - userId = CipherUtil.encrypt(userId, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); - Cookie cookie1 = new Cookie(USER_ID, userId); - cookie1.setMaxAge(cookieMaxAge); - cookie1.setDomain(EPCommonSystemProperties.getProperty(EPCommonSystemProperties.COOKIE_DOMAIN)); - cookie1.setPath("/"); - response.addCookie(cookie1); - logger.info("************** session cookie util set up EP cookie completed"); - } - - public static String getUserIdFromCookie(HttpServletRequest request, - HttpServletResponse response) throws Exception { - String userId = ""; - Cookie[] cookies = request.getCookies(); - Cookie userIdcookie = null; - if (cookies != null) - for (Cookie cookie : cookies) - if (cookie.getName().equals(USER_ID)) - userIdcookie = cookie; - if(userIdcookie!=null){ - userId = CipherUtil.decrypt(userIdcookie.getValue(), - SystemProperties.getProperty(SystemProperties.Decryption_Key)); - } - - logger.info("************** session cookie util set up EP cookie completed"); - return userId; - } - - public static String getJessionId(HttpServletRequest request){ - - return request.getSession().getId(); - /* - Cookie ep = WebUtils.getCookie(request, JSESSIONID); - if(ep==null){ - return request.getSession().getId(); - } - return ep.getValue(); - */ - } - - protected static void initateSessionMgtHandler(HttpServletRequest request) { - String jSessionId = getJessionId(request); - storeMaxInactiveTime(request); - PortalTimeoutHandler.sessionCreated(jSessionId, jSessionId, AppUtils.getSession(request)); - } - - protected static void storeMaxInactiveTime(HttpServletRequest request) { - HttpSession session = AppUtils.getSession(request); - if(session.getAttribute(PortalApiConstants.GLOBAL_SESSION_MAX_IDLE_TIME) == null) - session.setAttribute(PortalApiConstants.GLOBAL_SESSION_MAX_IDLE_TIME,session.getMaxInactiveInterval()); - } - - public static void resetSessionMaxIdleTimeOut(HttpServletRequest request) { - try { - HttpSession session = AppUtils.getSession(request); - final Object maxIdleAttribute = session.getAttribute(PortalApiConstants.GLOBAL_SESSION_MAX_IDLE_TIME); - if(session != null && maxIdleAttribute != null) { - session.setMaxInactiveInterval(Integer.parseInt(maxIdleAttribute.toString())); - } - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "resetSessionMaxIdleTimeOut failed", e); - } - - } - -} |