]> WPIA git - gigi.git/commitdiff
merged mailadd and mail overviwer to one page
authorJanis Streib <janis@dogcraft.de>
Wed, 9 Jul 2014 18:47:07 +0000 (20:47 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 10 Jul 2014 22:35:14 +0000 (00:35 +0200)
Conflicts:
src/org/cacert/gigi/Gigi.java

src/org/cacert/gigi/Gigi.java
src/org/cacert/gigi/output/MailTable.java [deleted file]
src/org/cacert/gigi/pages/account/MailAdd.java [deleted file]
src/org/cacert/gigi/pages/account/MailOverview.java
src/org/cacert/gigi/pages/account/mailAdd.templ [deleted file]
src/org/cacert/gigi/pages/account/mailOverview.templ [new file with mode: 0644]

index 82223a261124da531511217d064a2c5c7068301c..2741b7329ca6eb491f72cd524891ae1b820fde70 100644 (file)
@@ -26,7 +26,6 @@ import org.cacert.gigi.pages.Page;
 import org.cacert.gigi.pages.TestSecure;
 import org.cacert.gigi.pages.Verify;
 import org.cacert.gigi.pages.account.ChangePasswordPage;
 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;
 import org.cacert.gigi.pages.account.MailCertificateAdd;
 import org.cacert.gigi.pages.account.MailCertificates;
 import org.cacert.gigi.pages.account.MailOverview;
@@ -47,6 +46,7 @@ public class Gigi extends HttpServlet {
                EmailProvider.init(conf);
                DatabaseConnection.init(conf);
        }
                EmailProvider.init(conf);
                DatabaseConnection.init(conf);
        }
+
        @Override
        public void init() throws ServletException {
                pages.put("/login", new LoginPage("CACert - Login"));
        @Override
        public void init() throws ServletException {
                pages.put("/login", new LoginPage("CACert - Login"));
@@ -59,27 +59,22 @@ public class Gigi extends HttpServlet {
                pages.put(ChangePasswordPage.PATH, new ChangePasswordPage());
                pages.put(RegisterPage.PATH, new RegisterPage());
                pages.put(MailCertificateAdd.PATH, new MailCertificateAdd());
                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();
 
        }
                super.init();
 
        }
+
        @Override
        @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);
                        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) {
                HttpSession hs = req.getSession();
                if (req.getPathInfo() != null && req.getPathInfo().equals("/logout")) {
                        if (hs != null) {
@@ -109,8 +104,7 @@ public class Gigi extends HttpServlet {
                        Outputable content = new Outputable() {
 
                                @Override
                        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);
                                        try {
                                                if (req.getMethod().equals("POST")) {
                                                        p.doPost(req, resp);
@@ -134,6 +128,7 @@ public class Gigi extends HttpServlet {
                }
 
        }
                }
 
        }
+
        private Page getPage(String pathInfo) {
                if (pathInfo.endsWith("/") && !pathInfo.equals("/")) {
                        pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
        private Page getPage(String pathInfo) {
                if (pathInfo.endsWith("/") && !pathInfo.equals("/")) {
                        pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
@@ -158,8 +153,7 @@ public class Gigi extends HttpServlet {
        }
 
        public static void addXSSHeaders(HttpServletResponse hsr) {
        }
 
        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");
 
                                + ServerConstants.getSecureHostNamePort());
                hsr.addHeader("Access-Control-Max-Age", "60");
 
@@ -167,22 +161,19 @@ public class Gigi extends HttpServlet {
                hsr.addHeader("Strict-Transport-Security", "max-age=31536000");
 
        }
                hsr.addHeader("Strict-Transport-Security", "max-age=31536000");
 
        }
+
        private static String defaultCSP = null;
        private static String defaultCSP = null;
+
        private static String getDefaultCSP() {
                if (defaultCSP == null) {
                        StringBuffer csp = new StringBuffer();
                        csp.append("default-src 'none';");
        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(";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();
                                        + ServerConstants.getWwwHostNamePort());
                        csp.append("report-url https://api.cacert.org/security/csp/report");
                        defaultCSP = csp.toString();
diff --git a/src/org/cacert/gigi/output/MailTable.java b/src/org/cacert/gigi/output/MailTable.java
deleted file mode 100644 (file)
index 8f871ac..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.cacert.gigi.output;
-
-import java.io.PrintWriter;
-import java.util.Map;
-
-import org.cacert.gigi.Language;
-
-public class MailTable implements Outputable {
-       private String resultSet, userMail;
-
-       public MailTable(String key, String userMail) {
-               this.resultSet = key;
-               this.userMail = userMail;
-       }
-
-       @Override
-       public void output(PrintWriter out, Language l, Map<String, Object> vars) {
-
-       }
-
-}
diff --git a/src/org/cacert/gigi/pages/account/MailAdd.java b/src/org/cacert/gigi/pages/account/MailAdd.java
deleted file mode 100644 (file)
index 3d8ae61..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.cacert.gigi.pages.account;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.cacert.gigi.pages.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 {
-               getDefaultTemplate().output(resp.getWriter(), Page.getLanguage(req),
-                               null);
-       }
-
-}
index e5744388a08854de2acdccba7d524818f74213a0..a4dba582cda8f3ec5b20695a1a3988754ce726a8 100644 (file)
@@ -1,25 +1,21 @@
 package org.cacert.gigi.pages.account;
 
 import java.io.IOException;
 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.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 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.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";
 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);
        }
        public MailOverview(String title) {
                super(title);
        }
@@ -27,7 +23,6 @@ public class MailOverview extends Page {
        @Override
        public void doGet(HttpServletRequest req, HttpServletResponse resp)
                        throws IOException {
        @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 {
                User us = LoginPage.getUser(req);
                int id = us.getId();
                try {
@@ -35,19 +30,9 @@ public class MailOverview extends Page {
                                        "SELECT * from `email` WHERE `memid`=? AND `deleted`=0");
                        ps.setInt(1, id);
                        ResultSet rs = ps.executeQuery();
                                        "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();
                }
                } 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>");
        }
 
 }
        }
 
 }
diff --git a/src/org/cacert/gigi/pages/account/mailAdd.templ b/src/org/cacert/gigi/pages/account/mailAdd.templ
deleted file mode 100644 (file)
index 94ee62c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<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
diff --git a/src/org/cacert/gigi/pages/account/mailOverview.templ b/src/org/cacert/gigi/pages/account/mailOverview.templ
new file mode 100644 (file)
index 0000000..3dc1e8c
--- /dev/null
@@ -0,0 +1,37 @@
+<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