1 package org.cacert.gigi.pages.main;
3 import java.io.IOException;
4 import java.io.PrintWriter;
5 import java.util.HashMap;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9 import javax.servlet.http.HttpSession;
11 import org.cacert.gigi.GigiApiException;
12 import org.cacert.gigi.output.template.Form;
13 import org.cacert.gigi.pages.Page;
14 import org.cacert.gigi.util.AuthorizationContext;
15 import org.cacert.gigi.util.RateLimit;
17 public class RegisterPage extends Page {
19 private static final String SIGNUP_PROCESS = "signupProcess";
21 public static final String PATH = "/register";
24 public static final RateLimit RATE_LIMIT = new RateLimit(50, 5 * 60 * 1000);
26 public RegisterPage() {
31 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
32 Signup s = new Signup(req);
33 outputGet(req, resp, s);
36 private void outputGet(HttpServletRequest req, HttpServletResponse resp, Signup s) throws IOException {
37 PrintWriter out = resp.getWriter();
38 HashMap<String, Object> vars = new HashMap<String, Object>();
39 getDefaultTemplate().output(out, getLanguage(req), vars);
40 s.output(out, getLanguage(req), vars);
44 public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
45 Signup s = Form.getForm(req, Signup.class);
48 HttpSession hs = req.getSession();
49 hs.setAttribute(SIGNUP_PROCESS, null);
50 resp.getWriter().println(translate(req, "Your information has been submitted" + " into our system. You will now be sent an email with a web link," + " you need to open that link in your web browser within 24 hours" + " or your information will be removed from our system!"));
53 } catch (GigiApiException e) {
54 e.format(resp.getWriter(), getLanguage(req));
57 outputGet(req, resp, s);
61 public boolean needsLogin() {
66 public boolean isPermitted(AuthorizationContext ac) {