]> WPIA git - gigi.git/blob - src/org/cacert/gigi/pages/Verify.java
Format code according do BenBE's formatter.
[gigi.git] / src / org / cacert / gigi / pages / Verify.java
1 package org.cacert.gigi.pages;
2
3 import java.io.IOException;
4 import java.io.PrintWriter;
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
7
8 import org.cacert.gigi.EmailAddress;
9 import org.cacert.gigi.GigiApiException;
10
11 public class Verify extends Page {
12
13     public static final String PATH = "/verify";
14
15     public Verify() {
16         super("Verify email");
17     }
18
19     @Override
20     public boolean needsLogin() {
21         return false;
22     }
23
24     @Override
25     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
26         PrintWriter out = resp.getWriter();
27         String hash = req.getParameter("hash");
28         String type = req.getParameter("type");
29         String id = req.getParameter("id");
30         if ("email".equals(type)) {
31             try {
32                 EmailAddress ea = EmailAddress.getById(Integer.parseInt(id));
33                 ea.verify(hash);
34                 out.println("Email verification completed.");
35             } catch (IllegalArgumentException e) {
36                 out.println(translate(req, "The email address is invalid."));
37             } catch (GigiApiException e) {
38                 e.format(out, getLanguage(req));
39             }
40         }
41     }
42
43 }