use of java.security.cert.CertStoreParameters in project robovm by robovm.
the class CertStore2Test method testGetInstanceStringCertStoreParametersString.
public void testGetInstanceStringCertStoreParametersString() {
try {
CertStoreParameters parameters = new MyCertStoreParameters();
CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, parameters, CERT_STORE_PROVIDER_NAME);
assertNotNull(certStore);
assertNotNull(certStore.getCertStoreParameters());
assertNotSame(parameters, certStore.getCertStoreParameters());
assertEquals(CERT_STORE_PROVIDER_NAME, certStore.getProvider().getName());
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
try {
CertStore certStore = CertStore.getInstance(CERT_STORE_NAME, null, CERT_STORE_PROVIDER_NAME);
assertNotNull(certStore);
assertNull(certStore.getCertStoreParameters());
assertEquals(CERT_STORE_PROVIDER_NAME, certStore.getProvider().getName());
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
try {
CertStore.getInstance("UnknownCertStore", new MyCertStoreParameters(), CERT_STORE_PROVIDER_NAME);
fail("expected NoSuchAlgorithmException");
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
// ok
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
try {
CertStore.getInstance(CERT_STORE_NAME, null, "UnknownCertStoreProvider");
fail("expected NoSuchProviderException");
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected exception: " + e);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
// ok
}
try {
CertStore.getInstance(CERT_STORE_NAME, new MyOtherCertStoreParameters(), CERT_STORE_PROVIDER_NAME);
} catch (InvalidAlgorithmParameterException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
}
use of java.security.cert.CertStoreParameters in project robovm by robovm.
the class CollectionCertStoreParametersTest method testCollectionCertStoreParameters01.
//
// Tests
//
/**
* Test #1 for <code>CollectionCertStoreParameters()</code> constructor<br>
*/
public final void testCollectionCertStoreParameters01() {
CertStoreParameters cp = new CollectionCertStoreParameters();
assertTrue("isCollectionCertStoreParameters", cp instanceof CollectionCertStoreParameters);
}
use of java.security.cert.CertStoreParameters in project Payara by payara.
the class JSSE14SocketFactory method getParameters.
/**
* Return the initialization parameters for the TrustManager. Currently, only the default <code>PKIX</code> is
* supported.
*
* @param algorithm The algorithm to get parameters for.
* @param crlf The path to the CRL file.
* @param trustStore The configured TrustStore.
*
* @return The parameters including the CRLs and TrustStore.
*/
protected CertPathParameters getParameters(String algorithm, String crlf, KeyStore trustStore) throws Exception {
CertPathParameters params;
if ("PKIX".equalsIgnoreCase(algorithm)) {
PKIXBuilderParameters xparams = new PKIXBuilderParameters(trustStore, new X509CertSelector());
Collection crls = getCRLs(crlf);
CertStoreParameters csp = new CollectionCertStoreParameters(crls);
CertStore store = CertStore.getInstance("Collection", csp);
xparams.addCertStore(store);
xparams.setRevocationEnabled(true);
String trustLength = (String) attributes.get("trustMaxCertLength");
if (trustLength != null) {
try {
xparams.setMaxPathLength(Integer.parseInt(trustLength));
} catch (Exception ex) {
logger.warning("Bad maxCertLength: " + trustLength);
}
}
params = xparams;
} else {
throw new CRLException("CRLs not supported for type: " + algorithm);
}
return params;
}
Aggregations