Search in sources :

Example 6 with X509CRL

use of java.security.cert.X509CRL in project robovm by robovm.

the class X509CRLTest method getSignature.

private void getSignature(CertificateFactory f) throws Exception {
    X509CRL crlRsa = getCRL(f, CRL_RSA);
    byte[] expected = getResourceAsBytes(CRL_RSA_SIG);
    assertEquals(Arrays.toString(expected), Arrays.toString(crlRsa.getSignature()));
}
Also used : X509CRL(java.security.cert.X509CRL)

Example 7 with X509CRL

use of java.security.cert.X509CRL in project robovm by robovm.

the class X509CRLTest method getRevokedCertificates.

private void getRevokedCertificates(CertificateFactory f) throws Exception {
    X509CRL crlEmpty = getCRL(f, CRL_EMPTY);
    assertNull(crlEmpty.getRevokedCertificates());
    X509CRL crlRsa = getCRL(f, CRL_RSA);
    X509Certificate rsaCert = getCertificate(f, CERT_RSA);
    X509Certificate dsaCert = getCertificate(f, CERT_DSA);
    Set<? extends X509CRLEntry> entries = crlRsa.getRevokedCertificates();
    assertEquals(1, entries.size());
    for (X509CRLEntry e : entries) {
        assertRsaCrlEntry(f, e);
    }
    X509CRL crlRsaDsa = getCRL(f, CRL_RSA_DSA);
    Set<? extends X509CRLEntry> entries2 = crlRsaDsa.getRevokedCertificates();
    assertEquals(2, entries2.size());
    assertRsaCrlEntry(f, crlRsaDsa.getRevokedCertificate(rsaCert));
    assertDsaCrlEntry(f, crlRsaDsa.getRevokedCertificate(dsaCert));
}
Also used : X509CRLEntry(java.security.cert.X509CRLEntry) X509CRL(java.security.cert.X509CRL) X509Certificate(java.security.cert.X509Certificate)

Example 8 with X509CRL

use of java.security.cert.X509CRL in project robovm by robovm.

the class X509CRLTest method test_toString.

private void test_toString(CertificateFactory f) throws Exception {
    X509CRL crl1 = getCRL(f, CRL_RSA);
    X509CRL crl2 = getCRL(f, CRL_RSA);
    X509CRL crlRsaDsa = getCRL(f, CRL_RSA_DSA);
    assertNotNull(crl1);
    assertNotNull(crlRsaDsa);
    assertEquals(crl1.toString(), crl2.toString());
    assertFalse(crl1.toString().equals(crlRsaDsa.toString()));
}
Also used : X509CRL(java.security.cert.X509CRL)

Example 9 with X509CRL

use of java.security.cert.X509CRL in project robovm by robovm.

the class X509CRLTest method getSigAlgName.

private void getSigAlgName(CertificateFactory f) throws Exception {
    X509CRL crlRsa = getCRL(f, CRL_RSA);
    String actual = crlRsa.getSigAlgName().toUpperCase(Locale.US);
    // Bouncycastle is broken
    if ("BC".equals(f.getProvider().getName())) {
        assertEquals("1.2.840.113549.1.1.5", actual);
    } else {
        assertEquals("SHA1WITHRSA", actual);
    }
}
Also used : X509CRL(java.security.cert.X509CRL)

Example 10 with X509CRL

use of java.security.cert.X509CRL in project robovm by robovm.

the class X509CRLTest method verify.

private void verify(CertificateFactory f) throws Exception {
    X509CRL crlRsa = getCRL(f, CRL_RSA);
    X509Certificate caCert = getCertificate(f, CERT_CRL_CA);
    crlRsa.verify(caCert.getPublicKey());
    X509Certificate dsaCert = getCertificate(f, CERT_DSA);
    try {
        crlRsa.verify(dsaCert.getPublicKey());
        fail("should not verify using incorrect key type");
    } catch (InvalidKeyException expected) {
    }
}
Also used : X509CRL(java.security.cert.X509CRL) InvalidKeyException(java.security.InvalidKeyException) X509Certificate(java.security.cert.X509Certificate)

Aggregations

X509CRL (java.security.cert.X509CRL)74 IOException (java.io.IOException)23 CRLException (java.security.cert.CRLException)14 X509Certificate (java.security.cert.X509Certificate)14 File (java.io.File)12 GeneralSecurityException (java.security.GeneralSecurityException)8 CertificateException (java.security.cert.CertificateException)8 CRL (java.security.cert.CRL)7 CertificateFactory (java.security.cert.CertificateFactory)7 Iterator (java.util.Iterator)7 Calendar (java.util.Calendar)6 HashSet (java.util.HashSet)6 Set (java.util.Set)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InputStream (java.io.InputStream)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 LocalizedIllegalArgumentException (org.forgerock.i18n.LocalizedIllegalArgumentException)5 LdapException (org.forgerock.opendj.ldap.LdapException)5 FileInputStream (java.io.FileInputStream)4