Package org.apache.james.jdkim.api

Examples of org.apache.james.jdkim.api.BodyHasher


    }

  protected static List<SignatureRecord> verify(DKIMVerifier verifier, MimeMessage message, boolean forceCRLF)
      throws MessagingException, FailException {
    Headers headers = new MimeMessageHeaders(message);
    BodyHasher bh = verifier.newBodyHasher(headers);
    try {
        if (bh != null) {
          OutputStream os = new HeaderSkippingOutputStream(bh
                    .getOutputStream());
          if (forceCRLF) os = new CRLFOutputStream(os);
            message.writeTo(os);
            bh.getOutputStream().close();
        }
       
    } catch (IOException e) {
        throw new MessagingException("Exception calculating bodyhash: "
                + e.getMessage(), e);
View Full Code Here


    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);
View Full Code Here

     *                 if no signature can be verified
     */
    public List<SignatureRecord> verify(Headers messageHeaders,
            InputStream bodyInputStream) throws IOException, FailException {
       
        BodyHasher bh = newBodyHasher(messageHeaders);
       
        if (bh == null) return null;
       
        CompoundBodyHasher cbh = validateBodyHasher(bh);

View Full Code Here

            }

            try {
                SignatureRecord srt = newSignatureRecordTemplate(signatureRecordTemplate);

                BodyHasher bhj = newBodyHasher(srt);

                // computation of the body hash.
                DKIMCommon.streamCopy(message.getBodyInputStream(), bhj
                        .getOutputStream());

                return sign(message, bhj);
            } finally {
                message.dispose();
View Full Code Here

TOP

Related Classes of org.apache.james.jdkim.api.BodyHasher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.