2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalapp.controller.core;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
25 import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
26 import org.openecomp.portalsdk.core.domain.User;
27 import org.openecomp.portalsdk.core.logging.format.AlarmSeverityEnum;
28 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
29 import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
30 import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
31 import org.openecomp.portalsdk.core.web.support.UserUtils;
32 import org.springframework.stereotype.Controller;
33 import org.springframework.web.bind.annotation.RequestMapping;
34 import org.springframework.web.bind.annotation.RequestMethod;
35 import org.springframework.web.context.request.RequestContextHolder;
36 import org.springframework.web.context.request.ServletRequestAttributes;
37 import org.springframework.web.servlet.ModelAndView;
41 public class LogoutController extends UnRestrictedBaseController{
43 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LogoutController.class);
52 * globalLogout will invalid the current application session, then redirects to portal logout
54 @RequestMapping(value = {"/logout.htm" }, method = RequestMethod.GET)
55 public ModelAndView globalLogout(HttpServletRequest request, HttpServletResponse response) {
56 ModelAndView modelView = null;
58 chatRoomLogout(request);
59 request.getSession().invalidate();
60 String portalUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
61 String portalDomain = portalUrl.substring(0, portalUrl.lastIndexOf('/'));
62 String redirectUrl = portalDomain+"/logout.htm";
63 modelView = new ModelAndView("redirect:"+redirectUrl);
65 logger.error(EELFLoggerDelegate.errorLogger, "Logout Error: " + e.getMessage(),AlarmSeverityEnum.MAJOR);
75 * appLogout is a function that will invalid the current session (application logout) and redirects user to Portal.
77 @RequestMapping(value = {"/app_logout.htm" }, method = RequestMethod.GET)
78 public ModelAndView appLogout(HttpServletRequest request, HttpServletResponse response) {
79 ModelAndView modelView = null;
81 chatRoomLogout(request);
82 modelView = new ModelAndView("redirect:"+PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL));
83 UserUtils.clearUserSession(request);
84 request.getSession().invalidate();
86 logger.error(EELFLoggerDelegate.errorLogger, "Application Logout Error: " + e.getMessage(),AlarmSeverityEnum.MAJOR);
92 public void chatRoomLogout(HttpServletRequest request){
93 request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
94 setUser(UserUtils.getUserSession(request));
95 // if(getUser()!=null){
96 // Long login_IdLong = getUser().getId();
97 // String name = getUser().getFirstName();
98 // String login_IdStr = Long.toString(login_IdLong);
100 //UserListName.getInstance().delUserName(name);
101 //UserListID.getInstance().delUserName(login_IdStr);
104 public User getUser() {
108 public void setUser(User user) {