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;
}
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();
}
}
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
}
}
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
}
}
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);
}
}
Aggregations