in main/src/main/java/org/apache/james/jdkim/DKIMVerifier.java [394:434]
private List<SignatureRecord> verify(CompoundBodyHasher compoundBodyHasher)
throws FailException {
List<SignatureRecord> verifiedSignatures = new LinkedList<SignatureRecord>();
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"));
} else {
verifiedSignatures.add(bhj.getSignatureRecord());
}
}
if (verifiedSignatures.isEmpty()) {
throw prepareException(compoundBodyHasher.getSignatureExceptions());
} else {
// There is no access to the signatureExceptions when
// there is at least one valid signature (JDKIM-14)
/*
for (Iterator i = signatureExceptions.keySet().iterator(); i
.hasNext();) {
String f = (String) i.next();
System.out.println("DKIM-Error:"
+ ((FailException) signatureExceptions.get(f))
.getMessage() + " FIELD: " + f);
}
*/
/*
for (Iterator i = verifiedSignatures.iterator(); i.hasNext();) {
SignatureRecord sr = (SignatureRecord) i.next();
System.out.println("DKIM-Pass:" + sr);
}
*/
return verifiedSignatures;
}
}