+ e.getMessage(), e);
}
}
public void service(Mail mail) throws MessagingException {
DKIMSigner signer = new DKIMSigner(getSignatureTemplate(), getPrivateKey());
SignatureRecord signRecord = signer
.newSignatureRecordTemplate(getSignatureTemplate());
try {
BodyHasher bhj = signer.newBodyHasher(signRecord);
MimeMessage message = mail.getMessage();
Headers headers = new MimeMessageHeaders(message);
try {
OutputStream os = new HeaderSkippingOutputStream(bhj.getOutputStream());
if (forceCRLF) os = new CRLFOutputStream(os);
message.writeTo(os);
bhj.getOutputStream().close();
} catch (IOException e) {
throw new MessagingException("Exception calculating bodyhash: "
+ e.getMessage(), e);
}
String signatureHeader = signer.sign(headers, bhj);
// Unfortunately JavaMail does not give us a method to add headers
// on top.
// message.addHeaderLine(signatureHeader);
prependHeader(message, signatureHeader);
} catch (PermFailException e) {