Search in sources :

Example 46 with CRLException

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

the class CRLExceptionTest method testCRLException07.

/**
     * Test for <code>CRLException(String, Throwable)</code> constructor
     * Assertion: constructs CRLException when <code>cause</code> is null
     * <code>msg</code> is not null
     */
public void testCRLException07() {
    CRLException tE;
    for (int i = 0; i < msgs.length; i++) {
        tE = new CRLException(msgs[i], null);
        assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
        assertNull("getCause() must return null", tE.getCause());
    }
}
Also used : CRLException(java.security.cert.CRLException)

Example 47 with CRLException

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

the class CRLExceptionTest method testCRLException04.

/**
     * Test for <code>CRLException(Throwable)</code> constructor Assertion:
     * constructs CRLException when <code>cause</code> is null
     */
public void testCRLException04() {
    Throwable cause = null;
    CRLException tE = new CRLException(cause);
    assertNull("getMessage() must return null.", tE.getMessage());
    assertNull("getCause() must return null", tE.getCause());
}
Also used : CRLException(java.security.cert.CRLException)

Example 48 with CRLException

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

the class myCertificateFactory method testCertificateFactory17.

/**
     * Test for <code>CertificateFactory</code> constructor
     * Assertion: returns CertificateFactory object
     */
public void testCertificateFactory17() throws CRLException {
    if (!X509Support) {
        fail(NotSupportMsg);
        return;
    }
    CertificateFactorySpi spi = new MyCertificateFactorySpi();
    CertificateFactory cf = new myCertificateFactory(spi, defaultProvider, defaultType);
    assertEquals("Incorrect type", cf.getType(), defaultType);
    assertEquals("Incorrect provider", cf.getProvider(), defaultProvider);
    try {
        cf.generateCRLs(null);
        fail("CRLException must be thrown");
    } catch (CRLException e) {
    }
    cf = new myCertificateFactory(null, null, null);
    assertNull("Incorrect type", cf.getType());
    assertNull("Incorrect provider", cf.getProvider());
    try {
        cf.generateCRLs(null);
        fail("NullPointerException must be thrown");
    } catch (NullPointerException e) {
    }
}
Also used : CertificateFactorySpi(java.security.cert.CertificateFactorySpi) MyCertificateFactorySpi(org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi) MyCertificateFactorySpi(org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi) CertificateFactory(java.security.cert.CertificateFactory) CRLException(java.security.cert.CRLException)

Example 49 with CRLException

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

the class myCertificateFactory method testCertificateFactory10.

/**
     * Test for <code>generateCertificate(InputStream inStream)</code>
     * <code>generateCertificates(InputStream inStream)</code>
     * <code>generateCRL(InputStream inStream)</code>
     * <code>generateCRLs(InputStream inStream)</code>
     * methods
     * Assertion: throw CertificateException and CRLException when
     * inStream is null or empty
     */
public void testCertificateFactory10() {
    if (!X509Support) {
        fail(NotSupportMsg);
        return;
    }
    CertificateFactory[] certFs = initCertFs();
    assertNotNull("CertificateFactory objects were not created", certFs);
    byte[] bb = {};
    InputStream is = new ByteArrayInputStream(bb);
    Collection<?> colCer;
    Collection<?> colCrl;
    for (int i = 0; i < certFs.length; i++) {
        try {
            certFs[i].generateCertificate(null);
            fail("generateCertificate must thrown CertificateException or NullPointerEXception when input stream is null");
        } catch (CertificateException e) {
        } catch (NullPointerException e) {
        }
        is = new ByteArrayInputStream(bb);
        try {
            certFs[i].generateCertificates(null);
            fail("generateCertificates must throw CertificateException or NullPointerException when input stream is null");
        } catch (CertificateException e) {
        } catch (NullPointerException e) {
        }
        is = new ByteArrayInputStream(bb);
        try {
            certFs[i].generateCertificate(is);
        } catch (CertificateException e) {
        }
        is = new ByteArrayInputStream(bb);
        try {
            colCer = certFs[i].generateCertificates(is);
            if (colCer != null) {
                assertTrue("Not empty certificate collection", colCer.isEmpty());
            }
        } catch (CertificateException e) {
        }
    }
    for (int i = 0; i < certFs.length; i++) {
        try {
            certFs[i].generateCRL(null);
        } catch (CRLException e) {
        } catch (NullPointerException e) {
        }
        try {
            colCrl = certFs[i].generateCRLs(null);
            if (colCrl != null) {
                assertTrue("Not empty CRL collection was returned from null stream", colCrl.isEmpty());
            }
        } catch (CRLException e) {
        } catch (NullPointerException e) {
        }
        is = new ByteArrayInputStream(bb);
        try {
            certFs[i].generateCRL(is);
        } catch (CRLException e) {
        }
        is = new ByteArrayInputStream(bb);
        try {
            certFs[i].generateCRLs(is);
            colCrl = certFs[i].generateCRLs(null);
            if (colCrl != null) {
                assertTrue("Not empty CRL collection was returned from empty stream", colCrl.isEmpty());
            }
        } catch (CRLException e) {
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CertificateException(java.security.cert.CertificateException) CertificateFactory(java.security.cert.CertificateFactory) CRLException(java.security.cert.CRLException)

Example 50 with CRLException

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

the class myCertificateFactory method testCertificateFactory11.

/*
     * Test for <code> generateCertificate(InputStream inStream) </code><code>
     * generateCertificates(InputStream inStream) </code><code>
     * generateCRL(InputStream inStream) </code><code>
     * generateCRLs(InputStream inStream) </code>
     * methods
     * Assertion: throw CertificateException and CRLException when inStream
     * contains incompatible datas
     */
public void testCertificateFactory11() throws IOException {
    if (!X509Support) {
        fail(NotSupportMsg);
        return;
    }
    CertificateFactory[] certFs = initCertFs();
    assertNotNull("CertificateFactory objects were not created", certFs);
    MyCertificate mc = createMC();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    oos.writeObject(mc);
    oos.flush();
    oos.close();
    Certificate cer;
    Collection<?> colCer;
    CRL crl;
    Collection<?> colCrl;
    byte[] arr = os.toByteArray();
    ByteArrayInputStream is;
    for (int i = 0; i < certFs.length; i++) {
        is = new ByteArrayInputStream(arr);
        try {
            cer = certFs[i].generateCertificate(is);
            assertNull("Not null certificate was created", cer);
        } catch (CertificateException e) {
        }
        is = new ByteArrayInputStream(arr);
        try {
            colCer = certFs[i].generateCertificates(is);
            if (colCer != null) {
                assertTrue("Not empty certificate Collection was created", colCer.isEmpty());
            }
        } catch (CertificateException e) {
        }
        is = new ByteArrayInputStream(arr);
        try {
            crl = certFs[i].generateCRL(is);
            assertNull("Not null CRL was created", crl);
        } catch (CRLException e) {
        }
        is = new ByteArrayInputStream(arr);
        try {
            colCrl = certFs[i].generateCRLs(is);
            if (colCrl != null) {
                assertTrue("Not empty CRL Collection was created", colCrl.isEmpty());
            }
        } catch (CRLException e) {
        }
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) CertificateException(java.security.cert.CertificateException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) CertificateFactory(java.security.cert.CertificateFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) CRL(java.security.cert.CRL) CRLException(java.security.cert.CRLException) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Aggregations

CRLException (java.security.cert.CRLException)63 IOException (java.io.IOException)26 CertificateException (java.security.cert.CertificateException)21 X509CRL (java.security.cert.X509CRL)14 CRL (java.security.cert.CRL)11 ByteArrayInputStream (java.io.ByteArrayInputStream)8 Signature (java.security.Signature)8 CertificateFactory (java.security.cert.CertificateFactory)8 SignatureException (java.security.SignatureException)6 InputStream (java.io.InputStream)5 Certificate (java.security.cert.Certificate)5 X509CRLImpl (sun.security.x509.X509CRLImpl)5 CertificateParsingException (java.security.cert.CertificateParsingException)4 ArrayList (java.util.ArrayList)4 DataInputStream (java.io.DataInputStream)3 CertificateFactorySpi (java.security.cert.CertificateFactorySpi)3 X509CRLEntry (java.security.cert.X509CRLEntry)3 X509Certificate (java.security.cert.X509Certificate)3 X500Principal (javax.security.auth.x500.X500Principal)3 MyCertificateFactorySpi (org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi)3