Search in sources :

Example 11 with SSLParameters

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

the class SSLParametersTest method test_SSLParameters_CipherSuites.

public void test_SSLParameters_CipherSuites() {
    SSLParameters p = new SSLParameters();
    assertNull(p.getCipherSuites());
    // confirm clone on input
    String[] cipherSuites = new String[] { "fnord" };
    String[] copy = cipherSuites.clone();
    p.setCipherSuites(copy);
    copy[0] = null;
    assertEquals(Arrays.asList(cipherSuites), Arrays.asList(p.getCipherSuites()));
    // confirm clone on output
    assertNotSame(p.getCipherSuites(), p.getCipherSuites());
}
Also used : SSLParameters(javax.net.ssl.SSLParameters)

Example 12 with SSLParameters

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

the class SSLParametersTest method test_SSLParameters_ClientAuth.

public void test_SSLParameters_ClientAuth() {
    SSLParameters p = new SSLParameters();
    assertFalse(p.getWantClientAuth());
    assertFalse(p.getNeedClientAuth());
    // confirm turning one on by itself
    p.setWantClientAuth(true);
    assertTrue(p.getWantClientAuth());
    assertFalse(p.getNeedClientAuth());
    // confirm turning setting on toggles the other
    p.setNeedClientAuth(true);
    assertFalse(p.getWantClientAuth());
    assertTrue(p.getNeedClientAuth());
    // confirm toggling back
    p.setWantClientAuth(true);
    assertTrue(p.getWantClientAuth());
    assertFalse(p.getNeedClientAuth());
}
Also used : SSLParameters(javax.net.ssl.SSLParameters)

Example 13 with SSLParameters

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

the class SSLParametersTest method test_SSLParameters_Protocols.

public void test_SSLParameters_Protocols() {
    SSLParameters p = new SSLParameters();
    assertNull(p.getProtocols());
    // confirm clone on input
    String[] protocols = new String[] { "fnord" };
    String[] copy = protocols.clone();
    p.setProtocols(copy);
    copy[0] = null;
    assertEquals(Arrays.asList(protocols), Arrays.asList(p.getProtocols()));
    // confirm clone on output
    assertNotSame(p.getProtocols(), p.getProtocols());
}
Also used : SSLParameters(javax.net.ssl.SSLParameters)

Example 14 with SSLParameters

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

the class SSLEngineTest method test_SSLEngine_setSSLParameters.

public void test_SSLEngine_setSSLParameters() throws Exception {
    TestSSLContext c = TestSSLContext.create();
    SSLEngine e = c.clientContext.createSSLEngine();
    String[] defaultCipherSuites = e.getEnabledCipherSuites();
    String[] defaultProtocols = e.getEnabledProtocols();
    String[] supportedCipherSuites = e.getSupportedCipherSuites();
    String[] supportedProtocols = e.getSupportedProtocols();
    {
        SSLParameters p = new SSLParameters();
        e.setSSLParameters(p);
        assertEquals(Arrays.asList(defaultCipherSuites), Arrays.asList(e.getEnabledCipherSuites()));
        assertEquals(Arrays.asList(defaultProtocols), Arrays.asList(e.getEnabledProtocols()));
    }
    {
        SSLParameters p = new SSLParameters(supportedCipherSuites, supportedProtocols);
        e.setSSLParameters(p);
        assertEquals(Arrays.asList(supportedCipherSuites), Arrays.asList(e.getEnabledCipherSuites()));
        assertEquals(Arrays.asList(supportedProtocols), Arrays.asList(e.getEnabledProtocols()));
    }
    {
        SSLParameters p = new SSLParameters();
        p.setNeedClientAuth(true);
        assertFalse(e.getNeedClientAuth());
        assertFalse(e.getWantClientAuth());
        e.setSSLParameters(p);
        assertTrue(e.getNeedClientAuth());
        assertFalse(e.getWantClientAuth());
        p.setWantClientAuth(true);
        assertTrue(e.getNeedClientAuth());
        assertFalse(e.getWantClientAuth());
        e.setSSLParameters(p);
        assertFalse(e.getNeedClientAuth());
        assertTrue(e.getWantClientAuth());
        p.setWantClientAuth(false);
        assertFalse(e.getNeedClientAuth());
        assertTrue(e.getWantClientAuth());
        e.setSSLParameters(p);
        assertFalse(e.getNeedClientAuth());
        assertFalse(e.getWantClientAuth());
    }
    c.close();
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) SSLEngine(javax.net.ssl.SSLEngine)

Example 15 with SSLParameters

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

the class SSLSocketTest method test_SSLSocket_setSSLParameters.

public void test_SSLSocket_setSSLParameters() throws Exception {
    SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault();
    SSLSocket ssl = (SSLSocket) sf.createSocket();
    String[] defaultCipherSuites = ssl.getEnabledCipherSuites();
    String[] defaultProtocols = ssl.getEnabledProtocols();
    String[] supportedCipherSuites = ssl.getSupportedCipherSuites();
    String[] supportedProtocols = ssl.getSupportedProtocols();
    {
        SSLParameters p = new SSLParameters();
        ssl.setSSLParameters(p);
        assertEquals(Arrays.asList(defaultCipherSuites), Arrays.asList(ssl.getEnabledCipherSuites()));
        assertEquals(Arrays.asList(defaultProtocols), Arrays.asList(ssl.getEnabledProtocols()));
    }
    {
        SSLParameters p = new SSLParameters(supportedCipherSuites, supportedProtocols);
        ssl.setSSLParameters(p);
        assertEquals(Arrays.asList(supportedCipherSuites), Arrays.asList(ssl.getEnabledCipherSuites()));
        assertEquals(Arrays.asList(supportedProtocols), Arrays.asList(ssl.getEnabledProtocols()));
    }
    {
        SSLParameters p = new SSLParameters();
        p.setNeedClientAuth(true);
        assertFalse(ssl.getNeedClientAuth());
        assertFalse(ssl.getWantClientAuth());
        ssl.setSSLParameters(p);
        assertTrue(ssl.getNeedClientAuth());
        assertFalse(ssl.getWantClientAuth());
        p.setWantClientAuth(true);
        assertTrue(ssl.getNeedClientAuth());
        assertFalse(ssl.getWantClientAuth());
        ssl.setSSLParameters(p);
        assertFalse(ssl.getNeedClientAuth());
        assertTrue(ssl.getWantClientAuth());
        p.setWantClientAuth(false);
        assertFalse(ssl.getNeedClientAuth());
        assertTrue(ssl.getWantClientAuth());
        ssl.setSSLParameters(p);
        assertFalse(ssl.getNeedClientAuth());
        assertFalse(ssl.getWantClientAuth());
    }
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) SSLSocket(javax.net.ssl.SSLSocket) SSLSocketFactory(javax.net.ssl.SSLSocketFactory)

Aggregations

SSLParameters (javax.net.ssl.SSLParameters)153 SSLEngine (javax.net.ssl.SSLEngine)41 SSLContext (javax.net.ssl.SSLContext)29 SSLSocket (javax.net.ssl.SSLSocket)29 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)21 IOException (java.io.IOException)19 Test (org.junit.Test)18 Test (org.testng.annotations.Test)18 InetSocketAddress (java.net.InetSocketAddress)17 SNIHostName (javax.net.ssl.SNIHostName)16 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)13 SSLException (javax.net.ssl.SSLException)11 SslHandler (io.netty.handler.ssl.SslHandler)10 ArrayList (java.util.ArrayList)10 CertificateException (java.security.cert.CertificateException)9 ByteString (com.linkedin.data.ByteString)8 SNIServerName (javax.net.ssl.SNIServerName)8 HttpsConfigurator (com.sun.net.httpserver.HttpsConfigurator)7 HttpsParameters (com.sun.net.httpserver.HttpsParameters)7 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)7