use of javax.net.ssl.SSLContextSpi in project robovm by robovm.
the class MySslContext method test_createSSLEngine.
/**
* @throws KeyManagementException
* javax.net.ssl.SSLContext#createSSLEngine()
*/
public void test_createSSLEngine() throws KeyManagementException {
if (!DEFSupported)
fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol);
sslContext.init(null, null, new SecureRandom());
SSLEngine sslEngine = sslContext.createSSLEngine();
assertNotNull("SSL engine is null", sslEngine);
}
use of javax.net.ssl.SSLContextSpi in project robovm by robovm.
the class MySslContext method test_createSSLEngineLjava_lang_StringI.
/**
* @throws KeyManagementException
* javax.net.ssl.SSLContext#createSSLEngine(java.lang.String, int)
*/
public void test_createSSLEngineLjava_lang_StringI() throws KeyManagementException {
if (!DEFSupported)
fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol);
sslContext.init(null, null, new SecureRandom());
SSLEngine sslEngine = sslContext.createSSLEngine("www.fortify.net", 80);
assertNotNull("SSL engine is null", sslEngine);
}
use of javax.net.ssl.SSLContextSpi in project robovm by robovm.
the class MySslContext method test_init$Ljavax_net_ssl_KeyManager$Ljavax_net_ssl_TrustManagerLjava_security_SecureRandom.
/**
* @throws NoSuchAlgorithmException
* @throws KeyStoreException
* @throws FileNotFoundException
* @throws KeyManagementException
* javax.net.ssl.SSLContext#
* init(javax.net.ssl.KeyManager[], javax.net.ssl.TrustManager[],
* java.security.SecureRandom)
*/
public void test_init$Ljavax_net_ssl_KeyManager$Ljavax_net_ssl_TrustManagerLjava_security_SecureRandom() throws Exception {
if (!DEFSupported)
fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol);
try {
sslContext.createSSLEngine();
fail("Expected RuntimeException was not thrown");
} catch (RuntimeException rte) {
// expected
}
try {
sslContext.init(null, null, null);
fail("KeyManagementException wasn't thrown");
} catch (KeyManagementException kme) {
//expected
}
try {
String tAlg = TrustManagerFactory.getDefaultAlgorithm();
String kAlg = KeyManagerFactory.getDefaultAlgorithm();
if (tAlg == null)
fail("TrustManagerFactory default algorithm is not defined");
if (kAlg == null)
fail("KeyManagerFactory default algorithm is not defined");
KeyManagerFactory kmf = KeyManagerFactory.getInstance(kAlg);
kmf.init(null, new char[11]);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tAlg);
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
tmf.init(ks);
TrustManager[] tms = tmf.getTrustManagers();
sslContext.init(kmf.getKeyManagers(), tms, new SecureRandom());
} catch (Exception e) {
System.out.println("EE = " + e);
}
}
use of javax.net.ssl.SSLContextSpi in project robovm by robovm.
the class SSLContextSpiTest method test_Constructor.
/**
* javax.net.ssl.SSLContextSpi#SSLContextSpi()
*/
public void test_Constructor() {
try {
SSLContextSpiImpl ssl = new SSLContextSpiImpl();
assertTrue(ssl instanceof SSLContextSpi);
} catch (Exception e) {
fail("Unexpected exception " + e.toString());
}
}
use of javax.net.ssl.SSLContextSpi in project robovm by robovm.
the class MySslContext method test_getProtocol.
/**
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* javax.net.ssl.SSLContext#getProtocol()
*/
public void test_getProtocol() throws NoSuchAlgorithmException, NoSuchProviderException {
if (!DEFSupported)
fail(NotSupportMsg);
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol);
assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol());
sslContext = new MySslContext(spi, defaultProvider, null);
assertNull("Incorrect protocol", sslContext.getProtocol());
sslContext = SSLContext.getInstance(defaultProtocol);
assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol());
sslContext = SSLContext.getInstance(defaultProtocol, defaultProvider);
assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol());
sslContext = SSLContext.getInstance(defaultProtocol, defaultProviderName);
assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol());
}
Aggregations