]> WPIA git - gigi.git/blob - src/org/cacert/gigi/pages/main/RegisterPage.java
Merge branch 'libs/jetty/upstream' into libs/jetty/local
[gigi.git] / src / org / cacert / gigi / pages / main / RegisterPage.java
1 package org.cacert.gigi.pages.main;
2
3 import java.io.IOException;
4 import java.io.PrintWriter;
5 import java.util.HashMap;
6
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9 import javax.servlet.http.HttpSession;
10
11 import org.cacert.gigi.pages.Page;
12
13 public class RegisterPage extends Page {
14
15         private static final String SIGNUP_PROCESS = "signupProcess";
16         public static final String PATH = "/register";
17
18         public RegisterPage() {
19                 super("Register");
20         }
21
22         @Override
23         public void doGet(HttpServletRequest req, HttpServletResponse resp)
24                         throws IOException {
25                 PrintWriter out = resp.getWriter();
26                 HashMap<String, Object> vars = new HashMap<String, Object>();
27                 getDefaultTemplate().output(out, getLanguage(req), vars);
28                 Signup s = getForm(req);
29                 s.output(out, getLanguage(req), vars);
30         }
31         public Signup getForm(HttpServletRequest req) {
32                 HttpSession hs = req.getSession();
33                 Signup s = (Signup) hs.getAttribute(SIGNUP_PROCESS);
34                 if (s == null) {
35                         s = new Signup();
36                         hs.setAttribute(SIGNUP_PROCESS, s);
37                 }
38                 return s;
39
40         }
41         @Override
42         public void doPost(HttpServletRequest req, HttpServletResponse resp)
43                         throws IOException {
44                 Signup s = getForm(req);
45                 if (s.submit(resp.getWriter(), req)) {
46                         HttpSession hs = req.getSession();
47                         hs.setAttribute(SIGNUP_PROCESS, null);
48                         resp.getWriter()
49                                         .println(
50                                                         translate(
51                                                                         req,
52                                                                         "Your information has been submitted"
53                                                                                         + " into our system. You will now be sent an email with a web link,"
54                                                                                         + " you need to open that link in your web browser within 24 hours"
55                                                                                         + " or your information will be removed from our system!"));
56                         return;
57                 }
58
59                 super.doPost(req, resp);
60         }
61         @Override
62         public boolean needsLogin() {
63                 return false;
64         }
65 }