Search in sources :

Example 1 with JMXSslConfigHolder

use of org.glassfish.admin.mbeanserver.JMXSslConfigHolder 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

ServerSocket (java.net.ServerSocket)1 SSLContext (javax.net.ssl.SSLContext)1 SSLException (javax.net.ssl.SSLException)1 SSLServerSocket (javax.net.ssl.SSLServerSocket)1 JMXSslConfigHolder (org.glassfish.admin.mbeanserver.JMXSslConfigHolder)1