Search in sources :

Example 6 with SSLContextSpi

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());
}
Also used : MySSLContextSpi(org.apache.harmony.xnet.tests.support.MySSLContextSpi) MySSLContextSpi(org.apache.harmony.xnet.tests.support.MySSLContextSpi) SSLContextSpi(javax.net.ssl.SSLContextSpi) SSLContext(javax.net.ssl.SSLContext)

Example 7 with SSLContextSpi

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) {
    }
}
Also used : MySSLContextSpi(org.apache.harmony.xnet.tests.support.MySSLContextSpi) MySSLContextSpi(org.apache.harmony.xnet.tests.support.MySSLContextSpi) SSLContextSpi(javax.net.ssl.SSLContextSpi) SecureRandom(java.security.SecureRandom) SSLContext(javax.net.ssl.SSLContext) KeyManager(javax.net.ssl.KeyManager) KeyManagementException(java.security.KeyManagementException) TrustManager(javax.net.ssl.TrustManager)

Aggregations

SSLContextSpi (javax.net.ssl.SSLContextSpi)7 SSLContext (javax.net.ssl.SSLContext)6 MySSLContextSpi (org.apache.harmony.xnet.tests.support.MySSLContextSpi)6 SecureRandom (java.security.SecureRandom)4 KeyManagementException (java.security.KeyManagementException)3 SSLEngine (javax.net.ssl.SSLEngine)2 TrustManager (javax.net.ssl.TrustManager)2 FileNotFoundException (java.io.FileNotFoundException)1 KeyStore (java.security.KeyStore)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 KeyManager (javax.net.ssl.KeyManager)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)1 SSLContextSpiImpl (org.apache.harmony.xnet.tests.support.SSLContextSpiImpl)1