Examples of BodyHasherImpl


Examples of org.apache.james.jdkim.impl.BodyHasherImpl

        return new SignatureRecordImpl(record);
    }

    protected BodyHasherImpl newBodyHasher(SignatureRecord signRecord)
            throws PermFailException {
        return new BodyHasherImpl(signRecord);
    }
View Full Code Here

Examples of org.apache.james.jdkim.impl.BodyHasherImpl

                            publicKeyRecord, signedHeadersList);

                    // we track all canonicalizations+limit+bodyHash we
                    // see so to be able to check all of them in a single
                    // stream run.
                    BodyHasherImpl bhj = newBodyHasher(signatureRecord);

                    bodyHashJobs.put(signatureField, bhj);

                } else {
                    throw new PermFailException(
View Full Code Here

Examples of org.apache.james.jdkim.impl.BodyHasherImpl

     */
    private List<SignatureRecord> verify(CompoundBodyHasher compoundBodyHasher)
            throws FailException {
        List<SignatureRecord> verifiedSignatures = new LinkedList<SignatureRecord>();
        for (Iterator<BodyHasherImpl> i = compoundBodyHasher.getBodyHashJobs().values().iterator(); i.hasNext();) {
            BodyHasherImpl bhj = i.next();

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

Examples of org.apache.james.jdkim.impl.BodyHasherImpl

        return new SignatureRecordImpl(record);
    }

    public BodyHasher newBodyHasher(SignatureRecord signRecord)
            throws PermFailException {
        return new BodyHasherImpl(signRecord);
    }
View Full Code Here

Examples of org.apache.james.jdkim.impl.BodyHasherImpl

    public String sign(Headers message, BodyHasher bh) throws PermFailException {
        if (!(bh instanceof BodyHasherImpl)) {
            throw new PermFailException(
                    "Supplied BodyHasher has not been generated with this signer");
        }
        BodyHasherImpl bhj = (BodyHasherImpl) bh;
        byte[] computedHash = bhj.getDigest();

        bhj.getSignatureRecord().setBodyHash(computedHash);

        List<CharSequence> headers = bhj.getSignatureRecord().getHeaders();
        try {
            // TODO handle b= in SignatureRecord.
            // whenever any tag is changed the b should be invalidated and the
            // text representation lost.
            // whenever the b value is regenerated it should also be associated
            // with the right test representation.
            // we need a method to "regenerate the text representation" and to
            // retrieve it when it is valid.
            byte[] signatureHash = signatureSign(message, bhj
                    .getSignatureRecord(), privateKey, headers);

            bhj.getSignatureRecord().setSignature(signatureHash);

            return "DKIM-Signature:" + bhj.getSignatureRecord().toString();
        } catch (InvalidKeyException e) {
            throw new PermFailException("Invalid key: " + e.getMessage(), e);
        } catch (NoSuchAlgorithmException e) {
            throw new PermFailException("Unknown algorythm: " + e.getMessage(),
                    e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.