use of javax.net.ssl.SSLContextSpi in project robovm by robovm.
the class MySslContext method test_getProvider.
/**
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* javax.net.ssl.SSLContext#getProvider()
*/
public void test_getProvider() throws NoSuchAlgorithmException, NoSuchProviderException {
if (!DEFSupported)
fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol);
assertEquals("Incorrect provider", defaultProvider, sslContext.getProvider());
sslContext = SSLContext.getInstance(defaultProtocol, defaultProvider);
assertEquals("Incorrect provider", defaultProvider, sslContext.getProvider());
sslContext = SSLContext.getInstance(defaultProtocol, defaultProviderName);
assertEquals("Incorrect provider", defaultProvider, sslContext.getProvider());
}
use of javax.net.ssl.SSLContextSpi in project robovm by robovm.
the class MySslContext method test_ConstructorLjavax_net_ssl_SSLContextSpiLjava_security_ProviderLjava_lang_String.
/**
* Test for <code>SSLContext</code> constructor Assertion: returns
* SSLContext object
*/
public void test_ConstructorLjavax_net_ssl_SSLContextSpiLjava_security_ProviderLjava_lang_String() throws NoSuchAlgorithmException, KeyManagementException {
if (!DEFSupported) {
fail(NotSupportMsg);
return;
}
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol);
assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol());
assertEquals("Incorrect provider", defaultProvider, sslContext.getProvider());
TrustManager[] tm = null;
KeyManager[] km = null;
sslContext.init(km, tm, new SecureRandom());
assertNotNull("No SSLEngine created", sslContext.createSSLEngine());
assertNotNull("No SSLEngine created", sslContext.createSSLEngine("host", 8888));
try {
sslContext.init(km, tm, null);
fail("KeyManagementException should be thrown for null " + "SecureRandom");
} catch (KeyManagementException e) {
}
sslContext = new MySslContext(null, null, null);
assertNull("Incorrect protocol", sslContext.getProtocol());
assertNull("Incorrect provider", sslContext.getProvider());
try {
sslContext.createSSLEngine();
fail("NullPointerException should be thrown");
} catch (NullPointerException e) {
}
try {
sslContext.getSocketFactory();
fail("NullPointerException should be thrown");
} catch (NullPointerException e) {
}
}
Aggregations