Package org.apache.james.jdkim.api

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


        assertEquals("@", pattern.pattern());
        assertFalse(pattern.matcher("something").matches());
        assertFalse(pattern.matcher("").matches());
        pkr = new PublicKeyRecordImpl(
                "k=rsa; g=some*; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        pattern = pkr.getGranularityPattern();
        assertTrue(pattern.matcher("something").matches());
        assertTrue(pattern.matcher("some").matches());
        assertFalse(pattern.matcher("som").matches());
        assertFalse(pattern.matcher("awesome").matches());
View Full Code Here


        assertFalse(pattern.matcher("som").matches());
        assertFalse(pattern.matcher("awesome").matches());
        assertEquals("^\\Qsome\\E.*\\Q\\E$", pattern.pattern());
        pkr = new PublicKeyRecordImpl(
                "k=rsa; g=*+test; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        pattern = pkr.getGranularityPattern();
        assertEquals("^\\Q\\E.*\\Q+test\\E$", pattern.pattern());
        assertTrue(pattern.matcher("a+test").matches());
        assertTrue(pattern.matcher("+test").matches());
        assertFalse(pattern.matcher("atest").matches());
View Full Code Here

        assertTrue(pattern.matcher("+test").matches());
        assertFalse(pattern.matcher("atest").matches());
        assertFalse(pattern.matcher("+tested").matches());
        pkr = new PublicKeyRecordImpl(
                "k=rsa; g=test; h=sha1:sha256; p=XXXXXXXX=;");
        pkr.validate();
        pattern = pkr.getGranularityPattern();
        assertEquals("^\\Qtest\\E$", pattern.pattern());
        assertTrue(pattern.matcher("test").matches());
        assertFalse(pattern.matcher("atest").matches());
        assertFalse(pattern.matcher("testa").matches());
View Full Code Here

        assertFalse(pattern.matcher("atest").matches());
        assertFalse(pattern.matcher("testa").matches());
        try {
            pkr = new PublicKeyRecordImpl(
                    "k=rsa; g=*\\+test; h=sha1:sha256; p=XXXXXXXX=;");
            pkr.validate();
            pattern = pkr.getGranularityPattern();
            fail("Expected syntax error");
        } catch (IllegalStateException e) {
        }
        try {
View Full Code Here

        } catch (IllegalStateException e) {
        }
        try {
            pkr = new PublicKeyRecordImpl(
                    "k=rsa; g=*test*; h=sha1:sha256; p=XXXXXXXX=;");
            pkr.validate();
            pattern = pkr.getGranularityPattern();
            fail("Expected syntax error");
        } catch (IllegalStateException e) {
        }
    }
View Full Code Here

    }

    public void testGetPublicKey() {
        PublicKeyRecord pkr = new PublicKeyRecordImpl(
                "k=rsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIhyR3oItOy22ZOaBrIVe9m/iME3RqOJeasANSpg2YTHTYV+Xtp4xwf5gTjCmHQEMOs0qYu0FYiNQPQogJ2t0Mfx9zNu06rfRBDjiIU9tpx2T+NGlWZ8qhbiLo5By8apJavLyqTLavyPSrvsx0B3YzC63T4Age2CDqZYA+OwSMWQIDAQAB");
        pkr.validate();
        PublicKey pk = pkr.getPublicKey();
        assertEquals("RSA", pk.getAlgorithm());
        // On older jvm this is X509
        // assertEquals("X.509", pk.getFormat());
        assertEquals(
View Full Code Here

                ((RSAKey) pk).getModulus());

        try {
            pkr = new PublicKeyRecordImpl(
                    "k=dsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIhyR3oItOy22ZOaBrIVe9m/iME3RqOJeasANSpg2YTHTYV+Xtp4xwf5gTjCmHQEMOs0qYu0FYiNQPQogJ2t0Mfx9zNu06rfRBDjiIU9tpx2T+NGlWZ8qhbiLo5By8apJavLyqTLavyPSrvsx0B3YzC63T4Age2CDqZYA+OwSMWQIDAQAB");
            pkr.validate();
            pk = pkr.getPublicKey();
            fail("Expected invalid key spec. DSA is not supported");
        } catch (IllegalStateException e) {
        }
View Full Code Here

        }

        try {
            pkr = new PublicKeyRecordImpl(
                    "k=unknown; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIhyR3oItOy22ZOaBrIVe9m/iME3RqOJeasANSpg2YTHTYV+Xtp4xwf5gTjCmHQEMOs0qYu0FYiNQPQogJ2t0Mfx9zNu06rfRBDjiIU9tpx2T+NGlWZ8qhbiLo5By8apJavLyqTLavyPSrvsx0B3YzC63T4Age2CDqZYA+OwSMWQIDAQAB");
            pkr.validate();
            pk = pkr.getPublicKey();
            fail("Expected invalid algorythm. 'unknown' is not supported");
        } catch (IllegalStateException e) {
        }
    }
View Full Code Here

        } else {
            for (Iterator<String> i = records.iterator(); i.hasNext();) {
                String record = i.next();
                try {
                    PublicKeyRecord pk = newPublicKeyRecord(record);
                    pk.validate();
                    // we expect a single valid record, otherwise the result
                    // is unpredictable.
                    // in case of multiple valid records we use the first one.
                    return pk;
                } catch (IllegalStateException 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.