Source code: nectar/action/LogoutAction.java
1 /*
2 Copyright (C) 2003 Kai Schutte
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 * LogoutAction.java -- unloads the session.
19 *
20 * Created on March 13, 2003, 2:02 PM
21 */
22
23 package nectar.action;
24
25 import javax.servlet.http.HttpServletRequest;
26 import javax.servlet.http.HttpServletResponse;
27 import javax.servlet.http.HttpSession;
28 import org.apache.struts.action.Action;
29 import org.apache.struts.action.ActionMapping;
30 import org.apache.struts.action.ActionForm;
31 import org.apache.struts.action.ActionForward;
32
33 import nectar.view.UserView;
34 import nectar.form.LoginForm;
35
36 import nectar.configuration.ConfigurationService;
37 import nectar.configuration.Configuration;
38 import nectar.services.AuthenticationConfiguration;
39 import nectar.services.AuthenticationService;
40 import nectar.ServicesUtil;
41 import nectar.record.PersonRecord;
42 /**
43 * This Action is called when a logout attempt is made by the user. It simply invalidates the session.
44 * @author Kai Schutte skander@skander.com
45 */
46 public class LogoutAction extends Action {
47
48 public ActionForward execute( ActionMapping mapping,
49 ActionForm form,
50 HttpServletRequest request,
51 HttpServletResponse response)
52 throws Exception {
53
54 // Invalidate existing session if it exists
55 HttpSession session = request.getSession(false);
56 if(session != null) {
57 session.invalidate();
58 }
59
60 // Store the UserView into the session and return
61 return mapping.findForward("Success");
62 }
63 }