This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 0a40a91ebd [ENHANCEMENT] DKIMVerify outputs logs and machine readable
attributes
0a40a91ebd is described below
commit 0a40a91ebd680095f4694424b542aebea7a5b1af
Author: Benoit TELLIER <[email protected]>
AuthorDate: Fri Jun 20 12:55:31 2025 +0200
[ENHANCEMENT] DKIMVerify outputs logs and machine readable attributes
- Allows admin review of the DKIM verifications
- Also eases writing logic atop the DKIM validation results
---
.../main/java/org/apache/james/jdkim/mailets/DKIMVerify.java | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git
a/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
b/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
index 1d713230cd..fdfbf6e045 100644
---
a/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
+++
b/server/mailet/dkim/src/main/java/org/apache/james/jdkim/mailets/DKIMVerify.java
@@ -34,6 +34,8 @@ import org.apache.mailet.AttributeName;
import org.apache.mailet.AttributeValue;
import org.apache.mailet.Mail;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
@@ -51,8 +53,10 @@ import com.google.common.annotations.VisibleForTesting;
* behaviour then set forceCRLF attribute to false.
*/
public class DKIMVerify extends GenericMailet {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(DKIMVerify.class);
public static final AttributeName DKIM_AUTH_RESULT =
AttributeName.of("jDKIM.AUTHRESULT");
+ public static final AttributeName DKIM_AUTH_RESULT_BOOLEAN =
AttributeName.of("jDKIM.AUTHRESULT.FLAG");
@VisibleForTesting
DKIMVerifier verifier;
@@ -76,6 +80,7 @@ public class DKIMVerify extends GenericMailet {
if (res == null || res.isEmpty()) {
// neutral
mail.setAttribute(new Attribute(DKIM_AUTH_RESULT,
AttributeValue.of("neutral (no signatures)")));
+ LOGGER.info("DKIM signature neutral (no signatures)");
} else {
// pass
StringBuilder msg = new StringBuilder();
@@ -87,13 +92,18 @@ public class DKIMVerify extends GenericMailet {
msg.append(")");
}
mail.setAttribute(new Attribute(DKIM_AUTH_RESULT,
AttributeValue.of(msg.toString())));
+ mail.setAttribute(new Attribute(DKIM_AUTH_RESULT_BOOLEAN,
AttributeValue.of(true)));
+ LOGGER.info("DKIM signature {}", msg);
}
} catch (FailException e) {
// fail
String relatedRecordIdentity =
Optional.ofNullable(e.getRelatedRecordIdentity())
.map(value -> "identity" + value + ":")
.orElse("");
- mail.setAttribute(new Attribute(DKIM_AUTH_RESULT,
AttributeValue.of("fail (" + relatedRecordIdentity + e.getMessage() + ")")));
+ String msg = "fail (" + relatedRecordIdentity + e.getMessage() +
")";
+ mail.setAttribute(new Attribute(DKIM_AUTH_RESULT,
AttributeValue.of(msg)));
+ mail.setAttribute(new Attribute(DKIM_AUTH_RESULT_BOOLEAN,
AttributeValue.of(false)));
+ LOGGER.info("DKIM signature {}", msg);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]