Search in sources :

Example 51 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project robovm by robovm.

the class SSLServerSocketTest method test_EnableSessionCreation.

/**
     * @throws IOException
     * javax.net.ssl.SSLServerSocket#setEnableSessionCreation(boolean flag)
     * javax.net.ssl.SSLServerSocket#getEnableSessionCreation()
     */
public void test_EnableSessionCreation() throws Exception {
    SSLServerSocket sss = getSSLServerSocket();
    assertTrue(sss.getEnableSessionCreation());
    sss.setEnableSessionCreation(false);
    assertFalse(sss.getEnableSessionCreation());
    sss.setEnableSessionCreation(true);
    assertTrue(sss.getEnableSessionCreation());
}
Also used : SSLServerSocket(javax.net.ssl.SSLServerSocket)

Example 52 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project robovm by robovm.

the class SSLServerSocketTest method test_EnabledCipherSuites.

/**
     * @throws IOException
     * javax.net.ssl.SSLServerSocket#getEnabledCipherSuites()
     * javax.net.ssl.SSLServerSocket#setEnabledCipherSuites(String[] suites)
     */
public void test_EnabledCipherSuites() throws Exception {
    SSLServerSocket sss = getSSLServerSocket();
    try {
        sss.setEnabledCipherSuites(null);
    } catch (IllegalArgumentException iae) {
    //expected
    }
    String[] unsupportedCipherSuites = { "unsupported" };
    try {
        sss.setEnabledCipherSuites(unsupportedCipherSuites);
    } catch (IllegalArgumentException iae) {
    //expected
    }
    int count = sss.getSupportedCipherSuites().length;
    assertTrue("No supported cipher suites", count > 0);
    sss.setEnabledCipherSuites(sss.getSupportedCipherSuites());
    String[] res = sss.getEnabledCipherSuites();
    assertNotNull("NULL result", res);
    assertEquals("not all supported cipher suites were enabled", Arrays.asList(sss.getSupportedCipherSuites()), Arrays.asList(res));
}
Also used : SSLServerSocket(javax.net.ssl.SSLServerSocket)

Example 53 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project robovm by robovm.

the class SSLServerSocketTest method test_NeedClientAuth.

/**
     * @throws IOException
     * javax.net.ssl.SSLServerSocket#setNeedClientAuth(boolean need)
     * javax.net.ssl.SSLServerSocket#getNeedClientAuthCreation()
     */
public void test_NeedClientAuth() throws Exception {
    SSLServerSocket sss = getSSLServerSocket();
    sss.setNeedClientAuth(true);
    assertTrue(sss.getNeedClientAuth());
    sss.setNeedClientAuth(false);
    assertFalse(sss.getNeedClientAuth());
}
Also used : SSLServerSocket(javax.net.ssl.SSLServerSocket)

Example 54 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project robovm by robovm.

the class SSLServerSocketTest method testConstructor_I.

/**
     * javax.net.ssl.SSLServerSocket#SSLServerSocket(int port)
     */
public void testConstructor_I() throws Exception {
    int[] port_invalid = { -1, 65536, Integer.MIN_VALUE, Integer.MAX_VALUE };
    SSLServerSocket ssl = new mySSLServerSocket(0);
    for (int i = 0; i < port_invalid.length; i++) {
        try {
            new mySSLServerSocket(port_invalid[i]);
            fail("IllegalArgumentException should be thrown");
        } catch (IllegalArgumentException expected) {
        }
    }
    try {
        new mySSLServerSocket(ssl.getLocalPort());
        fail("IOException Expected when opening an already opened port");
    } catch (IOException expected) {
    }
}
Also used : IOException(java.io.IOException) SSLServerSocket(javax.net.ssl.SSLServerSocket)

Example 55 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project robovm by robovm.

the class SSLServerSocketTest method test_UseClientMode.

/**
     * @throws IOException
     * javax.net.ssl.SSLServerSocket#getUseClientMode()
     * javax.net.ssl.SSLServerSocket#setUseClientMode(boolean mode)
     */
public void test_UseClientMode() throws Exception {
    SSLServerSocket sss = getSSLServerSocket();
    sss.setUseClientMode(false);
    assertFalse(sss.getUseClientMode());
    sss.setUseClientMode(true);
    assertTrue(sss.getUseClientMode());
}
Also used : SSLServerSocket(javax.net.ssl.SSLServerSocket)

Aggregations

SSLServerSocket (javax.net.ssl.SSLServerSocket)67 SSLContext (javax.net.ssl.SSLContext)24 SSLSocket (javax.net.ssl.SSLSocket)19 InetSocketAddress (java.net.InetSocketAddress)15 SSLServerSocketFactory (javax.net.ssl.SSLServerSocketFactory)14 IOException (java.io.IOException)13 ServerSocket (java.net.ServerSocket)12 URL (java.net.URL)10 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)10 SSLEngine (javax.net.ssl.SSLEngine)9 UnknownHostException (java.net.UnknownHostException)7 Proxy (java.net.Proxy)6 Test (org.junit.Test)6 InetAddress (java.net.InetAddress)5 Method (java.lang.reflect.Method)3 KeyManagementException (java.security.KeyManagementException)3 KeyStore (java.security.KeyStore)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 ArrayList (java.util.ArrayList)3 ServerSocketFactory (javax.net.ServerSocketFactory)3