Search in sources :

Example 66 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project Payara by payara.

the class JSSESocketFactory method initServerSocket.

/**
 * Configures the given SSL server socket with the requested cipher suites, protocol versions, and need for client
 * authentication
 */
protected void initServerSocket(ServerSocket ssocket) {
    if (!(ssocket instanceof SSLServerSocket)) {
        throw new IllegalArgumentException("The ServerSocket has to be SSLServerSocket");
    }
    SSLServerSocket socket = (SSLServerSocket) ssocket;
    if (attributes.get("ciphers") != null) {
        socket.setEnabledCipherSuites(enabledCiphers);
    }
    String requestedProtocols = (String) attributes.get("protocols");
    setEnabledProtocols(socket, getEnabledProtocols(socket, requestedProtocols));
    // after parsing the request we may re-handshake
    if (clientAuthNeed) {
        socket.setNeedClientAuth(clientAuthNeed);
    } else {
        socket.setWantClientAuth(clientAuthWant);
    }
}
Also used : SSLServerSocket(javax.net.ssl.SSLServerSocket)

Example 67 with SSLServerSocket

use of javax.net.ssl.SSLServerSocket in project Payara by payara.

the class SecureRMIServerSocketFactory method createServerSocket.

@Override
public ServerSocket createServerSocket(int port) throws IOException {
    // debug( "MyRMIServerSocketFactory.createServerSocket(): " + mAddress + " : " + port );
    if (socketMap.containsKey(port)) {
        return (ServerSocket) socketMap.get(port);
    }
    // plenty
    final int backlog = 5;
    // we use a custom class here. The reason is mentioned in the class.
    final JMXSslConfigHolder sslConfigHolder;
    try {
        sslConfigHolder = new JMXSslConfigHolder(habitat, ssl);
    } catch (SSLException ssle) {
        throw new IllegalStateException(ssle);
    }
    final SSLContext context = sslConfigHolder.getSslContext();
    ServerSocket sslSocket = context.getServerSocketFactory().createServerSocket(port, backlog, mAddress);
    if (!(sslSocket instanceof SSLServerSocket)) {
        throw new IllegalStateException("ServerSocketFactory returned non-secure server socket.");
    }
    configureSSLSocket((SSLServerSocket) sslSocket, sslConfigHolder);
    Util.getLogger().log(Level.INFO, createdServerSocket, new Object[] { sslSocket.getLocalSocketAddress(), sslSocket.toString() });
    // sslSocket.startHandshake();
    // debug( "MyRMIServerSocketFactory.createServerSocket(): " + mAddress + " : " + port );
    socketMap.put(port, sslSocket);
    return sslSocket;
}
Also used : JMXSslConfigHolder(org.glassfish.admin.mbeanserver.JMXSslConfigHolder) ServerSocket(java.net.ServerSocket) SSLServerSocket(javax.net.ssl.SSLServerSocket) SSLContext(javax.net.ssl.SSLContext) SSLServerSocket(javax.net.ssl.SSLServerSocket) SSLException(javax.net.ssl.SSLException)

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