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,
80 "ECOMPLogoutController.handleRequestInternal - Logout request received.");
82 modelView = new ModelAndView("redirect:login.htm");
85 * if (UserUtils.isClientMobileDevice(request)){
86 * modelView.setViewName(modelView.getViewName().concat("?viewType=mobile")); }
88 String cookieDoamin = EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN);
89 Cookie epCookie = new Cookie(EP_SERVICE, "");
90 epCookie.setSecure(true);
91 epCookie.setMaxAge(0);
92 epCookie.setDomain(cookieDoamin);
93 epCookie.setPath("/");
95 Cookie appHeaderCookie = new Cookie("show_app_header", "");
96 appHeaderCookie.setSecure(true);
97 appHeaderCookie.setMaxAge(0);
98 appHeaderCookie.setDomain(cookieDoamin);
99 appHeaderCookie.setPath("/");
101 Cookie appTabCookie = new Cookie("cookieTabs", "");
102 appTabCookie.setSecure(true);
103 appTabCookie.setMaxAge(0);
104 appTabCookie.setDomain(cookieDoamin);
105 appTabCookie.setPath("/");
107 Cookie appVisInvisTabCookie = new Cookie("visInVisCookieTabs", "");
108 appVisInvisTabCookie.setSecure(true);
109 appVisInvisTabCookie.setMaxAge(0);
110 appVisInvisTabCookie.setDomain(cookieDoamin);
111 appVisInvisTabCookie.setPath("/");
113 response.addCookie(epCookie);
114 response.addCookie(appHeaderCookie);
115 response.addCookie(appTabCookie);
116 response.addCookie(appVisInvisTabCookie);
117 request.getSession().invalidate();
119 logger.debug(EELFLoggerDelegate.debugLogger,
120 "ECOMPLogoutController.handleRequestInternal - Successfully processed the logout request.");
126 public void chatRoomLogout(HttpServletRequest request) {
127 request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
128 setUser(EPUserUtils.getUserSession(request));
131 public EPUser getUser() {
135 public void setUser(EPUser user) {