1 package org.cacert.gigi.pages.account.domain;
3 import java.io.IOException;
4 import java.util.HashMap;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
9 import org.cacert.gigi.GigiApiException;
10 import org.cacert.gigi.dbObjects.CertificateOwner;
11 import org.cacert.gigi.dbObjects.Domain;
12 import org.cacert.gigi.output.template.Form;
13 import org.cacert.gigi.output.template.Form.CSRFException;
14 import org.cacert.gigi.pages.LoginPage;
15 import org.cacert.gigi.pages.ManagedMultiFormPage;
17 public class EditDomain extends ManagedMultiFormPage {
19 public static final String PATH = "/account/domains/";
26 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
27 CertificateOwner u = LoginPage.getAuthorizationContext(req).getTarget();
28 String pi = req.getPathInfo();
29 if (pi.length() - PATH.length() <= 0) {
32 Form.printFormErrors(req, resp.getWriter());
33 int i = Integer.parseInt(pi.substring(PATH.length()));
36 d = Domain.getById(i);
37 } catch (IllegalArgumentException e) {
38 resp.getWriter().println(getLanguage(req).getTranslation("Access denied"));
41 if (d == null || u.getId() != d.getOwner().getId()) {
42 resp.getWriter().println(getLanguage(req).getTranslation("Access denied"));
45 new DomainPinglogForm(req, d).output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
47 new PingConfigForm(req, d).output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
48 } catch (GigiApiException e) {
49 e.format(resp.getWriter(), getLanguage(req));
55 public Form getForm(HttpServletRequest req) throws CSRFException {
56 String pi = req.getPathInfo();
57 if (pi.length() - PATH.length() <= 0) {
60 if (req.getParameter("configId") != null) {
61 return Form.getForm(req, DomainPinglogForm.class);
63 return Form.getForm(req, PingConfigForm.class);