1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts.apps.mailreader.actions;
23
24 import jakarta.servlet.http.HttpServletRequest;
25 import jakarta.servlet.http.HttpServletResponse;
26 import jakarta.servlet.http.HttpSession;
27
28 import org.apache.struts.action.ActionForm;
29 import org.apache.struts.action.ActionForward;
30 import org.apache.struts.action.ActionMapping;
31 import org.apache.struts.apps.mailreader.Constants;
32 import org.apache.struts.apps.mailreader.dao.User;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
35
36
37
38
39
40
41
42
43 public final class LogoffAction extends BaseAction {
44 private static final long serialVersionUID = -5919029695025512650L;
45
46
47
48
49 private final static Logger LOG =
50 LoggerFactory.getLogger(LogoffAction.class);
51
52
53 public ActionForward execute(
54 ActionMapping mapping,
55 ActionForm form,
56 HttpServletRequest request,
57 HttpServletResponse response)
58 throws Exception {
59
60
61 HttpSession session = request.getSession();
62 User user = doGetUser(session);
63 if (user != null) {
64 LOG.debug("LogoffAction: User '{}' logged off in session {}",
65 user.getUsername(), session.getId());
66 } else {
67 LOG.debug("LogoffActon: User logged off in session {}",
68 session.getId());
69 }
70
71
72 session.removeAttribute(Constants.SUBSCRIPTION_KEY);
73 session.removeAttribute(Constants.USER_KEY);
74 session.invalidate();
75
76
77 return doFindSuccess(mapping);
78
79 }
80 }