]> WPIA git - gigi.git/blob - src/org/cacert/gigi/pages/LogoutPage.java
Move the "dbObject"s to their own package.
[gigi.git] / src / org / cacert / gigi / pages / LogoutPage.java
1 package org.cacert.gigi.pages;
2
3 import java.io.IOException;
4
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
7 import javax.servlet.http.HttpSession;
8
9 import org.cacert.gigi.Gigi;
10 import org.cacert.gigi.dbObjects.User;
11
12 public class LogoutPage extends Page {
13
14     public static final String PATH = "/logout";
15
16     public LogoutPage(String title) {
17         super(title);
18     }
19
20     @Override
21     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
22         HttpSession hs = req.getSession();
23         if (req.getPathInfo() != null && req.getPathInfo().equals("/logout")) {
24             if (hs != null) {
25                 hs.setAttribute(Gigi.LOGGEDIN, null);
26                 hs.invalidate();
27             }
28             resp.sendRedirect("/");
29             return;
30         }
31     }
32
33     @Override
34     public boolean isPermitted(User u) {
35         return u != null;
36     }
37
38 }