in main/src/main/java/org/apache/james/jdkim/DKIMVerifier.java [385:413]
private List<SignatureRecord> verify(CompoundBodyHasher compoundBodyHasher)
throws FailException {
List<SignatureRecord> verifiedSignatures = new LinkedList<>();
for (BodyHasherImpl bhj : compoundBodyHasher.getBodyHashJobs().values()) {
byte[] computedHash = bhj.getDigest();
byte[] expectedBodyHash = bhj.getSignatureRecord().getBodyHash();
if (!Arrays.equals(expectedBodyHash, computedHash)) {
compoundBodyHasher.getSignatureExceptions()
.put(
"DKIM-Signature:" + bhj.getSignatureRecord().toString(),
new PermFailException(
"Computed bodyhash is different from the expected one", bhj.getSignatureRecord()));
} else {
verifiedSignatures.add(bhj.getSignatureRecord());
}
}
for(SignatureRecord s: verifiedSignatures) {
result.add(new Result(s));
}
result.addAll(resultsFromExceptions(compoundBodyHasher.getSignatureExceptions()));
if (verifiedSignatures.isEmpty()) {
throw prepareException(compoundBodyHasher.getSignatureExceptions());
} else {
return verifiedSignatures;
}
}