]> WPIA git - gigi.git/commitdiff
Merge changes I8f2dfb5e,Ife185cda,I79a10fa7,Ib764cc42,I76efe755, ...
authorFelix Dörre <felix@dogcraft.de>
Fri, 5 Aug 2016 20:12:11 +0000 (22:12 +0200)
committerGerrit Code Review <gigi-system@dogcraft.de>
Fri, 5 Aug 2016 20:12:11 +0000 (22:12 +0200)
* changes:
  del: unused old css file
  upd: rename main css file more neutrally
  upd: format main css file
  upd: add minimal spacing to points summary table
  upd: rename "My Points" to "Points" for consistency with support view.
  add: new test cases for supporter view to points
  add: support should be able to see verifications of user

18 files changed:
src/org/cacert/gigi/api/FindAgent.java
src/org/cacert/gigi/dbObjects/SupportedUser.java
src/org/cacert/gigi/email/EmailProvider.java
src/org/cacert/gigi/email/SendMail.java
src/org/cacert/gigi/output/template/MailTemplate.java
src/org/cacert/gigi/pages/account/History.java
src/org/cacert/gigi/pages/account/History.templ
src/org/cacert/gigi/pages/account/UserTrainings.java
src/org/cacert/gigi/pages/account/UserTrainings.templ
src/org/cacert/gigi/util/ServerConstants.java
tests/org/cacert/gigi/email/TestSendmail.java
tests/org/cacert/gigi/pages/admin/TestSEAdminNotificationMail.java
tests/org/cacert/gigi/testUtils/BusinessTest.java
tests/org/cacert/gigi/testUtils/TestEmailReceiver.java
util-testing/org/cacert/gigi/email/CommandlineEmailProvider.java
util-testing/org/cacert/gigi/email/DelegateMailProvider.java
util-testing/org/cacert/gigi/email/TestEmailProvider.java
util-testing/org/cacert/gigi/pages/Manager.java

index bca3a1276c73ca4cb40c5adc67250cf43b931327..e64326b303bcd2238d4790ec71a7b7b48e762230 100644 (file)
@@ -99,7 +99,7 @@ public class FindAgent extends APIPoint {
                 return;
 
             }
-            EmailProvider.getInstance().sendMail(to.getEmail(), "[Find Agent] " + subject, body, to.getEmail(), null, null, null, null, false);
+            EmailProvider.getInstance().sendMail(to.getEmail(), "[Find Agent] " + subject, body, null, null, null, null, false);
         }
     }
 }
index 975ef9b51e02055fb444819a4330d43a42cadbab..47c17e83460662e70b15cd1828bcdb81946a4249 100644 (file)
@@ -94,7 +94,7 @@ public class SupportedUser {
             vars.put("ticket", this.getTicket());
             vars.put("subject", subject);
 
-            String supportemailaddress = "support@" + ServerConstants.getWwwHostName().replaceFirst("^www\\.", "");
+            String supportemailaddress = ServerConstants.getSupportMailAddress();
             supportNotification.sendMail(Language.getInstance(Locale.ENGLISH), vars, supportemailaddress);
         } catch (IOException e) {
             e.printStackTrace();
index ed61aeca2f6cf3ddab0c35f43c7a1e25ebb04031..ea6679cd1a98e0c878173c13c35d770999eea427 100644 (file)
@@ -25,7 +25,7 @@ import org.cacert.gigi.util.DNSUtil;
 
 public abstract class EmailProvider {
 
-    public abstract void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException;
+    public abstract void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException;
 
     private static EmailProvider instance;
 
index 43c07e8ae593f2841d46051d834f6cb4ef0d88d2..c288e5497d3d0b0b16843f50cdac5707e86b95b9 100644 (file)
@@ -31,19 +31,17 @@ public class SendMail extends EmailProvider {
     private static final Pattern NON_ASCII = Pattern.compile("[^a-zA-Z0-9 .-\\[\\]!_@]");
 
     @Override
-    public void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
-
-        String[] bits = from.split(",");
-
+    public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+        String from = ServerConstants.getSupportMailAddress();
         try (Socket smtp = new Socket(targetHost, targetPort); PrintWriter out = new PrintWriter(new OutputStreamWriter(smtp.getOutputStream(), "UTF-8")); BufferedReader in = new BufferedReader(new InputStreamReader(smtp.getInputStream(), "UTF-8"));) {
             readSMTPResponse(in, 220);
             out.print("HELO www.cacert.org\r\n");
             out.flush();
             readSMTPResponse(in, 250);
-            out.print("MAIL FROM:<returns@cacert.org>\r\n");
+            out.print("MAIL FROM: <" + from + ">\r\n");
             out.flush();
             readSMTPResponse(in, 250);
-            bits = to.split(",");
+            String[] bits = to.split(",");
             for (String user : bits) {
                 out.print("RCPT TO:<" + user.trim() + ">\r\n");
                 out.flush();
@@ -68,7 +66,7 @@ public class SendMail extends EmailProvider {
             } else {
                 out.print("Reply-To: " + from + "\r\n");
             }
-            out.print("From: support@" + ServerConstants.getWwwHostName().replaceAll("^www.", "") + "\r\n");
+            out.print("From: " + from + "\r\n");
             out.print("To: " + to + "\r\n");
             if (NON_ASCII.matcher(subject).matches()) {
 
index 9c247e00445bf1d8649c5968c01e869fd17f6838..45f8594a594bdc762f5c157b6578aa7e6836bb7b 100644 (file)
@@ -14,7 +14,7 @@ import org.cacert.gigi.localisation.Language;
 
 public class MailTemplate extends Template {
 
-    public static final String SUBJECT_TAG = "[SomeCA.org] ";
+    public static final String SUBJECT_TAG = "[SomeCA] ";
 
     private TemplateBlock subjectBlock;
 
@@ -65,7 +65,7 @@ public class MailTemplate extends Template {
         String body = runTemplate(this, l, vars);
         String subject = runTemplate(subjectBlock, l, vars);
 
-        SendMail.getInstance().sendMail(to, SUBJECT_TAG + subject, body, "support@cacert.org", null, null, null, null, false);
+        SendMail.getInstance().sendMail(to, SUBJECT_TAG + subject, body, null, null, null, null, false);
     }
 
     private static String runTemplate(Outputable toRun, Language l, Map<String, Object> vars) {
index 520e3a549b3f7a73c453a51d4a9592da31e5ded8..470ed1c6cb91add8d0e6a106556af1323a156fcd 100644 (file)
@@ -6,10 +6,8 @@ import java.util.HashMap;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.cacert.gigi.dbObjects.CertificateOwner;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.output.template.OutputableArrayIterable;
-import org.cacert.gigi.pages.LoginPage;
 import org.cacert.gigi.pages.Page;
 import org.cacert.gigi.util.AuthorizationContext;
 
@@ -30,7 +28,8 @@ public class History extends Page {
 
     @Override
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
-        CertificateOwner u;
+        User u;
+        HashMap<String, Object> vars = new HashMap<>();
         if (support) {
             String info = req.getPathInfo();
             int id = Integer.parseInt(info.substring(intStart, info.length() - SUPPORT_PATH.length() + intStart + 1));
@@ -39,11 +38,11 @@ public class History extends Page {
                 resp.sendError(404);
                 return;
             }
+            vars.put("username", u.getPreferredName().toString());
         } else {
-            u = LoginPage.getAuthorizationContext(req).getTarget();
+            u = getUser(req);
         }
         String[] adminLog = u.getAdminLog();
-        HashMap<String, Object> vars = new HashMap<>();
         vars.put("entries", new OutputableArrayIterable(adminLog, "entry"));
         getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars);
     }
index d6fe85af2c3d62e6270a8a5e1466be92f5810cdb..90f1892941777fbeb09292568711599258fb97b8 100644 (file)
@@ -1,6 +1,6 @@
 <table class="table">
 <tbody>
-<tr><th><?=_Support actions?></th></tr>
+<tr><th><? if($username) { ?><?=_Support actions for ${username}?><? } else { ?><?=_Support actions?><? } ?></th></tr>
 <? foreach($entries) { ?>
 <tr><td><?=$entry?></td></tr>
 <? } ?>
index 3a0a450be05fe3975559b71cd8e199d1e2205b7f..fca2d24f2cf306d0d03379a781f212843a37d7cb 100644 (file)
@@ -29,6 +29,7 @@ public class UserTrainings extends Page {
     @Override
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
         User u;
+        HashMap<String, Object> vars = new HashMap<>();
         if (support) {
             String info = req.getPathInfo();
             int id = Integer.parseInt(info.substring(intStart, info.length() - SUPPORT_PATH.length() + intStart + 1));
@@ -37,10 +38,10 @@ public class UserTrainings extends Page {
                 resp.sendError(404);
                 return;
             }
+            vars.put("username", u.getPreferredName().toString());
         } else {
             u = getUser(req);
         }
-        HashMap<String, Object> vars = new HashMap<>();
         vars.put("entries", new OutputableArrayIterable(u.getTrainings(), "entry"));
         getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars);
     }
index 0e2667a0137d16472d767abcbe0c901b2611eb65..58de7ddf1f7bd89afae7f59a504aa5d439fed011 100644 (file)
@@ -1,6 +1,6 @@
 <table class="table">
 <tbody>
-<tr><th><?=_Trainings?></th></tr>
+<tr><th><? if($username) { ?><?=_Trainings of ${username}?><? } else { ?><?=_Trainings?><? } ?></th></tr>
 <? foreach($entries) { ?>
 <tr><td><?=$entry?></td></tr>
 <? } ?>
index 5ae4e1b320435fbf40f7bce0f020b1d042fcf072..09317c3ec643f8c53dfc16b3b27309b4b7ac2883 100644 (file)
@@ -90,4 +90,8 @@ public class ServerConstants {
         return suffix;
     }
 
+    public static String getSupportMailAddress() {
+        return "support@" + ServerConstants.getWwwHostName().replaceFirst("^www\\.", "");
+    }
+
 }
index 5ddd75080fe318da796e0bec0fa706352ac18d78..d9af0a28f62e6fceaaefb998afc3466243cc6c5c 100644 (file)
@@ -55,7 +55,7 @@ public class TestSendmail extends ConfiguredTest {
 
         String subj = "subj-" + createUniqueName();
         String msg = "msg-" + createUniqueName();
-        EmailProvider.getInstance().sendMail(succmail, subj, msg, "system@cacert.org", "system@cacert.org", "Testtarget", "Testsender", null, false);
+        EmailProvider.getInstance().sendMail(succmail, subj, msg, "system@cacert.org", "Testtarget", "Testsender", null, false);
 
         try (Socket s = SSLSocketFactory.getDefault().createSocket(imap, 993);//
                 PrintWriter pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream(), "UTF-8"), true);//
@@ -85,7 +85,7 @@ public class TestSendmail extends ConfiguredTest {
             imapUntil(br, "exp");
             pw.println("log logout");
             imapUntil(br, "log");
-            assertThat(body, containsString("From: support@" + ServerConstants.getWwwHostName().replaceAll("^www.", "")));
+            assertThat(body, containsString("From: " + ServerConstants.getSupportMailAddress()));
             assertThat(body, containsString("To: gigi-testuser@dogcraft.de"));
             assertThat(body, containsString("Subject: " + subj));
             assertThat(body, containsString(Base64.getEncoder().encodeToString(msg.getBytes("UTF-8"))));
index bd64f9bf2e0da906ef282323ea588b0912eb7ad2..033f69a6a8445b43b637d7f99e788e318631a59c 100644 (file)
@@ -43,7 +43,7 @@ public class TestSEAdminNotificationMail extends ClientTest {
     public void testPasswordReset() throws MalformedURLException, IOException {
         executeBasicWebInteraction(cookie, SupportUserDetailsPage.PATH + targetID, "aword=SecretWord&resetPass", 0);
         TestMail tm;
-        String targetMail = "support@" + ServerConstants.getWwwHostName().replaceFirst("^www\\.", "");
+        String targetMail = ServerConstants.getSupportMailAddress();
         do {
             tm = getMailReceiver().receive();
         } while ( !tm.getTo().equals(targetMail));
index 8de7a5868df942ca775e7496390d5647f32798aa..b78b37263eddccb3299688963f1c972b6c8c412b 100644 (file)
@@ -39,8 +39,8 @@ public abstract class BusinessTest extends ConfiguredTest {
         }
 
         @Override
-        public void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
-            TestMail tm = new TestEmailReceiver.TestMail(to, subject, message, fromname, replyto) {
+        public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+            TestMail tm = new TestEmailReceiver.TestMail(to, subject, message, replyto) {
 
                 @Override
                 public void verify() throws IOException {
index 27b166f9667c35109839d9a4fccd404f117831fb..155539c798b1ed0c0e18ba7807e26b8df7610b89 100644 (file)
@@ -34,15 +34,12 @@ public final class TestEmailReceiver extends EmailProvider implements Runnable,
 
         String message;
 
-        String from;
-
         String replyto;
 
-        public TestMail(String to, String subject, String message, String from, String replyto) {
+        public TestMail(String to, String subject, String message, String replyto) {
             this.to = to;
             this.subject = subject;
             this.message = message;
-            this.from = from;
             this.replyto = replyto;
         }
 
@@ -58,10 +55,6 @@ public final class TestEmailReceiver extends EmailProvider implements Runnable,
             return message;
         }
 
-        public String getFrom() {
-            return from;
-        }
-
         public String getReplyto() {
             return replyto;
         }
@@ -174,9 +167,8 @@ public final class TestEmailReceiver extends EmailProvider implements Runnable,
                     String to = dis.readUTF();
                     String subject = dis.readUTF();
                     String message = dis.readUTF();
-                    String from = dis.readUTF();
                     String replyto = dis.readUTF();
-                    mails.add(new TestMail(to, subject, message, from, replyto));
+                    mails.add(new TestMail(to, subject, message, replyto));
                 } else if (type.equals("challengeAddrBox")) {
                     String email = dis.readUTF();
                     dos.writeUTF(quickEmailCheck(email));
@@ -273,8 +265,8 @@ public final class TestEmailReceiver extends EmailProvider implements Runnable,
     }
 
     @Override
-    public void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
-        mails.add(new TestMail(to, subject, message, from, replyto));
+    public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+        mails.add(new TestMail(to, subject, message, replyto));
     }
 
 }
index e23f47588fa553014b262659517b33b32ce8015f..263b4c49b6f3af34d71b16aa77eaa8ae907cb921 100644 (file)
@@ -8,12 +8,11 @@ public class CommandlineEmailProvider extends EmailProvider {
     public CommandlineEmailProvider(Properties p) {}
 
     @Override
-    public void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+    public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
         synchronized (System.out) {
             System.out.println("== MAIL ==");
             System.out.println("To: " + to);
             System.out.println("Subject: " + subject);
-            System.out.println("From: " + from);
             System.out.println("Errors-To: " + errorsto);
             System.out.println("Extra: " + extra);
             System.out.println(message);
index c0143ebe0a855e79109f099c544e1d3ee1aeba81..109aae8dc17f7d1bba931a9cb9d34d23d3d92dd1 100644 (file)
@@ -25,9 +25,9 @@ public abstract class DelegateMailProvider extends EmailProvider {
     }
 
     @Override
-    public void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+    public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
         if (target != null) {
-            target.sendMail(to, subject, message, from, replyto, toname, fromname, errorsto, extra);
+            target.sendMail(to, subject, message, replyto, toname, fromname, errorsto, extra);
         }
     }
 
index ab1fa37bf5a0ab0e6b16c7778ea8f43101a38ab9..eb5eb820d795c8e21e10030404a0ce9d8def203c 100644 (file)
@@ -33,10 +33,10 @@ public class TestEmailProvider extends DelegateMailProvider {
     }
 
     @Override
-    public synchronized void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+    public synchronized void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
         while (true) {
-            if ( !assureLocalConnection() && getTarget() != null) {
-                super.sendMail(to, subject, message, from, replyto, toname, fromname, errorsto, extra);
+            if ( !ensureLocalConnection() && getTarget() != null) {
+                super.sendMail(to, subject, message, replyto, toname, fromname, errorsto, extra);
                 return;
             }
             try {
@@ -47,7 +47,6 @@ public class TestEmailProvider extends DelegateMailProvider {
                 write(to);
                 write(subject);
                 write(message);
-                write(from);
                 write(replyto);
                 out.flush();
                 return;
@@ -57,7 +56,7 @@ public class TestEmailProvider extends DelegateMailProvider {
         }
     }
 
-    private boolean assureLocalConnection() throws IOException {
+    private boolean ensureLocalConnection() throws IOException {
         if (out != null) {
             try {
                 out.writeUTF("ping");
@@ -81,7 +80,7 @@ public class TestEmailProvider extends DelegateMailProvider {
     @Override
     public synchronized String checkEmailServer(int forUid, String address) throws IOException {
         while (true) {
-            if ( !assureLocalConnection() && getTarget() != null) {
+            if ( !ensureLocalConnection() && getTarget() != null) {
                 return super.checkEmailServer(forUid, address);
             }
             try {
index 8600785bc4a9da3033342c566f6a93e59ae231d6..0cf8e12d6055f342d0f81582cdad8922b4470ebb 100644 (file)
@@ -164,7 +164,7 @@ public class Manager extends Page {
         }
 
         @Override
-        public synchronized void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+        public synchronized void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
             HashMap<String, LinkedList<String>> mails = Manager.getInstance().emails;
             LinkedList<String> hismails = mails.get(to);
             if (hismails == null) {
@@ -173,7 +173,7 @@ public class Manager extends Page {
             hismails.addFirst(subject + "\n" + message);
             for (int i = 0; i < toForward.length; i++) {
                 if (toForward[i].matcher(to).matches()) {
-                    super.sendMail(to, subject, message, from, replyto, toname, fromname, errorsto, extra);
+                    super.sendMail(to, subject, message, replyto, toname, fromname, errorsto, extra);
                     return;
                 }
             }