Search in sources :

Example 11 with CertificateFactorySpi

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

the class CertificateFactorySpiTest method testCertificateFactorySpi01.

/**
     * Test for <code>CertificateFactorySpi</code> constructor
     * Assertion: constructs CertificateFactorySpi
     */
public void testCertificateFactorySpi01() throws CertificateException, CRLException {
    CertificateFactorySpi certFactorySpi = new extCertificateFactorySpi();
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
    try {
        certFactorySpi.engineGenerateCertPath(bais);
        fail("UnsupportedOperationException must be thrown");
    } catch (UnsupportedOperationException e) {
    }
    try {
        certFactorySpi.engineGenerateCertPath(bais, "");
        fail("UnsupportedOperationException must be thrown");
    } catch (UnsupportedOperationException e) {
    }
    try {
        List<Certificate> list = null;
        certFactorySpi.engineGenerateCertPath(list);
        fail("UnsupportedOperationException must be thrown");
    } catch (UnsupportedOperationException e) {
    }
    try {
        certFactorySpi.engineGetCertPathEncodings();
        fail("UnsupportedOperationException must be thrown");
    } catch (UnsupportedOperationException e) {
    }
    Certificate cc = certFactorySpi.engineGenerateCertificate(bais);
    assertNull("Not null Cerificate", cc);
    try {
        certFactorySpi.engineGenerateCertificate(null);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    Collection<? extends Certificate> col = certFactorySpi.engineGenerateCertificates(bais);
    assertNull("Not null Collection", col);
    try {
        certFactorySpi.engineGenerateCertificates(null);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    CRL ccCRL = certFactorySpi.engineGenerateCRL(bais);
    assertNull("Not null CRL", ccCRL);
    try {
        certFactorySpi.engineGenerateCRL(null);
        fail("CRLException must be thrown");
    } catch (CRLException e) {
    }
    Collection<? extends CRL> colCRL = certFactorySpi.engineGenerateCRLs(bais);
    assertNull("Not null CRL", colCRL);
    try {
        certFactorySpi.engineGenerateCRLs(null);
        fail("CRLException must be thrown");
    } catch (CRLException e) {
    }
}
Also used : CertificateFactorySpi(java.security.cert.CertificateFactorySpi) MyCertificateFactorySpi(org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi) ByteArrayInputStream(java.io.ByteArrayInputStream) CertificateException(java.security.cert.CertificateException) CRL(java.security.cert.CRL) CRLException(java.security.cert.CRLException) Certificate(java.security.cert.Certificate)

Example 12 with CertificateFactorySpi

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

the class CertificateFactorySpiTest method testCertificateFactorySpi03.

/**
     * Test for <code>CertificateFactorySpi</code> constructor
     * Assertion: constructs CertificateFactorySpi
     */
public void testCertificateFactorySpi03() throws CertificateException, CRLException {
    CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
    MyCertificateFactorySpi.putMode(false);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
    DataInputStream dis = new DataInputStream(bais);
    try {
        certFactorySpi.engineGenerateCertPath(bais);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    try {
        certFactorySpi.engineGenerateCertPath(dis);
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    try {
        certFactorySpi.engineGenerateCertPath(bais, "aa");
        fail("CertificateException must be thrown");
    } catch (CertificateException e) {
    }
    certFactorySpi.engineGenerateCertPath(dis, "");
    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;
    certFactorySpi.engineGenerateCertPath(list);
    Iterator<String> enc = certFactorySpi.engineGetCertPathEncodings();
    assertFalse("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)

Aggregations

CertificateFactorySpi (java.security.cert.CertificateFactorySpi)12 MyCertificateFactorySpi (org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi)12 CertificateException (java.security.cert.CertificateException)11 ByteArrayInputStream (java.io.ByteArrayInputStream)8 DataInputStream (java.io.DataInputStream)7 CRLException (java.security.cert.CRLException)6 Certificate (java.security.cert.Certificate)5 CRL (java.security.cert.CRL)3 CertificateFactory (java.security.cert.CertificateFactory)2 ArrayList (java.util.ArrayList)2 IOException (java.io.IOException)1 NoSuchProviderException (java.security.NoSuchProviderException)1