Search in sources :

Example 31 with CRL

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

the class CertStoreCollectionSpi method engineGetCRLs.

public Collection engineGetCRLs(CRLSelector selector) throws CertStoreException {
    List col = new ArrayList();
    Iterator iter = params.getCollection().iterator();
    if (selector == null) {
        while (iter.hasNext()) {
            Object obj = iter.next();
            if (obj instanceof CRL) {
                col.add(obj);
            }
        }
    } else {
        while (iter.hasNext()) {
            Object obj = iter.next();
            if ((obj instanceof CRL) && selector.match((CRL) obj)) {
                col.add(obj);
            }
        }
    }
    return col;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) CRL(java.security.cert.CRL)

Example 32 with CRL

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

the class Pair method doPrintCRL.

private void doPrintCRL(String src, PrintStream out) throws Exception {
    for (CRL crl : loadCRLs(src)) {
        printCRL(crl, out);
        String issuer = null;
        if (caks != null) {
            issuer = verifyCRL(caks, crl);
            if (issuer != null) {
                out.printf(rb.getString("verified.by.s.in.s"), issuer, "cacerts");
                out.println();
            }
        }
        if (issuer == null && keyStore != null) {
            issuer = verifyCRL(keyStore, crl);
            if (issuer != null) {
                out.printf(rb.getString("verified.by.s.in.s"), issuer, "keystore");
                out.println();
            }
        }
        if (issuer == null) {
            out.println(rb.getString("STAR"));
            out.println(rb.getString("warning.not.verified.make.sure.keystore.is.correct"));
            out.println(rb.getString("STARNN"));
        }
    }
}
Also used : X509CRL(java.security.cert.X509CRL) CRL(java.security.cert.CRL)

Example 33 with CRL

use of java.security.cert.CRL in project nhin-d by DirectProject.

the class CRLRevocationManager method isRevoked.

/**
	 * {@inheritDoc}
	 */
@Override
public boolean isRevoked(X509Certificate certificate) {
    if (certificate == null)
        return false;
    final CRL crl = loadCRLs(certificate);
    if (crl == null) {
        final StringBuilder builder = new StringBuilder("Cannot find a CRL for certificate.").append("\r\n\tDN: ").append(certificate.getSubjectDN());
        builder.append("\r\n\tSerial Number: ").append(certificate.getSerialNumber().toString(16));
        LOGGER.warn(builder.toString());
        return false;
    }
    synchronized (crl) {
        if (crl.isRevoked(certificate)) {
            final StringBuilder builder = new StringBuilder("Certificate is revoked by CRL ").append("\r\n\tDN: ").append(certificate.getSubjectDN());
            builder.append("\r\n\tSerial Number: ").append(certificate.getSerialNumber().toString(16));
            LOGGER.warn(builder.toString());
            return true;
        }
    }
    return false;
}
Also used : X509CRL(java.security.cert.X509CRL) CRL(java.security.cert.CRL)

Example 34 with CRL

use of java.security.cert.CRL in project nhin-d by DirectProject.

the class CRLRevocationManager_getCrlFromUriTest method testGetCrlFromUri_emptyURI_assertNull.

public void testGetCrlFromUri_emptyURI_assertNull() {
    CRL crl = CRLRevocationManager.getInstance().getCrlFromUri("");
    assertNull(crl);
}
Also used : X509CRL(java.security.cert.X509CRL) CRL(java.security.cert.CRL)

Example 35 with CRL

use of java.security.cert.CRL in project nhin-d by DirectProject.

the class CRLRevocationManager_writeCRLCacheFileTest method testWriteCRLCacheFile_writeToFile.

public void testWriteCRLCacheFile_writeToFile() throws Exception {
    CRLRevocationManager.initCRLCacheLocation();
    CRL crlToWrite = TestUtils.loadCRL("certs.crl");
    String distURI = "http://localhost:8080/config";
    CRLRevocationManager.getInstance().writeCRLCacheFile(distURI, (X509CRL) crlToWrite);
    // make sure the file exists
    File crlFile = new File(CRLRevocationManager.getCacheFileName(distURI));
    assertTrue(crlFile.exists());
}
Also used : X509CRL(java.security.cert.X509CRL) CRL(java.security.cert.CRL) File(java.io.File)

Aggregations

CRL (java.security.cert.CRL)37 X509CRL (java.security.cert.X509CRL)16 CRLException (java.security.cert.CRLException)11 CertificateException (java.security.cert.CertificateException)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ArrayList (java.util.ArrayList)7 File (java.io.File)6 Certificate (java.security.cert.Certificate)5 IOException (java.io.IOException)4 CertificateFactory (java.security.cert.CertificateFactory)4 DataInputStream (java.io.DataInputStream)3 InputStream (java.io.InputStream)3 CertificateFactorySpi (java.security.cert.CertificateFactorySpi)3 X509Certificate (java.security.cert.X509Certificate)3 List (java.util.List)3 FileInputStream (java.io.FileInputStream)2 X509CRLSelector (java.security.cert.X509CRLSelector)2 Iterator (java.util.Iterator)2 MyCertificateFactorySpi (org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi)2 AndroidOnly (dalvik.annotation.AndroidOnly)1