use of java.security.cert.CertPathParameters in project robovm by robovm.
the class CertPathValidatorSpiTest method testCertPathValidatorSpi01.
/**
* Test for <code>CertPathValidatorSpi</code> constructor Assertion:
* constructs CertPathValidatorSpi
*/
public void testCertPathValidatorSpi01() throws CertPathValidatorException, InvalidAlgorithmParameterException {
CertPathValidatorSpi certPathValid = new MyCertPathValidatorSpi();
CertPathParameters params = null;
CertPath certPath = null;
CertPathValidatorResult cpvResult = certPathValid.engineValidate(certPath, params);
assertNull("Not null CertPathValidatorResult", cpvResult);
try {
certPathValid.engineValidate(certPath, params);
fail("CertPathValidatorException must be thrown");
} catch (CertPathValidatorException e) {
}
try {
certPathValid.engineValidate(certPath, params);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
}
use of java.security.cert.CertPathParameters in project robovm by robovm.
the class myCertPathBuilder method testBuild.
// Test passed on RI
@KnownFailure(value = "expired certificate bug 2322662")
public void testBuild() throws Exception {
TestUtils.initCertPathSSCertChain();
CertPathParameters params = TestUtils.getCertPathParameters();
CertPathBuilder builder = TestUtils.getCertPathBuilder();
try {
CertPathBuilderResult result = builder.build(params);
assertNotNull("builder result is null", result);
CertPath certPath = result.getCertPath();
assertNotNull("certpath of builder result is null", certPath);
} catch (InvalidAlgorithmParameterException e) {
fail("unexpected Exception: " + e);
}
}
use of java.security.cert.CertPathParameters in project robovm by robovm.
the class MyCertPathParameters method test_ConstructorLjava_security_cert_CertPathParameters.
/**
* javax.net.ssl.CertPathTrustManagerParameters#
* CertPathTrustManagerParameters(java.security.cert.CertPathParameters)
* Case 1: Try to construct object.
* Case 2: Check NullPointerException.
*/
public void test_ConstructorLjava_security_cert_CertPathParameters() {
// case 1: Try to construct object.
try {
CertPathParameters parameters = new MyCertPathParameters();
CertPathTrustManagerParameters p = new CertPathTrustManagerParameters(parameters);
assertNotSame("Parameters were cloned incorrectly", parameters, p.getParameters());
} catch (Exception e) {
fail("Unexpected exception " + e.toString());
}
// case 2: Check NullPointerException.
try {
new CertPathTrustManagerParameters(null);
fail("Expected CertPathTrustManagerParameters was not thrown");
} catch (NullPointerException npe) {
// expected
}
}
use of java.security.cert.CertPathParameters in project robovm by robovm.
the class MyCertPathParameters method test_getParameters.
/**
* javax.net.ssl.CertPathTrustManagerParameters#getParameters()
*/
public void test_getParameters() {
CertPathParameters parameters = new MyCertPathParameters();
CertPathTrustManagerParameters p = new CertPathTrustManagerParameters(parameters);
if (!(p.getParameters() instanceof MyCertPathParameters)) {
fail("incorrect parameters");
}
assertNotSame("Parameters were cloned incorrectly", parameters, p.getParameters());
}
use of java.security.cert.CertPathParameters in project tomcat70 by apache.
the class JSSESocketFactory method getTrustManagers.
/**
* Gets the initialized trust managers.
*/
protected TrustManager[] getTrustManagers(String keystoreType, String keystoreProvider, String algorithm) throws Exception {
String crlf = endpoint.getCrlFile();
String className = endpoint.getTrustManagerClassName();
if (className != null && className.length() > 0) {
ClassLoader classLoader = getClass().getClassLoader();
Class<?> clazz = classLoader.loadClass(className);
if (!(TrustManager.class.isAssignableFrom(clazz))) {
throw new InstantiationException(sm.getString("jsse.invalidTrustManagerClassName", className));
}
Object trustManagerObject = clazz.newInstance();
TrustManager trustManager = (TrustManager) trustManagerObject;
return new TrustManager[] { trustManager };
}
TrustManager[] tms = null;
KeyStore trustStore = getTrustStore(keystoreType, keystoreProvider);
if (trustStore != null || endpoint.getTrustManagerClassName() != null) {
if (crlf == null) {
TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm);
tmf.init(trustStore);
tms = tmf.getTrustManagers();
} else {
TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm);
CertPathParameters params = getParameters(algorithm, crlf, trustStore);
ManagerFactoryParameters mfp = new CertPathTrustManagerParameters(params);
tmf.init(mfp);
tms = tmf.getTrustManagers();
}
}
return tms;
}
Aggregations