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-jdkim.git

commit 5d172ddc4509948459eafe5b45ed5ee3c3172893
Author: Emerson Pinter <e...@pinter.dev>
AuthorDate: Wed Mar 26 14:19:16 2025 -0300

    Add DMARC compliant result method
    
    Also updates javadoc.
---
 .../java/org/apache/james/jdkim/DKIMVerifier.java    | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/main/src/main/java/org/apache/james/jdkim/DKIMVerifier.java 
b/main/src/main/java/org/apache/james/jdkim/DKIMVerifier.java
index 84fcedd..40e9836 100644
--- a/main/src/main/java/org/apache/james/jdkim/DKIMVerifier.java
+++ b/main/src/main/java/org/apache/james/jdkim/DKIMVerifier.java
@@ -413,7 +413,11 @@ public class DKIMVerifier {
     }
 
     /**
-     * Return the results of all signature checks, success and fail.
+     * Returns the results of all signature checks, success and fail.
+     * If a message doesn't have a DKIM-Signature header the result list will
+     * be empty. Use {@link Result#getResultType} or {@link Result#isSuccess}
+     * to get verification result of each DKIM-Signature check. Call {@link 
#resetResults}
+     * if the same instance of {@code DKIMVerifier} is reused for a new {@code 
verify} call.
      *
      * @return List of {@link Result} object.
      */
@@ -421,6 +425,20 @@ public class DKIMVerifier {
         return result;
     }
 
+    /**
+     * Returns {@code true} if at least one signature is successfully verified.
+     * A message pass the DKIM check when at least one signature is valid.
+     * This method is DMARC compliant, and should be called after {@code 
DKIMVerifier.verify}.
+     * Use {@link #getResults} to get result details.
+     *
+     * @return {@code true} if a valid signature is found,
+     * {@code false} if there's no valid signature.
+     * @see #getResults
+     */
+    public boolean hasAnyValidSignature() {
+        return result.stream().anyMatch(Result::isSuccess);
+    }
+
     /**
      * Returns true when all signature verification are successful. A message 
without dkim-signature is considered a success.
      *


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

Reply via email to