Search in sources :

Example 81 with X509CRL

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

the class X509CRLTest method getEncoded.

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

Example 82 with X509CRL

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

the class X509CRLTest method hasUnsupportedCriticalExtension.

private void hasUnsupportedCriticalExtension(CertificateFactory f) throws Exception {
    X509CRL crlRsa = getCRL(f, CRL_RSA);
    assertFalse(crlRsa.hasUnsupportedCriticalExtension());
    X509CRL unsupportedCrl = getCRL(f, CRL_UNSUPPORTED);
    assertTrue(unsupportedCrl.hasUnsupportedCriticalExtension());
}
Also used : X509CRL(java.security.cert.X509CRL)

Example 83 with X509CRL

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

the class X509CRLTest method getSigAlgOID.

private void getSigAlgOID(CertificateFactory f) throws Exception {
    X509CRL crlRsa = getCRL(f, CRL_RSA);
    assertEquals("1.2.840.113549.1.1.5", crlRsa.getSigAlgOID());
}
Also used : X509CRL(java.security.cert.X509CRL)

Example 84 with X509CRL

use of java.security.cert.X509CRL in project XobotOS by xamarin.

the class CertPathValidatorUtilities method getDeltaCRLs.

/**
     * Fetches delta CRLs according to RFC 3280 section 5.2.4.
     *
     * @param currentDate The date for which the delta CRLs must be valid.
     * @param paramsPKIX The extended PKIX parameters.
     * @param completeCRL The complete CRL the delta CRL is for.
     * @return A <code>Set</code> of <code>X509CRL</code>s with delta CRLs.
     * @throws AnnotatedException if an exception occurs while picking the delta
     *             CRLs.
     */
protected static Set getDeltaCRLs(Date currentDate, ExtendedPKIXParameters paramsPKIX, X509CRL completeCRL) throws AnnotatedException {
    X509CRLStoreSelector deltaSelect = new X509CRLStoreSelector();
    // 5.2.4 (a)
    try {
        deltaSelect.addIssuerName(CertPathValidatorUtilities.getIssuerPrincipal(completeCRL).getEncoded());
    } catch (IOException e) {
        new AnnotatedException("Cannot extract issuer from CRL.", e);
    }
    BigInteger completeCRLNumber = null;
    try {
        DERObject derObject = CertPathValidatorUtilities.getExtensionValue(completeCRL, CRL_NUMBER);
        if (derObject != null) {
            completeCRLNumber = CRLNumber.getInstance(derObject).getPositiveValue();
        }
    } catch (Exception e) {
        throw new AnnotatedException("CRL number extension could not be extracted from CRL.", e);
    }
    // 5.2.4 (b)
    byte[] idp = null;
    try {
        idp = completeCRL.getExtensionValue(ISSUING_DISTRIBUTION_POINT);
    } catch (Exception e) {
        throw new AnnotatedException("Issuing distribution point extension value could not be read.", e);
    }
    // 5.2.4 (d)
    deltaSelect.setMinCRLNumber(completeCRLNumber == null ? null : completeCRLNumber.add(BigInteger.valueOf(1)));
    deltaSelect.setIssuingDistributionPoint(idp);
    deltaSelect.setIssuingDistributionPointEnabled(true);
    // 5.2.4 (c)
    deltaSelect.setMaxBaseCRLNumber(completeCRLNumber);
    // find delta CRLs
    Set temp = CRL_UTIL.findCRLs(deltaSelect, paramsPKIX, currentDate);
    Set result = new HashSet();
    for (Iterator it = temp.iterator(); it.hasNext(); ) {
        X509CRL crl = (X509CRL) it.next();
        if (isDeltaCRL(crl)) {
            result.add(crl);
        }
    }
    return result;
}
Also used : X509CRLStoreSelector(org.bouncycastle.x509.X509CRLStoreSelector) DERObject(org.bouncycastle.asn1.DERObject) Set(java.util.Set) HashSet(java.util.HashSet) X509CRL(java.security.cert.X509CRL) Iterator(java.util.Iterator) BigInteger(java.math.BigInteger) IOException(java.io.IOException) GeneralSecurityException(java.security.GeneralSecurityException) CertPathValidatorException(java.security.cert.CertPathValidatorException) ParseException(java.text.ParseException) ExtCertPathValidatorException(org.bouncycastle.jce.exception.ExtCertPathValidatorException) CertStoreException(java.security.cert.CertStoreException) CertificateParsingException(java.security.cert.CertificateParsingException) StoreException(org.bouncycastle.util.StoreException) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 85 with X509CRL

use of java.security.cert.X509CRL in project XobotOS by xamarin.

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)

Aggregations

X509CRL (java.security.cert.X509CRL)167 IOException (java.io.IOException)47 File (java.io.File)39 CRLException (java.security.cert.CRLException)39 X509Certificate (java.security.cert.X509Certificate)36 BigInteger (java.math.BigInteger)27 CertificateException (java.security.cert.CertificateException)27 CertificateFactory (java.security.cert.CertificateFactory)26 HashSet (java.util.HashSet)23 Date (java.util.Date)20 GeneralSecurityException (java.security.GeneralSecurityException)18 X509CRLEntry (java.security.cert.X509CRLEntry)18 InputStream (java.io.InputStream)17 Test (org.junit.Test)16 FileOutputStream (java.io.FileOutputStream)14 BufferedOutputStream (java.io.BufferedOutputStream)13 OutputStream (java.io.OutputStream)13 ArrayList (java.util.ArrayList)13 ByteArrayInputStream (java.io.ByteArrayInputStream)12 FileInputStream (java.io.FileInputStream)12