Search in sources :

Example 1 with CertificateFactorySpi

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

the class CertificateFactorySpiTest method testEngineGenerateCertPathLjava_io_InputStream02.

/**
     * Test for <code>engineGenerateCertPath(InputStream)</code> method.
     * Assertion: Generates a <code>CertPath</code> object and initializes it
     * with the data read from the <code>InputStream</code>
     */
public void testEngineGenerateCertPathLjava_io_InputStream02() {
    CertificateFactorySpi certFactorySpi = new extCertificateFactorySpi();
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
    DataInputStream dis = new DataInputStream(bais);
    try {
        certFactorySpi.engineGenerateCertPath(dis);
        fail("UnsupportedOperationException expected");
    } catch (UnsupportedOperationException e) {
    // expected
    } catch (CertificateException e) {
        fail("Unexpected CertificateException " + e.getMessage());
    }
}
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) DataInputStream(java.io.DataInputStream)

Example 2 with CertificateFactorySpi

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

the class CertificateFactorySpiTest method testEngineGenerateCertPathLJava_util_List01.

/**
     * Test for <code>engineGenerateCertPath(List<? extends Certificate>)</code>
     * method Assertion: generates a <code>CertPath</code> object and
     * initializes it with a <code>List</code> of <code>Certificates</code>
     */
public void testEngineGenerateCertPathLJava_util_List01() {
    CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
    MyCertificateFactorySpi.putMode(true);
    List<Certificate> list = new ArrayList<Certificate>();
    try {
        assertNull(certFactorySpi.engineGenerateCertPath(list));
    } catch (CertificateException e) {
        fail("Unexpected CertificateException " + e.getMessage());
    }
    try {
        certFactorySpi.engineGenerateCertPath((List<? extends Certificate>) null);
        fail("expected NullPointerException");
    } catch (NullPointerException e) {
    // ok
    } catch (CertificateException e) {
        fail("Unexpected CertificateException " + e.getMessage());
    }
}
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) ArrayList(java.util.ArrayList) CertificateException(java.security.cert.CertificateException) Certificate(java.security.cert.Certificate)

Example 3 with CertificateFactorySpi

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

the class CertificateFactorySpiTest method testEngineGenerateCertPathLjava_io_InputStream_Ljava_lang_String01.

/**
     * Test for <code>engineGenerateCertPath(InputStream, String)</code>
     * method. Assertion: generates a <code>CertPath</code> object and
     * initializes it with the data read from the <code>InputStream</code>
     */
public void testEngineGenerateCertPathLjava_io_InputStream_Ljava_lang_String01() {
    CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
    MyCertificateFactorySpi.putMode(true);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
    DataInputStream dis = new DataInputStream(bais);
    try {
        certFactorySpi.engineGenerateCertPath(dis, "");
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    // expected
    } catch (CertificateException e) {
        fail("Unexpected CertificateException " + e.getMessage());
    }
    try {
        assertNull(certFactorySpi.engineGenerateCertPath(dis, "encoding"));
    } catch (CertificateException e) {
        fail("Unexpected CertificateException " + e.getMessage());
    }
}
Also used : CertificateFactorySpi(java.security.cert.CertificateFactorySpi) MyCertificateFactorySpi(org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi) ByteArrayInputStream(java.io.ByteArrayInputStream) MyCertificateFactorySpi(org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi) CertificateException(java.security.cert.CertificateException) DataInputStream(java.io.DataInputStream)

Example 4 with CertificateFactorySpi

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

the class CertificateFactorySpiTest method testAbstractMethods.

public void testAbstractMethods() {
    CertificateFactorySpi certFactorySpi = new extCertificateFactorySpi();
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[3]);
    DataInputStream dis = new DataInputStream(bais);
    try {
        certFactorySpi.engineGenerateCRL(dis);
        certFactorySpi.engineGenerateCRLs(dis);
        certFactorySpi.engineGenerateCertificate(dis);
        certFactorySpi.engineGenerateCertificates(dis);
    } catch (Exception e) {
        fail("Unexpected exception " + e.getMessage());
    }
}
Also used : CertificateFactorySpi(java.security.cert.CertificateFactorySpi) MyCertificateFactorySpi(org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi) ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) CertificateException(java.security.cert.CertificateException) CRLException(java.security.cert.CRLException)

Example 5 with CertificateFactorySpi

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

the class CertificateFactorySpiTest method testEngineGenerateCertPathLjava_io_InputStream_Ljava_lang_String02.

/**
     * Test for <code>engineGenerateCertPath(InputStream, String)</code>
     * method. Assertion: generates a <code>CertPath</code> object and
     * initializes it with the data read from the <code>InputStream</code>
     */
public void testEngineGenerateCertPathLjava_io_InputStream_Ljava_lang_String02() {
    CertificateFactorySpi certFactorySpi = new extCertificateFactorySpi();
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
    DataInputStream dis = new DataInputStream(bais);
    try {
        certFactorySpi.engineGenerateCertPath(dis, "encoding");
        fail("UnsupportedOperationException expected");
    } catch (UnsupportedOperationException e) {
    // expected
    } catch (CertificateException e) {
        fail("Unexpected CertificateException " + e.getMessage());
    }
}
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) DataInputStream(java.io.DataInputStream)

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