1
2
3
4 package org.sourceforge.vlibrary.security.actions;
5
6 import java.util.ArrayList;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9 import javax.servlet.http.HttpSession;
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionForward;
12 import org.apache.struts.action.ActionMapping;
13 import org.apache.struts.util.MessageResources;
14 import org.apache.log4j.Logger;
15 import org.sourceforge.vlibrary.exceptions.LibraryException;
16 import org.sourceforge.vlibrary.user.actions.LibraryAction;
17
18
19
20
21
22
23
24 public class LogoffAction extends LibraryAction {
25
26 private static Logger logger =
27 Logger.getLogger(LogoffAction.class.getName());
28
29
30
31
32
33
34
35
36
37
38
39 public ActionForward executeAction(ActionMapping mapping, ActionForm form,
40 HttpServletRequest request, HttpServletResponse response,
41 MessageResources messages) throws Exception {
42
43 ArrayList errors = new ArrayList();
44
45 try {
46 HttpSession session = request.getSession();
47
48 session.invalidate();
49
50 if (logger.isInfoEnabled()) {
51 logger.info(messages.getMessage("logout", request
52 .getRemoteUser()));
53 }
54 } catch (Throwable t) {
55 String errString = messages.getMessage("error.logoff");
56 logger.error(errString, t);
57 errors.add(new LibraryException(errString, t));
58 }
59
60 return standardForward(mapping, request, errors);
61 }
62 }