Search in sources :

Example 61 with X509CRL

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

the class X509CRLSelector2Test method testMatchLjava_security_cert_X509CRL.

/**
     * match(CRL crl) method testing. Tests if the null object matches to the
     * selector or not.
     */
public void testMatchLjava_security_cert_X509CRL() {
    X509CRLSelector selector = new X509CRLSelector();
    assertFalse("The null object should not match", selector.match((X509CRL) null));
}
Also used : X509CRL(java.security.cert.X509CRL) X509CRLSelector(java.security.cert.X509CRLSelector)

Example 62 with X509CRL

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

the class CMSUtils method getCRLsFromStore.

static List getCRLsFromStore(CertStore certStore) throws CertStoreException, CMSException {
    List crls = new ArrayList();
    try {
        for (Iterator it = certStore.getCRLs(null).iterator(); it.hasNext(); ) {
            X509CRL c = (X509CRL) it.next();
            crls.add(CertificateList.getInstance(ASN1Primitive.fromByteArray(c.getEncoded())));
        }
        return crls;
    } catch (IllegalArgumentException e) {
        throw new CMSException("error processing crls", e);
    } catch (IOException e) {
        throw new CMSException("error processing crls", e);
    } catch (CRLException e) {
        throw new CMSException("error encoding crls", e);
    }
}
Also used : X509CRL(java.security.cert.X509CRL) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) CertificateList(org.bouncycastle.asn1.x509.CertificateList) List(java.util.List) IOException(java.io.IOException) CRLException(java.security.cert.CRLException)

Example 63 with X509CRL

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

the class PKIXCRLUtil method findCRLs.

public Set findCRLs(X509CRLStoreSelector crlselect, ExtendedPKIXParameters paramsPKIX, Date currentDate) throws AnnotatedException {
    Set initialSet = new HashSet();
    // get complete CRL(s)
    try {
        initialSet.addAll(findCRLs(crlselect, paramsPKIX.getAdditionalStores()));
        initialSet.addAll(findCRLs(crlselect, paramsPKIX.getStores()));
        initialSet.addAll(findCRLs(crlselect, paramsPKIX.getCertStores()));
    } catch (AnnotatedException e) {
        throw new AnnotatedException("Exception obtaining complete CRLs.", e);
    }
    Set finalSet = new HashSet();
    Date validityDate = currentDate;
    if (paramsPKIX.getDate() != null) {
        validityDate = paramsPKIX.getDate();
    }
    // based on RFC 5280 6.3.3
    for (Iterator it = initialSet.iterator(); it.hasNext(); ) {
        X509CRL crl = (X509CRL) it.next();
        if (crl.getNextUpdate().after(validityDate)) {
            X509Certificate cert = crlselect.getCertificateChecking();
            if (cert != null) {
                if (crl.getThisUpdate().before(cert.getNotAfter())) {
                    finalSet.add(crl);
                }
            } else {
                finalSet.add(crl);
            }
        }
    }
    return finalSet;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) X509CRL(java.security.cert.X509CRL) Iterator(java.util.Iterator) Date(java.util.Date) X509Certificate(java.security.cert.X509Certificate) HashSet(java.util.HashSet)

Example 64 with X509CRL

use of java.security.cert.X509CRL in project jdk8u_jdk by JetBrains.

the class Pair method printCRL.

private void printCRL(CRL crl, PrintStream out) throws Exception {
    if (rfc) {
        X509CRL xcrl = (X509CRL) crl;
        out.println("-----BEGIN X509 CRL-----");
        out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(xcrl.getEncoded()));
        out.println("-----END X509 CRL-----");
    } else {
        out.println(crl.toString());
    }
}
Also used : X509CRL(java.security.cert.X509CRL)

Example 65 with X509CRL

use of java.security.cert.X509CRL in project jdk8u_jdk by JetBrains.

the class CertUtils method getCRLFromFile.

/**
     * Get a DER-encoded X.509 CRL from a file.
     *
     * @param crlFilePath path to file containing DER-encoded CRL
     * @return X509CRL
     * @throws IOException on error
     */
public static X509CRL getCRLFromFile(String crlFilePath) throws IOException {
    X509CRL crl = null;
    try {
        File crlFile = new File(System.getProperty("test.src", "."), crlFilePath);
        if (!crlFile.canRead())
            throw new IOException("File " + crlFile.toString() + " is not a readable file.");
        FileInputStream crlFileInputStream = new FileInputStream(crlFile);
        CertificateFactory cf = CertificateFactory.getInstance("X509");
        crl = (X509CRL) cf.generateCRL(crlFileInputStream);
    } catch (Exception e) {
        e.printStackTrace();
        throw new IOException("Can't construct X509CRL: " + e.getMessage());
    }
    return crl;
}
Also used : X509CRL(java.security.cert.X509CRL) IOException(java.io.IOException) File(java.io.File) CertificateFactory(java.security.cert.CertificateFactory) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException)

Aggregations

X509CRL (java.security.cert.X509CRL)78 IOException (java.io.IOException)24 CRLException (java.security.cert.CRLException)16 X509Certificate (java.security.cert.X509Certificate)15 File (java.io.File)13 CertificateException (java.security.cert.CertificateException)10 CertificateFactory (java.security.cert.CertificateFactory)9 GeneralSecurityException (java.security.GeneralSecurityException)8 CRL (java.security.cert.CRL)7 ArrayList (java.util.ArrayList)7 Iterator (java.util.Iterator)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 InputStream (java.io.InputStream)6 Calendar (java.util.Calendar)6 HashSet (java.util.HashSet)6 Set (java.util.Set)6 Date (java.util.Date)5 LocalizedIllegalArgumentException (org.forgerock.i18n.LocalizedIllegalArgumentException)5 LdapException (org.forgerock.opendj.ldap.LdapException)5 FileInputStream (java.io.FileInputStream)4