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;
22 import javax.servlet.http.Cookie;
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletResponse;
26 import org.openecomp.portalapp.portal.domain.EPUser;
27 import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
28 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
29 import org.openecomp.portalapp.portal.utils.EPSystemProperties;
30 import org.openecomp.portalapp.util.EPUserUtils;
31 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
32 import org.springframework.context.annotation.EnableAspectJAutoProxy;
33 import org.springframework.stereotype.Controller;
34 import org.springframework.web.bind.annotation.RequestMapping;
35 import org.springframework.web.bind.annotation.RequestMethod;
36 import org.springframework.web.context.request.RequestContextHolder;
37 import org.springframework.web.context.request.ServletRequestAttributes;
38 import org.springframework.web.servlet.ModelAndView;
42 @org.springframework.context.annotation.Configuration
43 @EnableAspectJAutoProxy
44 public class ECOMPLogoutController extends EPUnRestrictedBaseController{
47 private static final String EP_SERVICE = "EPService";
48 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECOMPLogoutController.class);
51 @RequestMapping(value = {"/logout.htm" }, method = RequestMethod.GET)
52 public ModelAndView logOut(HttpServletRequest request,
53 HttpServletResponse response) throws Exception {
55 ModelAndView modelView = null;
57 chatRoomLogout(request);
58 logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Logout request received.");
60 modelView = new ModelAndView("redirect:login.htm");
63 if (UserUtils.isClientMobileDevice(request)){
64 modelView.setViewName(modelView.getViewName().concat("?viewType=mobile"));
67 String cookieDoamin = EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN);
68 Cookie epCookie = new Cookie(EP_SERVICE, "");
69 epCookie.setMaxAge(0);
70 epCookie.setDomain(cookieDoamin);
71 epCookie.setPath("/");
73 Cookie appHeaderCookie = new Cookie("show_app_header", "");
74 appHeaderCookie.setMaxAge(0);
75 appHeaderCookie.setDomain(cookieDoamin);
76 appHeaderCookie.setPath("/");
78 Cookie appTabCookie = new Cookie("cookieTabs", "");
79 appTabCookie.setMaxAge(0);
80 appTabCookie.setDomain(cookieDoamin);
81 appTabCookie.setPath("/");
83 Cookie appVisInvisTabCookie = new Cookie("visInVisCookieTabs", "");
84 appVisInvisTabCookie.setMaxAge(0);
85 appVisInvisTabCookie.setDomain(cookieDoamin);
86 appVisInvisTabCookie.setPath("/");
88 response.addCookie(epCookie);
89 response.addCookie(appHeaderCookie);
90 response.addCookie(appTabCookie);
91 response.addCookie(appVisInvisTabCookie);
92 request.getSession().invalidate();
94 logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Successfully processed the logout request.");
100 public void chatRoomLogout(HttpServletRequest request){
101 request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
102 setUser(EPUserUtils.getUserSession(request));
105 public EPUser getUser() {
109 public void setUser(EPUser user) {