Search in sources :

Example 56 with SSLServerSocket

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

the class SSLServerSocketTest method test_getSupportedCipherSuites.

/**
     * @throws Exception
     * javax.net.ssl.SSLServerSocket#getSupportedCipherSuites()
     */
public void test_getSupportedCipherSuites() throws Exception {
    SSLServerSocket sss = getSSLServerSocket();
    String[] res = sss.getSupportedCipherSuites();
    assertNotNull("NULL result", res);
    assertTrue("no supported cipher suites available.", res.length > 0);
}
Also used : SSLServerSocket(javax.net.ssl.SSLServerSocket)

Example 57 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project cloudstack by apache.

the class ConsoleProxySecureServerFactoryImpl method createSSLServerSocket.

@Override
public SSLServerSocket createSSLServerSocket(int port) throws IOException {
    try {
        SSLServerSocket srvSock = null;
        SSLServerSocketFactory ssf = sslContext.getServerSocketFactory();
        srvSock = (SSLServerSocket) ssf.createServerSocket(port);
        srvSock.setEnabledProtocols(SSLUtils.getSupportedProtocols(srvSock.getEnabledProtocols()));
        s_logger.info("create SSL server socket on port: " + port);
        return srvSock;
    } catch (Exception ioe) {
        s_logger.error(ioe.toString(), ioe);
    }
    return null;
}
Also used : SSLServerSocketFactory(javax.net.ssl.SSLServerSocketFactory) SSLServerSocket(javax.net.ssl.SSLServerSocket) IOException(java.io.IOException)

Example 58 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project jdk8u_jdk by JetBrains.

the class SSLEchoServer method init.

/*
     * Creates server instance.
     *
     * @param cipherSuiteFilter Filter for enabled cipher suites
     * @param sniMatcherPattern Pattern for SNI server hame
     */
static SSLEchoServer init(String cipherSuiteFilter, String sniPattern) throws NoSuchAlgorithmException, IOException {
    SSLContext context = SSLContext.getDefault();
    SSLServerSocketFactory ssf = (SSLServerSocketFactory) context.getServerSocketFactory();
    SSLServerSocket ssocket = (SSLServerSocket) ssf.createServerSocket(0);
    // specify enabled cipher suites
    if (cipherSuiteFilter != null) {
        String[] ciphersuites = UnboundSSLUtils.filterStringArray(ssf.getSupportedCipherSuites(), cipherSuiteFilter);
        System.out.println("Server: enabled cipher suites: " + Arrays.toString(ciphersuites));
        ssocket.setEnabledCipherSuites(ciphersuites);
    }
    // specify SNI matcher pattern
    if (sniPattern != null) {
        System.out.println("Server: set SNI matcher: " + sniPattern);
        SNIMatcher matcher = SNIHostName.createSNIMatcher(sniPattern);
        List<SNIMatcher> matchers = new ArrayList<>();
        matchers.add(matcher);
        SSLParameters params = ssocket.getSSLParameters();
        params.setSNIMatchers(matchers);
        ssocket.setSSLParameters(params);
    }
    return new SSLEchoServer(ssocket);
}
Also used : SNIMatcher(javax.net.ssl.SNIMatcher) SSLParameters(javax.net.ssl.SSLParameters) ArrayList(java.util.ArrayList) SSLServerSocketFactory(javax.net.ssl.SSLServerSocketFactory) SSLContext(javax.net.ssl.SSLContext) SSLServerSocket(javax.net.ssl.SSLServerSocket)

Example 59 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project jdk8u_jdk by JetBrains.

the class Timeout method main.

public static void main(String[] args) throws Exception {
    //        try {
    SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    SSLServerSocket ss = (SSLServerSocket) ssf.createServerSocket();
    String[] protocols = ss.getSupportedProtocols();
    for (int i = 0; i < protocols.length; i++) {
        //                try {
        if (protocols[i].equals("SSLv2Hello")) {
            continue;
        }
        SSLContext sslc = SSLContext.getInstance(protocols[i]);
        SSLSessionContext sslsc = sslc.getServerSessionContext();
        System.out.println("Protocol: " + protocols[i]);
        sslsc.setSessionTimeout(Integer.MAX_VALUE);
        int newtime = sslsc.getSessionTimeout();
        if (newtime != Integer.MAX_VALUE) {
            throw new Exception("Expected timeout: " + Integer.MAX_VALUE + ", got instead: " + newtime);
        }
    //                } catch (Exception e) {
    //                }
    }
    //        } catch (Exception e) {
    //            System.out.println(e);
    //        }
    System.out.println("Finished");
}
Also used : SSLSessionContext(javax.net.ssl.SSLSessionContext) SSLServerSocketFactory(javax.net.ssl.SSLServerSocketFactory) SSLContext(javax.net.ssl.SSLContext) SSLServerSocket(javax.net.ssl.SSLServerSocket)

Example 60 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project karaf by apache.

the class IntrospectionSupport method setProperty.

public static boolean setProperty(Object target, String name, Object value) {
    try {
        Class<?> clazz = target.getClass();
        if (target instanceof SSLServerSocket) {
            // overcome illegal access issues with internal implementation class
            clazz = SSLServerSocket.class;
        }
        Method setter = findSetterMethod(clazz, name);
        if (setter == null) {
            return false;
        }
        // value directly
        if (value == null || value.getClass() == setter.getParameterTypes()[0]) {
            setter.invoke(target, value);
        } else {
            // We need to convert it
            setter.invoke(target, convert(value, setter.getParameterTypes()[0]));
        }
        return true;
    } catch (Exception e) {
        LOG.error(String.format("Could not set property %s on %s", name, target), e);
        return false;
    }
}
Also used : Method(java.lang.reflect.Method) 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