Examples of PermFailException


Examples of org.apache.james.jdkim.exceptions.PermFailException

            } catch (IOException e) {
              throw e;
            } catch (Exception e1) {
              // This can only be a MimeException but we don't declare to allow usage of
              // DKIMSigner without Mime4J dependency.
                throw new PermFailException("MIME parsing exception: "
                        + e1.getMessage(), e1);
            }

            try {
                SignatureRecord srt = newSignatureRecordTemplate(signatureRecordTemplate);
View Full Code Here

Examples of org.apache.james.jdkim.exceptions.PermFailException

        }
    }

    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);
        } catch (SignatureException e) {
            throw new PermFailException("Signing exception: " + e.getMessage(),
                    e);
        }
    }
View Full Code Here

Examples of org.apache.james.jdkim.exceptions.PermFailException

        boolean relaxedHeaders = SignatureRecord.RELAXED.equals(sign
                .getHeaderCanonicalisationMethod());
        if (!relaxedHeaders
                && !SignatureRecord.SIMPLE.equals(sign
                        .getHeaderCanonicalisationMethod())) {
            throw new PermFailException(
                    "Unsupported canonicalization algorythm: "
                            + sign.getHeaderCanonicalisationMethod());
        }

        // NOTE: this could be improved by using iterators.
View Full Code Here

Examples of org.apache.james.jdkim.exceptions.PermFailException

                .toString() : methodAndOption.toString();
        PublicKeyRecordRetriever pkrr = retrievers.get(method);
        if (pkrr != null) {
            return pkrr.getRecords(methodAndOption, selector, token);
        } else {
            throw new PermFailException(
                    "Unknown public key record retrieving method: "
                            + methodAndOption);
        }
    }
View Full Code Here

Examples of org.apache.james.jdkim.exceptions.PermFailException

     */
    public List<String> getRecords(CharSequence methodAndOptions,
            CharSequence selector, CharSequence token)
            throws TempFailException, PermFailException {
        if (!"dns/txt".equals(methodAndOptions))
            throw new PermFailException("Only dns/txt is supported: "
                    + methodAndOptions + " options unsupported.");
        try {
            Lookup query = new Lookup(selector + "._domainkey." + token,
                    Type.TXT);
            query.setResolver(resolver);
View Full Code Here

Examples of org.apache.james.jdkim.exceptions.PermFailException

    public BodyHasherImpl(SignatureRecord sign) throws PermFailException {
        MessageDigest md;
        try {
            md = MessageDigest.getInstance(sign.getHashAlgo().toString());
        } catch (NoSuchAlgorithmException e) {
            throw new PermFailException("Unsupported algorythm: "
                    + sign.getHashAlgo(), e);
        }
       
        try {
            sign.validate();
        } catch (IllegalStateException e) {
            throw new PermFailException("Invalid signature template", e);
        }

        int limit = sign.getBodyHashLimit();

        // TODO enhance this to use a lookup service.
        boolean relaxedBody = SignatureRecord.RELAXED.equals(sign
                .getBodyCanonicalisationMethod());

        if (!relaxedBody
                && !SignatureRecord.SIMPLE.equals(sign
                        .getBodyCanonicalisationMethod())) {
            throw new PermFailException(
                    "Unsupported body canonicalization method: "
                            + sign.getBodyCanonicalisationMethod());
        }

        DigestOutputStream dout = new DigestOutputStream(md);
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.