Package org.apache.james.jdkim.api

Examples of org.apache.james.jdkim.api.PublicKeyRecord.validate()


            fail("Expected failure: wrong version");
        } catch (IllegalStateException e) {
        }
        pkr = new PublicKeyRecordImpl("v=DKIM1; k=rsa; p=");
        try {
            pkr.validate();
            fail("Expected failure: revoked key");
        } catch (IllegalStateException e) {
        }
    }
View Full Code Here


        }
    }

    public void testIsHashMethodSupported() {
        PublicKeyRecord pkr = new PublicKeyRecordImpl("k=rsa; p=XXXXXXXX=;");
        pkr.validate();
        assertTrue(pkr.isHashMethodSupported("sha1"));
        assertTrue(pkr.isHashMethodSupported("sha256"));
        pkr = new PublicKeyRecordImpl("k=rsa; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        assertTrue(pkr.isHashMethodSupported("sha1"));
View Full Code Here

        PublicKeyRecord pkr = new PublicKeyRecordImpl("k=rsa; p=XXXXXXXX=;");
        pkr.validate();
        assertTrue(pkr.isHashMethodSupported("sha1"));
        assertTrue(pkr.isHashMethodSupported("sha256"));
        pkr = new PublicKeyRecordImpl("k=rsa; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        assertTrue(pkr.isHashMethodSupported("sha1"));
        assertFalse(pkr.isHashMethodSupported("sha128"));
        assertTrue(pkr.isHashMethodSupported("sha256"));
    }
View Full Code Here

        assertTrue(pkr.isHashMethodSupported("sha256"));
    }

    public void testIsKeyTypeSupported() {
        PublicKeyRecord pkr = new PublicKeyRecordImpl("k=rsa; p=XXXXXXXX=;");
        pkr.validate();
        assertTrue(pkr.isKeyTypeSupported("rsa"));
        assertFalse(pkr.isKeyTypeSupported("dsa"));
    }

    public void testGetAcceptableHashMethods() {
View Full Code Here

    }

    public void testGetAcceptableHashMethods() {
        PublicKeyRecord pkr = new PublicKeyRecordImpl(
                "k=rsa; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        List<CharSequence> methods = pkr.getAcceptableHashMethods();
        assertEquals("[sha1, sha256]", methods.toString());
        pkr = new PublicKeyRecordImpl("k=rsa; p=XXXXXXXX=;");
        pkr.validate();
        methods = pkr.getAcceptableHashMethods();
View Full Code Here

                "k=rsa; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        List<CharSequence> methods = pkr.getAcceptableHashMethods();
        assertEquals("[sha1, sha256]", methods.toString());
        pkr = new PublicKeyRecordImpl("k=rsa; p=XXXXXXXX=;");
        pkr.validate();
        methods = pkr.getAcceptableHashMethods();
        assertNull(methods);
    }

    public void testGetAcceptableKeyTypes() {
View Full Code Here

    }

    public void testGetAcceptableKeyTypes() {
        PublicKeyRecord pkr = new PublicKeyRecordImpl(
                "k=rsa; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        List<CharSequence> methods = pkr.getAcceptableKeyTypes();
        assertEquals("[rsa]", methods.toString());
        pkr = new PublicKeyRecordImpl("k=rsa:dsa; p=XXXXXXXX=;");
        pkr.validate();
        methods = pkr.getAcceptableKeyTypes();
View Full Code Here

                "k=rsa; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        List<CharSequence> methods = pkr.getAcceptableKeyTypes();
        assertEquals("[rsa]", methods.toString());
        pkr = new PublicKeyRecordImpl("k=rsa:dsa; p=XXXXXXXX=;");
        pkr.validate();
        methods = pkr.getAcceptableKeyTypes();
        assertEquals("[rsa, dsa]", methods.toString());
    }

    public void testGetGranularityPattern() {
View Full Code Here

    }

    public void testGetGranularityPattern() {
        PublicKeyRecord pkr = new PublicKeyRecordImpl(
                "k=rsa; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        Pattern pattern = pkr.getGranularityPattern();
        assertEquals("^\\Q\\E.*\\Q\\E$", pattern.pattern());
        assertTrue(pattern.matcher("something").matches());
        assertTrue(pattern.matcher("").matches());
        pkr = new PublicKeyRecordImpl("k=rsa; g=; h=sha1:sha256; p=XXXXXXXX=;");
View Full Code Here

        Pattern pattern = pkr.getGranularityPattern();
        assertEquals("^\\Q\\E.*\\Q\\E$", pattern.pattern());
        assertTrue(pattern.matcher("something").matches());
        assertTrue(pattern.matcher("").matches());
        pkr = new PublicKeyRecordImpl("k=rsa; g=; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        pattern = pkr.getGranularityPattern();
        assertEquals("@", pattern.pattern());
        assertFalse(pattern.matcher("something").matches());
        assertFalse(pattern.matcher("").matches());
        pkr = new PublicKeyRecordImpl(
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.