Search in sources :

Example 1 with MyCertStoreSpi

use of org.apache.harmony.security.tests.support.cert.MyCertStoreSpi in project robovm by robovm.

the class CertStoreSpiTest method testCertStoreSpi01.

/**
     * Test for <code>CertStoreSpi</code> constructor Assertion: constructs
     * CertStoreSpi
     */
public void testCertStoreSpi01() throws InvalidAlgorithmParameterException, CertStoreException {
    CertStoreSpi certStoreSpi = null;
    //new
    CertSelector certSelector = new tmpCertSelector();
    // X509CertSelector();
    //new X509CRLSelector();
    CRLSelector crlSelector = new tmpCRLSelector();
    try {
        certStoreSpi = new MyCertStoreSpi(null);
        fail("InvalidAlgorithmParameterException must be thrown");
    } catch (InvalidAlgorithmParameterException e) {
    }
    certStoreSpi = new MyCertStoreSpi(new MyCertStoreParameters());
    assertNull("Not null collection", certStoreSpi.engineGetCertificates(certSelector));
    assertNull("Not null collection", certStoreSpi.engineGetCRLs(crlSelector));
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) MyCertStoreSpi(org.apache.harmony.security.tests.support.cert.MyCertStoreSpi) CertStoreSpi(java.security.cert.CertStoreSpi) CertSelector(java.security.cert.CertSelector) MyCertStoreSpi(org.apache.harmony.security.tests.support.cert.MyCertStoreSpi) CRLSelector(java.security.cert.CRLSelector) MyCertStoreParameters(org.apache.harmony.security.tests.support.cert.MyCertStoreParameters)

Example 2 with MyCertStoreSpi

use of org.apache.harmony.security.tests.support.cert.MyCertStoreSpi in project robovm by robovm.

the class myCertStore method testCertStore02.

/**
     * Test for
     * <code>CertStore</code> constructor
     * Assertion: returns CertStore object
     */
public void testCertStore02() throws InvalidAlgorithmParameterException, CertStoreException {
    if (!initParams()) {
        return;
    }
    MyCertStoreParameters pp = new MyCertStoreParameters();
    CertStoreSpi spi = new MyCertStoreSpi(pp);
    CertStore certS = new myCertStore(spi, dProv, dType, pp);
    assertEquals("Incorrect algorithm", certS.getType(), dType);
    assertEquals("Incorrect provider", certS.getProvider(), dProv);
    assertTrue("Incorrect parameters", certS.getCertStoreParameters() instanceof MyCertStoreParameters);
    try {
        certS.getCertificates(null);
        fail("CertStoreException must be thrown");
    } catch (CertStoreException e) {
    }
    certS = new myCertStore(null, null, null, null);
    assertNull("Incorrect algorithm", certS.getType());
    assertNull("Incorrect provider", certS.getProvider());
    assertNull("Incorrect parameters", certS.getCertStoreParameters());
    try {
        certS.getCertificates(null);
        fail("NullPointerException must be thrown");
    } catch (NullPointerException e) {
    }
}
Also used : CertStoreException(java.security.cert.CertStoreException) CertStoreSpi(java.security.cert.CertStoreSpi) MyCertStoreSpi(org.apache.harmony.security.tests.support.cert.MyCertStoreSpi) MyCertStoreSpi(org.apache.harmony.security.tests.support.cert.MyCertStoreSpi) CertStore(java.security.cert.CertStore) MyCertStoreParameters(org.apache.harmony.security.tests.support.cert.MyCertStoreParameters)

Aggregations

CertStoreSpi (java.security.cert.CertStoreSpi)2 MyCertStoreParameters (org.apache.harmony.security.tests.support.cert.MyCertStoreParameters)2 MyCertStoreSpi (org.apache.harmony.security.tests.support.cert.MyCertStoreSpi)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 CRLSelector (java.security.cert.CRLSelector)1 CertSelector (java.security.cert.CertSelector)1 CertStore (java.security.cert.CertStore)1 CertStoreException (java.security.cert.CertStoreException)1