import org.cacert.gigi.pages.TestSecure;
import org.cacert.gigi.pages.Verify;
import org.cacert.gigi.pages.account.ChangePasswordPage;
-import org.cacert.gigi.pages.account.MailAdd;
import org.cacert.gigi.pages.account.MailCertificateAdd;
import org.cacert.gigi.pages.account.MailCertificates;
import org.cacert.gigi.pages.account.MailOverview;
EmailProvider.init(conf);
DatabaseConnection.init(conf);
}
+
@Override
public void init() throws ServletException {
pages.put("/login", new LoginPage("CACert - Login"));
pages.put(ChangePasswordPage.PATH, new ChangePasswordPage());
pages.put(RegisterPage.PATH, new RegisterPage());
pages.put(MailCertificateAdd.PATH, new MailCertificateAdd());
- pages.put(MailOverview.DEFAULT_PATH, new MailOverview(
- "My email addresses"));
- pages.put(MailAdd.DEFAULT_PATH, new MailAdd("Add new email"));
- baseTemplate = new Template(new InputStreamReader(
- Gigi.class.getResourceAsStream("Gigi.templ")));
- m = new Menu("Certificates", "cert", new MenuItem(
- MailOverview.DEFAULT_PATH, "Emails"), new MenuItem("",
- "Client Certificates"), new MenuItem("", "Domains"),
- new MenuItem("", "Server Certificates"));
+ pages.put(MailOverview.DEFAULT_PATH, new MailOverview("My email addresses"));
+ baseTemplate = new Template(new InputStreamReader(Gigi.class.getResourceAsStream("Gigi.templ")));
+ m = new Menu("Certificates", "cert", new MenuItem(MailOverview.DEFAULT_PATH, "Emails"), new MenuItem("",
+ "Client Certificates"), new MenuItem("", "Domains"), new MenuItem("", "Server Certificates"));
super.init();
}
+
@Override
- protected void service(final HttpServletRequest req,
- final HttpServletResponse resp) throws ServletException,
+ protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException,
IOException {
addXSSHeaders(resp);
- if (req.getHeader("Origin") != null) {
- resp.getWriter().println("No cross domain access allowed.");
- return;
- }
+ // if (req.getHeader("Origin") != null) {
+ // resp.getWriter().println("No cross domain access allowed.");
+ // return;
+ // }
HttpSession hs = req.getSession();
if (req.getPathInfo() != null && req.getPathInfo().equals("/logout")) {
if (hs != null) {
Outputable content = new Outputable() {
@Override
- public void output(PrintWriter out, Language l,
- Map<String, Object> vars) {
+ public void output(PrintWriter out, Language l, Map<String, Object> vars) {
try {
if (req.getMethod().equals("POST")) {
p.doPost(req, resp);
}
}
+
private Page getPage(String pathInfo) {
if (pathInfo.endsWith("/") && !pathInfo.equals("/")) {
pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
}
public static void addXSSHeaders(HttpServletResponse hsr) {
- hsr.addHeader("Access-Control-Allow-Origin", "https://"
- + ServerConstants.getWwwHostNamePort() + " https://"
+ hsr.addHeader("Access-Control-Allow-Origin", "https://" + ServerConstants.getWwwHostNamePort() + " https://"
+ ServerConstants.getSecureHostNamePort());
hsr.addHeader("Access-Control-Max-Age", "60");
hsr.addHeader("Strict-Transport-Security", "max-age=31536000");
}
+
private static String defaultCSP = null;
+
private static String getDefaultCSP() {
if (defaultCSP == null) {
StringBuffer csp = new StringBuffer();
csp.append("default-src 'none';");
- csp.append("font-src https://"
- + ServerConstants.getStaticHostNamePort());
- csp.append(";img-src https://"
- + ServerConstants.getStaticHostNamePort());
+ csp.append("font-src https://" + ServerConstants.getStaticHostNamePort());
+ csp.append(";img-src https://" + ServerConstants.getStaticHostNamePort());
csp.append(";media-src 'none'; object-src 'none';");
- csp.append("script-src https://"
- + ServerConstants.getStaticHostNamePort());
- csp.append(";style-src https://"
- + ServerConstants.getStaticHostNamePort());
- csp.append(";form-action https://"
- + ServerConstants.getSecureHostNamePort() + " https://"
+ csp.append("script-src https://" + ServerConstants.getStaticHostNamePort());
+ csp.append(";style-src https://" + ServerConstants.getStaticHostNamePort());
+ csp.append(";form-action https://" + ServerConstants.getSecureHostNamePort() + " https://"
+ ServerConstants.getWwwHostNamePort());
csp.append("report-url https://api.cacert.org/security/csp/report");
defaultCSP = csp.toString();
package org.cacert.gigi.pages.account;
import java.io.IOException;
-import java.io.PrintWriter;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.cacert.gigi.Language;
import org.cacert.gigi.User;
import org.cacert.gigi.database.DatabaseConnection;
-import org.cacert.gigi.output.MailTable;
import org.cacert.gigi.pages.LoginPage;
import org.cacert.gigi.pages.Page;
public class MailOverview extends Page {
public static final String DEFAULT_PATH = "/account/mails";
- private MailTable table = new MailTable("mails", "userMail");
+
public MailOverview(String title) {
super(title);
}
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
- HashMap<String, Object> vars = new HashMap<String, Object>();
User us = LoginPage.getUser(req);
int id = us.getId();
try {
"SELECT * from `email` WHERE `memid`=? AND `deleted`=0");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
- vars.put("mails", rs);
- vars.put("userMail", us.getEmail());
-
} catch (SQLException e) {
e.printStackTrace();
}
- Language language = getLanguage(req);
- table.output(resp.getWriter(), language, vars);
- PrintWriter wri = resp.getWriter();
- wri.println("<p>");
- wri.println(language
- .getTranslation("Please Note: You can not set an unverified account as a default account, and you can not remove a default account. To remove the default account you must set another verified account as the default."));
- wri.println("</p>");
}
}
--- /dev/null
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+ <tr>
+ <td colspan="4" class="title"><?=?></td>
+ </tr>
+ <tr>
+ <td class="DataTD"><?=_Default?></td>
+ <td class="DataTD"><?=_Status?></td>
+ <td class="DataTD"><?=_Delete?></td>
+ <td class="DataTD"><?=_Address?></td>
+ </tr><tr>
+ <td class="DataTD"><input type="radio" name="emailid" value="409577" checked=""></td>
+ <td class="DataTD">Überprüft</td>
+ <td class="DataTD">nicht zutreffend</td>
+ <td class="DataTD">janis@dogcraft.de</td>
+ </tr>
+ <tr>
+ <td class="DataTD" colspan="2"><input type="submit" name="makedefault" value="Setze als Standard"></td>
+ <td class="DataTD" colspan="2"><input type="submit" name="process" value="Löschen"></td>
+ </tr>
+</table>
+<p>
+<?=_Please Note: You can not set an unverified account as a default account, and you can not remove a default account. To remove the default account you must set another verified account as the default.?>
+</p>
+<br/>
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+ <tbody><tr>
+ <td colspan="2" class="title"><?=_Add Email?></td>
+ </tr>
+
+ <tr>
+ <td class="DataTD" width="125"><?=_Email Addresses?> </td>
+ <td class="DataTD" width="125"><input type="text" name="newemail" value=""></td>
+ </tr>
+ <tr>
+ <td class="DataTD" colspan="2"><input type="submit" name="process" value="<?=_I own or am authorised to control this email address?>"></td>
+ </tr>
+</tbody></table>
\ No newline at end of file