+ private class VerificationForm extends Form {
+
+ private String hash;
+
+ private String type;
+
+ private String id;
+
+ public VerificationForm(HttpServletRequest hsr) {
+ super(hsr, PATH);
+ hash = hsr.getParameter("hash");
+ type = hsr.getParameter("type");
+ id = hsr.getParameter("id");
+ }
+
+ @Override
+ public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
+ if ("email".equals(type)) {
+ try {
+ EmailAddress ea = EmailAddress.getById(Integer.parseInt(id));
+ ea.verify(hash);
+ out.println("Email verification completed.");
+ } catch (IllegalArgumentException e) {
+ out.println(translate(req, "The email address is invalid."));
+ } catch (GigiApiException e) {
+ e.format(out, getLanguage(req));
+ }
+ } else if ("domain".equals(type)) {
+ try {
+ Domain ea = Domain.getById(Integer.parseInt(id));
+ ea.verify(hash);
+ out.println("Domain verification completed.");
+ } catch (IllegalArgumentException e) {
+ out.println(translate(req, "The domain address is invalid."));
+ } catch (GigiApiException e) {
+ e.format(out, getLanguage(req));
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {
+ vars.put("hash", hash);
+ vars.put("id", id);
+ vars.put("type", type);
+ getDefaultTemplate().output(out, l, vars);
+ }
+
+ }
+