X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2Fdomain%2FDomainOverview.java;fp=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2Fdomain%2FDomainOverview.java;h=aa2043a1fbd0765f867b12229279213577f86f8b;hb=abff88a2bf173198fe55c35ead97c9c7cdb5924c;hp=4d8165df3f86c4c7944ea8778de7e9dd3e1db8dc;hpb=17a15662212d973d12ed4cea3f5eaa9c0d1169ed;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 4d8165df..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,30 +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) { - Form.printFormErrors(req, resp.getWriter()); - 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<>(); @@ -64,39 +40,12 @@ public class DomainOverview extends Page { } @Override - public boolean beforePost(HttpServletRequest req, HttpServletResponse resp) throws IOException { - String pi = req.getPathInfo(); - if (pi.length() - PATH.length() > 0) { - if (req.getParameter("configId") != null) { - if (Form.getForm(req, DomainPinglogForm.class).submitExceptionProtected(req)) { - resp.sendRedirect(pi); - return true; - } - - } else { - if (Form.getForm(req, PingConfigForm.class).submitExceptionProtected(req)) { - resp.sendRedirect(pi); - return true; - } - } - - } - return super.beforePost(req, resp); - } - - @Override - public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { + public Form getForm(HttpServletRequest req) throws CSRFException { if (req.getParameter("adddomain") != null) { - DomainAddForm f = Form.getForm(req, DomainAddForm.class); - if (f.submitProtected(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; } }