james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [9/9] james-project git commit: JAMES-1856 Adding debug logs to AbstractSign
Date Thu, 17 Nov 2016 09:38:39 GMT
JAMES-1856 Adding debug logs to AbstractSign


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5ed89677
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5ed89677
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5ed89677

Branch: refs/heads/master
Commit: 5ed89677ca881eb80e31c2813c8bc882b5a0166c
Parents: f1ed155
Author: Benoit Tellier <btellier@linagora.com>
Authored: Mon Nov 14 11:15:20 2016 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Thu Nov 17 15:26:18 2016 +0700

----------------------------------------------------------------------
 .../james/transport/mailets/AbstractSign.java       | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5ed89677/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
----------------------------------------------------------------------
diff --git a/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
b/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
index 8f310d1..0188beb 100644
--- a/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
+++ b/mailet/crypto/src/main/java/org/apache/james/transport/mailets/AbstractSign.java
@@ -564,12 +564,14 @@ public abstract class AbstractSign extends GenericMailet {
         
         // Is it a bounce?
         if (reversePath == null) {
+            log("Can not sign : no sender");
             return false;
         }
         
         String authUser = (String) mail.getAttribute("org.apache.james.SMTPAuthUser");
         // was the sender user SMTP authorized?
         if (authUser == null) {
+            log("Can not sign mail for sender " + mail.getSender() + " as he is not a SMTP
authenticated user");
             return false;
         }
         
@@ -577,24 +579,30 @@ public abstract class AbstractSign extends GenericMailet {
         if (getMailetContext().getPostmaster().equals(reversePath)) {
             // should not sign postmaster sent messages?
             if (!isPostmasterSigns()) {
+                log("Can not sign mails for postmaster");
                 return false;
             }
         } else {
             // is the reverse-path user different from the SMTP authorized user?
             if (!reversePath.getLocalPart().equals(authUser)) {
+                log("SMTP logged in as " + authUser + " but pretend to be sender " + mail.getSender());
                 return false;
             }
             // is there no "From:" address same as the reverse-path?
             if (!fromAddressSameAsReverse(mail)) {
+                log("Can not sign mails with empty FROM header field");
                 return false;
             }
         }
-        
-        
+
         // if already signed return false
         MimeMessage mimeMessage = mail.getMessage();
-        return !(mimeMessage.isMimeType("multipart/signed")
-                || mimeMessage.isMimeType("application/pkcs7-mime"));
+        boolean isAlreadySigned = mimeMessage.isMimeType("multipart/signed")
+            || mimeMessage.isMimeType("application/pkcs7-mime");
+        if (isAlreadySigned) {
+            log("Can not sign a mail already signed");
+        }
+        return !isAlreadySigned;
 
     }
     


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message