import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.LinkedList;
import java.util.Map;
import org.cacert.gigi.Language;
-import org.cacert.gigi.output.DataTable.Cell;
public class CertificateTable implements Outputable {
String resultSet;
public CertificateTable(String resultSet) {
this.resultSet = resultSet;
}
+ private static final String[] columnNames = new String[]{
+ "Renew/Revoke/Delete", "Status", "Email Address", "SerialNumber",
+ "Revoked", "Expires", "Login"};
@Override
public void output(PrintWriter out, Language l, Map<String, Object> vars) {
ResultSet rs = (ResultSet) vars.get(resultSet);
try {
out.println("<form method=\"post\" action=\"account.php\">");
- final LinkedList<Cell> cells = new LinkedList<>();
- cells.add(new Cell("Renew/Revoke/Delete", true));
- cells.add(new Cell("Status", true));
- cells.add(new Cell("Email Address", true));
- cells.add(new Cell("SerialNumber", true));
- cells.add(new Cell("Revoked", true));
- cells.add(new Cell("Expires", true));
- cells.add(new Cell("Login", true));
- cells.add(new Cell("Comment *", true, 2));
+ out.println("<table align=\"center\" valign=\"middle\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"wrapper\">");
+ out.println("<tr>");
+ for (String column : columnNames) {
+ out.print("<td class=\"DataTD\">");
+ out.print(l.getTranslation(column));
+ out.println("</td>");
+ }
+ out.print("<td colspan=\"2\" class=\"DataTD\">");
+ out.print(l.getTranslation("Comment *"));
+ out.println("</td></tr>");
+
rs.beforeFirst();
while (rs.next()) {
// out.println(rs.getString("id"));
- cells.add(new Cell());
- cells.add(new Cell("State", false));
- cells.add(new Cell(rs.getString("CN"), false));
- cells.add(new Cell(rs.getString("serial"), false));
+ out.print("<tr><td class=\"DataTD\"> </td><td class=\"DataTD\">State</td><td class=\"DataTD\">");
+ out.println(rs.getString("CN"));
+ out.print("</td><td class=\"DataTD\">");
+ out.println(rs.getString("serial"));
+ out.print("</td><td class=\"DataTD\">");
if (rs.getString("revoked") == null) {
- cells.add(new Cell("N/A", false));
+ out.println("N/A");
} else {
- cells.add(new Cell(rs.getString("revoked"), false));
+ out.println(rs.getString("revoked"));
}
- cells.add(new Cell(rs.getString("expire"), false));
- cells.add(new Cell(rs.getString("a"), false));
- cells.add(new Cell(rs.getString("a"), false));
+ out.print("</td><td class=\"DataTD\">");
+ out.println(rs.getString("expire"));
+ out.println("</td><td class=\"DataTD\">a</td><td class=\"DataTD\">a</td></tr>");
}
- DataTable t = new DataTable(9, cells);
- t.output(out, l, vars);
- out.println("</form>");
+ out.println("</table>");
} catch (SQLException e) {
e.printStackTrace();
}
+++ /dev/null
-package org.cacert.gigi.output;
-
-import java.io.PrintWriter;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.cacert.gigi.Language;
-
-public class DataTable implements Outputable {
- private LinkedList<Cell> cells;
- private int columnCount;
-
- public DataTable(int coloumnCount, LinkedList<Cell> content) {
- this.columnCount = coloumnCount;
- this.cells = content;
- }
-
- public void output(PrintWriter out, Language l) {
- float mesCells = cells.size();
- for (Cell c : cells) {
- if (c.getColSpan() > 1) {
- mesCells += c.getColSpan();
- }
- }
- out.println("<table align=\"center\" valign=\"middle\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"wrapper\">");
- int cellsRendered = 0;
- for (int i = 0; i < Math.ceil(mesCells / columnCount) - 1; i++) {
- out.println("<tr>");
- for (int j = 0; j < columnCount;) {
- Cell current = cells.get(cellsRendered++);
- j += current.getColSpan();
- out.println("<td ");
- out.print(current.getHtmlAttribs());
- out.print(" >");
- out.print(current.shouldTranslate() ? l.getTranslation(current
- .getText()) : current.getText());
- out.print("</td>");
- }
- out.println("</tr>");
- }
- out.println("</table>");
- }
-
- public static class Cell {
- private String text, htmlAttribs;
- private boolean translate;
- private int colSpan;
-
- public Cell() {
- this(" ", false);
- }
-
- public Cell(String text, boolean translate, int colSpan,
- String htmlAttribs) {
- this.text = text;
- this.translate = translate;
- this.htmlAttribs = htmlAttribs;
- if (colSpan > 1) {
- this.htmlAttribs += " colspan=\"" + colSpan + "\"";
- }
- this.colSpan = colSpan;
- }
-
- public Cell(String text, boolean translate) {
- this(text, translate, 1, "class=\"DataTD\"");
- }
-
- public Cell(String text, boolean translate, int colSpan) {
- this(text, translate, colSpan, "class=\"DataTD\"");
- }
-
- public boolean shouldTranslate() {
- return translate;
- }
-
- public String getText() {
- return text;
- }
-
- public int getColSpan() {
- return colSpan;
- }
-
- public String getHtmlAttribs() {
- return htmlAttribs;
- }
-
- }
-
- @Override
- public void output(PrintWriter out, Language l, Map<String, Object> vars) {
- output(out, l);
- }
-
-}
package org.cacert.gigi.output;
import java.io.PrintWriter;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.LinkedList;
import java.util.Map;
import org.cacert.gigi.Language;
-import org.cacert.gigi.output.DataTable.Cell;
public class MailTable implements Outputable {
private String resultSet, userMail;
@Override
public void output(PrintWriter out, Language l, Map<String, Object> vars) {
- ResultSet rs = (ResultSet) vars.get(resultSet);
- String userMail = (String) vars.get(this.userMail);
- LinkedList<Cell> cells = new LinkedList<>();
- cells.add(new Cell("Email Accounts", true, 4, "class=\"title\""));
- cells.add(new Cell("Default", true));
- cells.add(new Cell("Status", true));
- cells.add(new Cell("Delete", true));
- cells.add(new Cell("Address", true));
- try {
- rs.beforeFirst();
- while (rs.next()) {
- cells.add(new Cell());
- cells.add(new Cell(
- rs.getString("hash").trim().isEmpty() ? "Verified"
- : "Unverified", true));
- if (rs.getString("email").equals(userMail)) {
- cells.add(new Cell(
- "N/A"
- , true));
- } else {
- cells.add(new Cell("<input type=\"checkbox\" name=\"delid[]\" value=\""
- + rs.getInt("id") + "\">", false));
- }
- cells.add(new Cell(rs.getString("email"), false));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- String trans = l.getTranslation("Make Default");
- cells.add(new Cell(
- "<input type=\"submit\" name=\"makedefault\" value=\"" + trans
- + "\">", false, 2));
- trans = l.getTranslation("Delete");
- cells.add(new Cell("<input type=\"submit\" name=\"process\" value=\""
- + trans + "\">", false, 2));
- DataTable t = new DataTable(4, cells);
- t.output(out, l, vars);
+
}
}
package org.cacert.gigi.pages.account;
import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.LinkedList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.cacert.gigi.Language;
-import org.cacert.gigi.output.DataTable;
-import org.cacert.gigi.output.DataTable.Cell;
import org.cacert.gigi.pages.Page;
-public class MailAdd extends Page{
+public class MailAdd extends Page {
public static final String DEFAULT_PATH = "/account/mails/add";
+
public MailAdd(String title) {
super(title);
}
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
- LinkedList<Cell> cells = new LinkedList<>();
- cells.add(new Cell("Add Email", true, 2, "class=\"title\""));
- cells.add(new Cell("Email Address", true));
- cells.add(new Cell("<input type=\"text\" name=\"newemail\">", false));
- Language language = getLanguage(req);
- String trans = language.getTranslation("I own or am authorised to control this email address");
- cells.add(new Cell("<input type=\"submit\" name=\"process\" value=\""
- + trans + "\">", false, 2));
- DataTable dt = new DataTable(2, cells);
- dt.output(resp.getWriter(), language);
- PrintWriter out = resp.getWriter();
- out.println("<p>");
- out.println(language
- .getTranslation(
- "Currently we only issue certificates for Punycode domains if the person requesting them has code signing attributes attached to their account, as these have potentially slightly higher security risk."));
- out.println("</p>");
+
}
}