2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 package org.onap.portalapp.controller;
40 import javax.servlet.http.Cookie;
41 import javax.servlet.http.HttpServletRequest;
42 import javax.servlet.http.HttpServletResponse;
44 import org.onap.portalapp.controller.EPUnRestrictedBaseController;
45 import org.onap.portalapp.portal.domain.EPUser;
46 import org.onap.portalapp.portal.logging.aop.EPAuditLog;
47 import org.onap.portalapp.portal.logging.aop.EPMetricsLog;
48 import org.onap.portalapp.portal.utils.EPSystemProperties;
49 import org.onap.portalapp.util.EPUserUtils;
50 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
51 import org.springframework.context.annotation.EnableAspectJAutoProxy;
52 import org.springframework.context.annotation.Profile;
53 import org.springframework.stereotype.Controller;
54 import org.springframework.web.bind.annotation.RequestMapping;
55 import org.springframework.web.bind.annotation.RequestMethod;
56 import org.springframework.web.context.request.RequestContextHolder;
57 import org.springframework.web.context.request.ServletRequestAttributes;
58 import org.springframework.web.servlet.ModelAndView;
62 @org.springframework.context.annotation.Configuration
63 @EnableAspectJAutoProxy
65 public class ECOMPLogoutController extends EPUnRestrictedBaseController{
68 private static final String EP_SERVICE = "EPService";
69 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECOMPLogoutController.class);
72 @RequestMapping(value = {"/logout.htm" }, method = RequestMethod.GET)
73 public ModelAndView logOut(HttpServletRequest request,
74 HttpServletResponse response) throws Exception {
76 ModelAndView modelView = null;
78 chatRoomLogout(request);
79 logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Logout request received.");
81 modelView = new ModelAndView("redirect:login.htm");
84 if (UserUtils.isClientMobileDevice(request)){
85 modelView.setViewName(modelView.getViewName().concat("?viewType=mobile"));
88 String cookieDoamin = EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN);
89 Cookie epCookie = new Cookie(EP_SERVICE, "");
90 epCookie.setMaxAge(0);
91 epCookie.setDomain(cookieDoamin);
92 epCookie.setPath("/");
94 Cookie appHeaderCookie = new Cookie("show_app_header", "");
95 appHeaderCookie.setMaxAge(0);
96 appHeaderCookie.setDomain(cookieDoamin);
97 appHeaderCookie.setPath("/");
99 Cookie appTabCookie = new Cookie("cookieTabs", "");
100 appTabCookie.setMaxAge(0);
101 appTabCookie.setDomain(cookieDoamin);
102 appTabCookie.setPath("/");
104 Cookie appVisInvisTabCookie = new Cookie("visInVisCookieTabs", "");
105 appVisInvisTabCookie.setMaxAge(0);
106 appVisInvisTabCookie.setDomain(cookieDoamin);
107 appVisInvisTabCookie.setPath("/");
109 response.addCookie(epCookie);
110 response.addCookie(appHeaderCookie);
111 response.addCookie(appTabCookie);
112 response.addCookie(appVisInvisTabCookie);
113 request.getSession().invalidate();
115 logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Successfully processed the logout request.");
121 public void chatRoomLogout(HttpServletRequest request){
122 request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
123 setUser(EPUserUtils.getUserSession(request));
126 public EPUser getUser() {
130 public void setUser(EPUser user) {