Search in sources :

Example 6 with CRL

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

the class CRLTest method testGetType02.

/**
     * Test #2 for <code>getType()</code> method<br>
     * Assertion: returns <code>CRL</code> type
     */
public final void testGetType02() {
    CRL crl = new MyCRL(null);
    assertNull(crl.getType());
}
Also used : CRL(java.security.cert.CRL)

Example 7 with CRL

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

the class CertificateFactory method engineGenerateCRLs.

/**
     * Returns a (possibly empty) collection view of the CRLs read from
     * the given input stream inStream.
     *
     * The inStream may contain a sequence of DER-encoded CRLs, or
     * a PKCS#7 CRL set.  This is a PKCS#7 SignedData object, with the
     * only signficant field being crls.  In particular the signature
     * and the contents are ignored.
     */
public Collection engineGenerateCRLs(InputStream inStream) throws CRLException {
    CRL crl;
    List crls = new ArrayList();
    while ((crl = engineGenerateCRL(inStream)) != null) {
        crls.add(crl);
    }
    return crls;
}
Also used : ArrayList(java.util.ArrayList) CertificateList(org.bouncycastle.asn1.x509.CertificateList) ArrayList(java.util.ArrayList) List(java.util.List) CRL(java.security.cert.CRL)

Example 8 with CRL

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

the class CertificateFactory2Test method checkResult.

private void checkResult(CertificateFactory certFactory, boolean mode) throws CertificateException, CRLException {
    MyCertificateFactorySpi.putMode(mode);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
    DataInputStream dis = new DataInputStream(bais);
    try {
        certFactory.generateCertPath(bais);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    try {
        certFactory.generateCertPath(dis);
        if (!mode) {
            fail("CertificateException must be thrown because encodings list is empty");
        }
    } catch (CertificateException e) {
        if (mode) {
            fail("Unexpected CertificateFactoryException was thrown");
        }
    }
    try {
        certFactory.generateCertPath(bais, "aa");
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    try {
        certFactory.generateCertPath(dis, "");
        if (mode) {
            fail("IllegalArgumentException must be thrown");
        }
    } catch (IllegalArgumentException e) {
        if (!mode) {
            fail("Unexpected IllegalArgumentException was thrown");
        }
    }
    certFactory.generateCertPath(dis, "ss");
    try {
        certFactory.generateCertificate(bais);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    try {
        certFactory.generateCertificates(null);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    Certificate cert = certFactory.generateCertificate(dis);
    assertNull("Result must be null", cert);
    Collection<? extends Certificate> col = certFactory.generateCertificates(dis);
    assertNull("Result must be null", col);
    try {
        certFactory.generateCRL(bais);
        fail("CRLException must be thrown");
    } catch (CRLException e) {
    }
    try {
        certFactory.generateCRLs(null);
        fail("CRLException must be thrown");
    } catch (CRLException e) {
    }
    CRL crl = certFactory.generateCRL(dis);
    assertNull("Result must be null", crl);
    Collection<? extends CRL> colc = certFactory.generateCRLs(dis);
    assertNull("Result must be null", colc);
    List<Certificate> list = null;
    CertPath cp;
    try {
        cp = certFactory.generateCertPath(list);
        if (mode) {
            fail("NullPointerException must be thrown");
        } else {
            assertNull("Must be null", cp);
        }
    } catch (NullPointerException e) {
        if (!mode) {
            fail("Unexpected NullPointerException was thrown");
        }
    }
    Iterator<String> it = certFactory.getCertPathEncodings();
    if (mode) {
        assertTrue(it.hasNext());
    } else {
        assertFalse(it.hasNext());
    }
}
Also used : CertificateException(java.security.cert.CertificateException) DataInputStream(java.io.DataInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) CRL(java.security.cert.CRL) CertPath(java.security.cert.CertPath) CRLException(java.security.cert.CRLException) Certificate(java.security.cert.Certificate)

Example 9 with CRL

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

the class CertificateFactorySpiTest method testCertificateFactorySpi02.

/**
     * Test for <code>CertificateFactorySpi</code> constructor
     * Assertion: constructs CertificateFactorySpi
     */
public void testCertificateFactorySpi02() throws CertificateException, CRLException {
    CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
    MyCertificateFactorySpi.putMode(true);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
    DataInputStream dis = new DataInputStream(bais);
    try {
        certFactorySpi.engineGenerateCertPath(bais);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    certFactorySpi.engineGenerateCertPath(dis);
    try {
        certFactorySpi.engineGenerateCertPath(bais, "aa");
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    try {
        certFactorySpi.engineGenerateCertPath(dis, "");
        fail("IllegalArgumentException must be thrown");
    } catch (IllegalArgumentException e) {
    }
    certFactorySpi.engineGenerateCertPath(dis, "ss");
    try {
        certFactorySpi.engineGenerateCertificate(bais);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    try {
        certFactorySpi.engineGenerateCertificates(null);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    Certificate cert = certFactorySpi.engineGenerateCertificate(dis);
    assertNull("Result must be null", cert);
    Collection<? extends Certificate> col = certFactorySpi.engineGenerateCertificates(dis);
    assertNull("Result must be null", col);
    try {
        certFactorySpi.engineGenerateCRL(bais);
        fail("CRLException must be thrown");
    } catch (CRLException e) {
    }
    try {
        certFactorySpi.engineGenerateCRLs(null);
        fail("CRLException must be thrown");
    } catch (CRLException e) {
    }
    CRL crl = certFactorySpi.engineGenerateCRL(dis);
    assertNull("Result must be null", crl);
    Collection<? extends CRL> colcrl = certFactorySpi.engineGenerateCRLs(dis);
    assertNull("Result must be null", colcrl);
    List<Certificate> list = null;
    try {
        certFactorySpi.engineGenerateCertPath(list);
        fail("NullPointerException must be thrown");
    } catch (NullPointerException e) {
    }
    Iterator<String> enc = certFactorySpi.engineGetCertPathEncodings();
    assertTrue("Incorrect Iterator", enc.hasNext());
}
Also used : CertificateFactorySpi(java.security.cert.CertificateFactorySpi) MyCertificateFactorySpi(org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi) CertificateException(java.security.cert.CertificateException) DataInputStream(java.io.DataInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) MyCertificateFactorySpi(org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi) CRL(java.security.cert.CRL) CRLException(java.security.cert.CRLException) Certificate(java.security.cert.Certificate)

Example 10 with CRL

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

the class CRLRevocationManager_writeCRLCacheFileTest method testWriteCRLCacheFile_noCRLLocation_assertFileNotCreated.

public void testWriteCRLCacheFile_noCRLLocation_assertFileNotCreated() throws Exception {
    CRL crlToWrite = TestUtils.loadCRL("certs.crl");
    String distURI = "http://localhost:8080/config";
    CRLRevocationManager.getInstance().writeCRLCacheFile(distURI, (X509CRL) crlToWrite);
    // make sure the file does not exists
    File crlFile = new File(CRLRevocationManager.getCacheFileName(distURI));
    assertFalse(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