X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2Fdomain%2FPingConfigForm.java;h=e212bb00e629af911bd8445d46e0dc76012b1de1;hp=460866cd1bdfd12e2e368a7269a6d5f116ca1b4d;hb=67bdb3b1fd3ff821d00715bf2a7ed90ca7a7a664;hpb=3167f729417a2c3f8c0d3fbe5091e467bd198509 diff --git a/src/org/cacert/gigi/pages/account/domain/PingConfigForm.java b/src/org/cacert/gigi/pages/account/domain/PingConfigForm.java index 460866cd..e212bb00 100644 --- a/src/org/cacert/gigi/pages/account/domain/PingConfigForm.java +++ b/src/org/cacert/gigi/pages/account/domain/PingConfigForm.java @@ -11,13 +11,14 @@ import org.cacert.gigi.Gigi; import org.cacert.gigi.GigiApiException; import org.cacert.gigi.dbObjects.Domain; import org.cacert.gigi.dbObjects.DomainPingConfiguration; -import org.cacert.gigi.dbObjects.DomainPingConfiguration.PingType; +import org.cacert.gigi.dbObjects.DomainPingType; import org.cacert.gigi.localisation.Language; -import org.cacert.gigi.output.Form; +import org.cacert.gigi.output.template.Form; import org.cacert.gigi.output.template.IterableDataset; import org.cacert.gigi.output.template.Template; import org.cacert.gigi.ping.SSLPinger; import org.cacert.gigi.util.RandomToken; +import org.cacert.gigi.util.SystemKeywords; public class PingConfigForm extends Form { @@ -50,7 +51,7 @@ public class PingConfigForm extends Form { private SSLType[] sslTypes = new SSLType[MAX_SSL_TESTS]; - private final Template t = new Template(PingConfigForm.class.getResource("PingConfigForm.templ")); + private static final Template t = new Template(PingConfigForm.class.getResource("PingConfigForm.templ")); public PingConfigForm(HttpServletRequest hsr, Domain target) throws GigiApiException { super(hsr); @@ -87,9 +88,11 @@ public class PingConfigForm extends Form { case SSL: { doSSL = true; String[] parts = dpc.getInfo().split(":"); - ports[portpos] = Integer.parseInt(parts[0]); - if (parts.length == 2) { - sslTypes[portpos] = SSLType.valueOf(parts[1].toUpperCase()); + tokenName = parts[0]; + tokenValue = parts[1]; + ports[portpos] = Integer.parseInt(parts[2]); + if (parts.length == 4) { + sslTypes[portpos] = SSLType.valueOf(parts[3].toUpperCase()); } else { sslTypes[portpos] = SSLType.DIRECT; } @@ -105,16 +108,21 @@ public class PingConfigForm extends Form { } @Override - public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException { - if (req.getParameter("emailType") != null) { - String mail = AUTHORATIVE_EMAILS[Integer.parseInt(req.getParameter("email"))]; - target.addPing(PingType.EMAIL, mail); + public SubmissionResult submit(HttpServletRequest req) throws GigiApiException { + target.clearPings(); + if (req.getParameter("emailType") != null && req.getParameter("email") != null) { + try { + String mail = AUTHORATIVE_EMAILS[Integer.parseInt(req.getParameter("email"))]; + target.addPing(DomainPingType.EMAIL, mail); + } catch (NumberFormatException e) { + throw new GigiApiException("A email address is required"); + } } if (req.getParameter("DNSType") != null) { - target.addPing(PingType.DNS, tokenName + ":" + tokenValue); + target.addPing(DomainPingType.DNS, tokenName + ":" + tokenValue); } if (req.getParameter("HTTPType") != null) { - target.addPing(PingType.HTTP, tokenName + ":" + tokenValue); + target.addPing(DomainPingType.HTTP, tokenName + ":" + tokenValue); } if (req.getParameter("SSLType") != null) { List types = Arrays.asList(SSLPinger.TYPES); @@ -126,25 +134,26 @@ public class PingConfigForm extends Form { } int portInt = Integer.parseInt(port); if ("direct".equals(type)) { - target.addPing(PingType.SSL, port); + target.addPing(DomainPingType.SSL, tokenName + ":" + tokenValue + ":" + port); } else if (types.contains(type)) { - target.addPing(PingType.SSL, portInt + ":" + type); + target.addPing(DomainPingType.SSL, tokenName + ":" + tokenValue + ":" + portInt + ":" + type); } } } - Gigi.notifyPinger(); - return false; + Gigi.notifyPinger(null); + return new RedirectResult(req.getPathInfo()); } @Override protected void outputContent(PrintWriter out, Language l, Map vars) { - out.print(""); + vars.put("notEmbedded", true); outputEmbeddableContent(out, l, vars); - out.print("
"); } protected void outputEmbeddableContent(PrintWriter out, Language l, Map vars) { + vars.put("httpPrefix", SystemKeywords.HTTP_CHALLENGE_PREFIX); + vars.put("dnsPrefix", SystemKeywords.DNS_PREFIX); vars.put("tokenName", tokenName); vars.put("tokenValue", tokenValue); vars.put("authEmails", new IterableDataset() {