KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
-DROP TABLE IF EXISTS `pinglog`;
-CREATE TABLE `pinglog` (
+DROP TABLE IF EXISTS `emailPinglog`;
+CREATE TABLE `emailPinglog` (
`when` datetime NOT NULL,
`uid` int(11) NOT NULL,
- `email` varchar(255) NOT NULL,
+ `emailid` int(11) NOT NULL,
+ `type` enum('fast', 'active') NOT NULL,
+ `status` enum('open', 'success', 'failed') NOT NULL,
+ `result` varchar(255) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+DROP TABLE IF EXISTS `pingconfig`;
+CREATE TABLE `pingconfig` (
+ `domainid` int(11) NOT NULL,
+ `type` enum('email', 'ssl', 'http', 'dns') NOT NULL,
+ `info` varchar(255) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+
+DROP TABLE IF EXISTS `domainPinglog`;
+CREATE TABLE `domainPinglog` (
+ `when` datetime NOT NULL,
+ `uid` int(11) NOT NULL,
+ `domainid` int(11) NOT NULL,
+ `type` enum('email', 'ssl', 'http', 'dns') NOT NULL,
+ `status` enum('open', 'success', 'failed') NOT NULL,
`result` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
}
}
+ public void addPing(String type, String config) throws GigiApiException {
+ try {
+ PreparedStatement ps = DatabaseConnection.getInstance().prepare("INSERT INTO pingconfig SET domainid=?, type=?, info=?");
+ ps.setInt(1, id);
+ ps.setString(2, type);
+ ps.setString(3, config);
+ ps.execute();
+ } catch (SQLException e) {
+ throw new GigiApiException(e);
+ }
+ }
}
package org.cacert.gigi.pages.account;
import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.cacert.gigi.output.template.OutputableArrayIterable;
import org.cacert.gigi.output.template.Template;
import org.cacert.gigi.pages.Page;
+import org.cacert.gigi.ping.SSLPinger;
import org.cacert.gigi.util.RandomToken;
public class DomainAddForm extends Form {
private String tokenValue = RandomToken.generateToken(16);
+ private static final int MAX_SSL_TESTS = 4;
+
public DomainAddForm(HttpServletRequest hsr, User target) {
super(hsr);
this.target = target;
}
Domain d = new Domain(target, parameter);
d.insert();
+ if (req.getParameter("emailType") != null) {
+ String mail = AUTHORATIVE_EMAILS[Integer.parseInt(req.getParameter("email"))];
+ d.addPing("email", mail + "@" + d.getSuffix());
+ }
+ if (req.getParameter("DNSType") != null) {
+ d.addPing("dns", tokenName + ":" + tokenValue);
+ }
+ if (req.getParameter("HTTPType") != null) {
+ d.addPing("http", tokenName + ":" + tokenValue);
+ }
+ if (req.getParameter("SSLType") != null) {
+ System.out.println("ssl");
+ List<String> types = Arrays.asList(SSLPinger.TYPES);
+ for (int i = 0; i < MAX_SSL_TESTS; i++) {
+ String type = req.getParameter("ssl-type-" + i);
+ String port = req.getParameter("ssl-port-" + i);
+ if (type == null || port == null || port.equals("")) {
+ continue;
+ }
+ int portInt = Integer.parseInt(port);
+ if ("direct".equals(type)) {
+ d.addPing("ssl", port);
+ } else if (types.contains(type)) {
+ d.addPing("ssl", portInt + ":" + type);
+ }
+
+ }
+ }
+
return true;
+ } catch (NumberFormatException e) {
+ new GigiApiException("A number could not be parsed").format(out, Page.getLanguage(req));
+ return false;
} catch (GigiApiException e) {
e.format(out, Page.getLanguage(req));
return false;
@Override
public boolean next(Language l, Map<String, Object> vars) {
- if (counter >= 4) {
+ if (counter >= MAX_SSL_TESTS) {
return false;
}
vars.put("i", counter);
<td>
Please insert the following DNS TXT entry into the SOA-file of your domain:<br/>
<pre>
- cacert-<?=$tokenName?> IN TXT "<?=$tokenValue?>"
+ cacert-<?=$tokenName?> IN TXT <?=$tokenValue?>
</pre>
</td>
</tr>
public class SSLPinger extends DomainPinger {
+ public static final String[] TYPES = new String[] {
+ "xmpp", "server-xmpp", "smtp", "imap"
+ };
+
@Override
public void ping(String domain, String configuration, String expToken) {
try {