2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
23 package com.liferay.portal.action;
\r
25 import javax.servlet.http.Cookie;
\r
26 import javax.servlet.http.HttpServletRequest;
\r
27 import javax.servlet.http.HttpServletResponse;
\r
28 import javax.servlet.http.HttpSession;
\r
30 import org.apache.struts.action.Action;
\r
31 import org.apache.struts.action.ActionForm;
\r
32 import org.apache.struts.action.ActionForward;
\r
33 import org.apache.struts.action.ActionMapping;
\r
35 //import com.liferay.client.json.ruon.util.RUONUtil;
\r
36 import com.liferay.portal.events.EventsProcessorUtil;
\r
37 import com.liferay.portal.kernel.util.PropsKeys;
\r
38 import com.liferay.portal.kernel.util.StringPool;
\r
39 import com.liferay.portal.kernel.util.Validator;
\r
40 //import com.liferay.portal.model.User;
\r
41 import com.liferay.portal.struts.ActionConstants;
\r
42 import com.liferay.portal.util.CookieKeys;
\r
43 import com.liferay.portal.util.PortalUtil;
\r
44 import com.liferay.portal.util.PropsValues;
\r
46 * <a href="LogoutAction.java.html"><b><i>View Source</i></b></a>
\r
48 * @author Brian Wing Shun Chan
\r
51 public class LogoutAction extends Action {
\r
53 public ActionForward execute(
\r
54 ActionMapping mapping, ActionForm form, HttpServletRequest request,
\r
55 HttpServletResponse response)
\r
59 HttpSession session = request.getSession();
\r
61 //User user = PortalUtil.getUser(request);
\r
63 //RUONUtil.updatePresence(user.getUserId(), "chat-portlet", false);
\r
65 EventsProcessorUtil.process(
\r
66 PropsKeys.LOGOUT_EVENTS_PRE, PropsValues.LOGOUT_EVENTS_PRE,
\r
69 String domain = CookieKeys.getDomain(request);
\r
71 Cookie companyIdCookie = new Cookie(
\r
72 CookieKeys.COMPANY_ID, StringPool.BLANK);
\r
74 if (Validator.isNotNull(domain)) {
\r
75 companyIdCookie.setDomain(domain);
\r
78 companyIdCookie.setMaxAge(0);
\r
79 companyIdCookie.setPath(StringPool.SLASH);
\r
81 Cookie idCookie = new Cookie(CookieKeys.ID, StringPool.BLANK);
\r
83 if (Validator.isNotNull(domain)) {
\r
84 idCookie.setDomain(domain);
\r
87 idCookie.setMaxAge(0);
\r
88 idCookie.setPath(StringPool.SLASH);
\r
90 Cookie passwordCookie = new Cookie(
\r
91 CookieKeys.PASSWORD, StringPool.BLANK);
\r
93 if (Validator.isNotNull(domain)) {
\r
94 passwordCookie.setDomain(domain);
\r
97 passwordCookie.setMaxAge(0);
\r
98 passwordCookie.setPath(StringPool.SLASH);
\r
100 CookieKeys.addCookie(request, response, companyIdCookie);
\r
101 CookieKeys.addCookie(request, response, idCookie);
\r
102 CookieKeys.addCookie(request, response, passwordCookie);
\r
105 session.invalidate();
\r
107 catch (Exception e) {
\r
110 EventsProcessorUtil.process(
\r
111 PropsKeys.LOGOUT_EVENTS_POST, PropsValues.LOGOUT_EVENTS_POST,
\r
112 request, response);
\r
114 return mapping.findForward(ActionConstants.COMMON_REFERER);
\r
116 catch (Exception e) {
\r
117 PortalUtil.sendError(e, request, response);
\r