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.context.annotation.Profile;
34 import org.springframework.stereotype.Controller;
35 import org.springframework.web.bind.annotation.RequestMapping;
36 import org.springframework.web.bind.annotation.RequestMethod;
37 import org.springframework.web.context.request.RequestContextHolder;
38 import org.springframework.web.context.request.ServletRequestAttributes;
39 import org.springframework.web.servlet.ModelAndView;
43 @org.springframework.context.annotation.Configuration
44 @EnableAspectJAutoProxy
46 public class ECOMPLogoutController extends EPUnRestrictedBaseController{
49 private static final String EP_SERVICE = "EPService";
50 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECOMPLogoutController.class);
53 @RequestMapping(value = {"/logout.htm" }, method = RequestMethod.GET)
54 public ModelAndView logOut(HttpServletRequest request,
55 HttpServletResponse response) throws Exception {
57 ModelAndView modelView = null;
59 chatRoomLogout(request);
60 logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Logout request received.");
62 modelView = new ModelAndView("redirect:login.htm");
65 if (UserUtils.isClientMobileDevice(request)){
66 modelView.setViewName(modelView.getViewName().concat("?viewType=mobile"));
69 String cookieDoamin = EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN);
70 Cookie epCookie = new Cookie(EP_SERVICE, "");
71 epCookie.setMaxAge(0);
72 epCookie.setDomain(cookieDoamin);
73 epCookie.setPath("/");
75 Cookie appHeaderCookie = new Cookie("show_app_header", "");
76 appHeaderCookie.setMaxAge(0);
77 appHeaderCookie.setDomain(cookieDoamin);
78 appHeaderCookie.setPath("/");
80 Cookie appTabCookie = new Cookie("cookieTabs", "");
81 appTabCookie.setMaxAge(0);
82 appTabCookie.setDomain(cookieDoamin);
83 appTabCookie.setPath("/");
85 Cookie appVisInvisTabCookie = new Cookie("visInVisCookieTabs", "");
86 appVisInvisTabCookie.setMaxAge(0);
87 appVisInvisTabCookie.setDomain(cookieDoamin);
88 appVisInvisTabCookie.setPath("/");
90 response.addCookie(epCookie);
91 response.addCookie(appHeaderCookie);
92 response.addCookie(appTabCookie);
93 response.addCookie(appVisInvisTabCookie);
94 request.getSession().invalidate();
96 logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Successfully processed the logout request.");
102 public void chatRoomLogout(HttpServletRequest request){
103 request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
104 setUser(EPUserUtils.getUserSession(request));
107 public EPUser getUser() {
111 public void setUser(EPUser user) {