Search in sources :

Example 26 with CertStore

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

the class myCertStore method testCertStore16.

/**
     * Test for <code>getType()</code> method
     */
public void testCertStore16() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    if (!initParams()) {
        return;
    }
    CertStore certS;
    for (int i = 0; i < dValid.length; i++) {
        certS = CertStore.getInstance(dValid[i], dParams);
        assertEquals("Incorrect type", certS.getType(), dValid[i]);
        try {
            certS = CertStore.getInstance(dValid[i], dParams, defaultProviderCol);
            assertEquals("Incorrect type", certS.getType(), dValid[i]);
        } catch (IllegalArgumentException e) {
            fail("Unexpected IllegalArgumentException " + e.getMessage());
        }
        try {
            certS = CertStore.getInstance(dValid[i], dParams, defaultProviderColName);
            assertEquals("Incorrect type", certS.getType(), dValid[i]);
        } catch (NoSuchProviderException e) {
            fail("Unexpected IllegalArgumentException " + e.getMessage());
        }
    }
}
Also used : NoSuchProviderException(java.security.NoSuchProviderException) CertStore(java.security.cert.CertStore)

Example 27 with CertStore

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

the class myCertStore method testCertStore17.

/**
     * Test for <code>getProvider()</code> method
     */
public void testCertStore17() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    if (!initParams()) {
        return;
    }
    CertStore certS;
    for (int i = 0; i < dValid.length; i++) {
        try {
            certS = CertStore.getInstance(dValid[i], dParams, defaultProviderCol);
            assertEquals("Incorrect provider", certS.getProvider(), defaultProviderCol);
        } catch (IllegalArgumentException e) {
            fail("Unexpected IllegalArgumentException " + e.getMessage());
        }
        try {
            certS = CertStore.getInstance(dValid[i], dParams, defaultProviderColName);
            assertEquals("Incorrect provider", certS.getProvider(), defaultProviderCol);
        } catch (NoSuchProviderException e) {
            fail("Unexpected IllegalArgumentException " + e.getMessage());
        }
    }
}
Also used : NoSuchProviderException(java.security.NoSuchProviderException) CertStore(java.security.cert.CertStore)

Example 28 with CertStore

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

the class myCertStore method testCertStore18.

/**
     * Test for <code>getCertStoreParameters()</code> method
     */
public void testCertStore18() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    if (!initParams()) {
        return;
    }
    CertStore certS;
    for (int i = 0; i < dValid.length; i++) {
        certS = CertStore.getInstance(dValid[i], dParams);
        assertEquals("Incorrect parameters", ((CollectionCertStoreParameters) certS.getCertStoreParameters()).getCollection(), ((CollectionCertStoreParameters) dParams).getCollection());
        try {
            certS = CertStore.getInstance(dValid[i], dParams, defaultProviderCol);
            assertEquals("Incorrect parameters", ((CollectionCertStoreParameters) certS.getCertStoreParameters()).getCollection(), ((CollectionCertStoreParameters) dParams).getCollection());
        } catch (IllegalArgumentException e) {
            fail("Unexpected IllegalArgumentException " + e.getMessage());
        }
        try {
            certS = CertStore.getInstance(dValid[i], dParams, defaultProviderColName);
            assertEquals("Incorrect parameters", ((CollectionCertStoreParameters) certS.getCertStoreParameters()).getCollection(), ((CollectionCertStoreParameters) dParams).getCollection());
        } catch (NoSuchProviderException e) {
            fail("Unexpected IllegalArgumentException " + e.getMessage());
        }
    }
}
Also used : NoSuchProviderException(java.security.NoSuchProviderException) CertStore(java.security.cert.CertStore)

Example 29 with CertStore

use of java.security.cert.CertStore 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)

Example 30 with CertStore

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

the class myCertStore method testCertStore14.

/**
     * Test for method
     * <code>getInstance(String type, CertStoreParameters params, Provider provider)</code>
     * Assertion: return CertStore object
     */
public void testCertStore14() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    if (!initParams()) {
        return;
    }
    CertStore certS;
    for (int i = 0; i < dValid.length; i++) {
        certS = CertStore.getInstance(dValid[i], dParams, dProv);
        assertEquals("Incorrect type", certS.getType(), dValid[i]);
        certS.getCertStoreParameters();
    }
}
Also used : CertStore(java.security.cert.CertStore)

Aggregations

CertStore (java.security.cert.CertStore)38 X509Certificate (java.security.cert.X509Certificate)18 CollectionCertStoreParameters (java.security.cert.CollectionCertStoreParameters)13 CertStoreException (java.security.cert.CertStoreException)12 ArrayList (java.util.ArrayList)12 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)9 X509CertSelector (java.security.cert.X509CertSelector)9 NoSuchProviderException (java.security.NoSuchProviderException)8 PKIXBuilderParameters (java.security.cert.PKIXBuilderParameters)8 HashSet (java.util.HashSet)7 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)6 Iterator (java.util.Iterator)6 IOException (java.io.IOException)5 CertPathBuilder (java.security.cert.CertPathBuilder)5 CertStoreParameters (java.security.cert.CertStoreParameters)5 TrustAnchor (java.security.cert.TrustAnchor)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 KeyStoreException (java.security.KeyStoreException)4 Certificate (java.security.cert.Certificate)4 CertificateException (java.security.cert.CertificateException)4