X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2Fdomain%2FDomainOverview.java;h=aa2043a1fbd0765f867b12229279213577f86f8b;hb=c9ed09f0007fc2c813815be927a5a24b23dab83c;hp=97c47eeb43f41414f9fa442fc2fb6da7cb3cb056;hpb=2fa72700a18cdc62e80e1762b90e6e8bf20e8b92;p=gigi.git diff --git a/src/org/cacert/gigi/pages/account/domain/DomainOverview.java b/src/org/cacert/gigi/pages/account/domain/DomainOverview.java index 97c47eeb..aa2043a1 100644 --- a/src/org/cacert/gigi/pages/account/domain/DomainOverview.java +++ b/src/org/cacert/gigi/pages/account/domain/DomainOverview.java @@ -8,15 +8,15 @@ import javax.servlet.http.HttpServletResponse; import org.cacert.gigi.GigiApiException; import org.cacert.gigi.dbObjects.CertificateOwner; -import org.cacert.gigi.dbObjects.Domain; import org.cacert.gigi.dbObjects.User; import org.cacert.gigi.output.template.Form; +import org.cacert.gigi.output.template.Form.CSRFException; import org.cacert.gigi.pages.LoginPage; -import org.cacert.gigi.pages.Page; +import org.cacert.gigi.pages.ManagedMultiFormPage; -public class DomainOverview extends Page { +public class DomainOverview extends ManagedMultiFormPage { - public static final String PATH = "/account/domains/"; + public static final String PATH = "/account/domains"; public DomainOverview() { super("Domains"); @@ -25,29 +25,6 @@ public class DomainOverview extends Page { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { CertificateOwner u = LoginPage.getAuthorizationContext(req).getTarget(); - String pi = req.getPathInfo(); - if (pi.length() - PATH.length() > 0) { - int i = Integer.parseInt(pi.substring(PATH.length())); - Domain d; - try { - d = Domain.getById(i); - } catch (IllegalArgumentException e) { - resp.getWriter().println(getLanguage(req).getTranslation("Access denied")); - return; - } - if (d == null || u.getId() != d.getOwner().getId()) { - resp.getWriter().println(getLanguage(req).getTranslation("Access denied")); - return; - } - new DomainPinglogForm(req, d).output(resp.getWriter(), getLanguage(req), new HashMap()); - try { - new PingConfigForm(req, d).output(resp.getWriter(), getLanguage(req), new HashMap()); - } catch (GigiApiException e) { - e.format(resp.getWriter(), getLanguage(req)); - } - return; - - } try { DomainManagementForm domMan = new DomainManagementForm(req, u, false); HashMap vars = new HashMap<>(); @@ -63,38 +40,12 @@ public class DomainOverview extends Page { } @Override - public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { - String pi = req.getPathInfo(); - if (pi.length() - PATH.length() > 0) { - try { - if (req.getParameter("configId") != null) { - if ( !Form.getForm(req, DomainPinglogForm.class).submit(resp.getWriter(), req)) { - // error? - } - - } else { - if ( !Form.getForm(req, PingConfigForm.class).submit(resp.getWriter(), req)) { - - } - } - } catch (GigiApiException e) { - e.format(resp.getWriter(), getLanguage(req)); - return; - } - - resp.sendRedirect(pi); - } + public Form getForm(HttpServletRequest req) throws CSRFException { if (req.getParameter("adddomain") != null) { - DomainAddForm f = Form.getForm(req, DomainAddForm.class); - if (f.submit(resp.getWriter(), req)) { - resp.sendRedirect(PATH); - } + return Form.getForm(req, DomainAddForm.class); } else if (req.getParameter("delete") != null) { - DomainManagementForm f = Form.getForm(req, DomainManagementForm.class); - if (f.submitProtected(resp.getWriter(), req)) { - resp.sendRedirect(PATH); - } + return Form.getForm(req, DomainManagementForm.class); } - super.doPost(req, resp); + return null; } }