Search in sources :

Example 6 with CertStore

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

the class TestUtils method getCollectionCertStoresList.

/**
     * Creates <code>List</code> of <code>CollectionCertStores</code>
     *
     * @return The list created
     *
     * @throws InvalidAlgorithmParameterException
     * @throws NoSuchAlgorithmException
     */
public static List<CertStore> getCollectionCertStoresList() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    CertStore cs = CertStore.getInstance("Collection", new CollectionCertStoreParameters());
    ArrayList<CertStore> l = new ArrayList<CertStore>();
    if (!l.add(cs)) {
        throw new RuntimeException("Could not create cert stores list");
    }
    return l;
}
Also used : CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) ArrayList(java.util.ArrayList) CertStore(java.security.cert.CertStore)

Example 7 with CertStore

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

the class myCertStore method testCertStore05.

/**
     * Test for <code>getInstance(String type, CertStoreParameters params)</code> method
     * Assertion: return CertStore object
     */
public void testCertStore05() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException {
    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]);
        certS.getCertStoreParameters();
    }
}
Also used : CertStore(java.security.cert.CertStore)

Example 8 with CertStore

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

the class CertStore2Test method testGetInstanceStringCertStoreParametersProvider.

public void testGetInstanceStringCertStoreParametersProvider() {
    try {
        CertStoreParameters parameters = new MyCertStoreParameters();
        CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, parameters, provider);
        assertNotNull(certStore);
        assertNotNull(certStore.getCertStoreParameters());
        assertNotSame(parameters, certStore.getCertStoreParameters());
        assertSame(provider, certStore.getProvider());
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected exception: " + e);
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected exception: " + e);
    }
    try {
        CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, null, provider);
        assertNotNull(certStore);
        assertNull(certStore.getCertStoreParameters());
        assertSame(provider, certStore.getProvider());
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected exception: " + e);
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected exception: " + e);
    }
    try {
        CertStore.getInstance("UnknownCertStore", null, provider);
        fail("expected NoSuchAlgorithmException");
    } catch (NoSuchAlgorithmException e) {
    // ok
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected exception: " + e);
    }
    try {
        CertStore.getInstance(CERT_STORE_NAME, new MyOtherCertStoreParameters(), provider);
        fail("expected InvalidAlgorithmParameterException");
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected exception: " + e);
    } catch (InvalidAlgorithmParameterException e) {
    // ok
    }
}
Also used : CertStoreParameters(java.security.cert.CertStoreParameters) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CertStore(java.security.cert.CertStore)

Example 9 with CertStore

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

the class CertStore2Test method testGetCRLs.

public void testGetCRLs() {
    CertStore certStore = null;
    try {
        certStore = CertStore.getInstance(CERT_STORE_NAME, new MyCertStoreParameters());
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected exception: " + e);
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected exception: " + e);
    }
    assertNotNull(certStore);
    try {
        Collection<? extends CRL> ls = certStore.getCRLs(null);
        assertNull(ls);
    } catch (CertStoreException e) {
        fail("unexpected exception: " + e);
    }
    try {
        Collection<? extends CRL> ls = certStore.getCRLs(new MyCRLSelector());
        assertNotNull(ls);
        assertTrue(ls.isEmpty());
    } catch (CertStoreException e) {
        fail("unexpected exception: " + e);
    }
    try {
        certStore.getCRLs(new MyOtherCRLSelector());
        fail("expected CertStoreException");
    } catch (CertStoreException e) {
    // ok
    }
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) CertStoreException(java.security.cert.CertStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CertStore(java.security.cert.CertStore)

Example 10 with CertStore

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

the class CertStore2Test method testGetInstanceStringCertStoreParameters.

public void testGetInstanceStringCertStoreParameters() {
    try {
        CertStoreParameters parameters = new MyCertStoreParameters();
        CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, parameters);
        assertNotNull(certStore);
        assertNotNull(certStore.getCertStoreParameters());
        assertNotSame(parameters, certStore.getCertStoreParameters());
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected exception: " + e);
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected exception: " + e);
    }
    try {
        CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, null);
        assertNotNull(certStore);
        assertNull(certStore.getCertStoreParameters());
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected exception: " + e);
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected exception: " + e);
    }
    try {
        CertStore.getInstance("UnknownCertStore", null);
        fail("expected NoSuchAlgorithmException");
    } catch (InvalidAlgorithmParameterException e) {
        fail("unexpected exception: " + e);
    } catch (NoSuchAlgorithmException e) {
    // ok
    }
    try {
        CertStore.getInstance(CERT_STORE_NAME, new MyOtherCertStoreParameters());
        fail("expected InvalidAlgorithmParameterException");
    } catch (InvalidAlgorithmParameterException e) {
    // ok
    } catch (NoSuchAlgorithmException e) {
        fail("unexpected exception: " + e);
    }
}
Also used : CertStoreParameters(java.security.cert.CertStoreParameters) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) 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