users@grizzly.java.net

grizzly 2.0 : converting server, issue 2

From: buzz lightyear <buzzheavyyear_at_hotmail.com>
Date: Fri, 1 May 2009 13:34:01 +0000

Hi

I'm converting a tcp server to grizzy 2 and I have the
following code that I need to embed in a FilterAdapter, but I can't
work out how to set up the current grizzly socket as a new SSLSocket for tls.

I've read the SSLEchoServer example, but this only works during the initialisation phase and I can't see how to set up the socket in an adhoc manner.

            java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
            SSLSocketFactory factory = protocol.getSslSocketFactory();
            Socket oldSocket = getSocket();
            final SSLSocket newSocket = (SSLSocket) factory.createSocket(
                    oldSocket, oldSocket.getLocalAddress().getHostName(),
                    oldSocket.getLocalPort(), true);
            newSocket.setNeedClientAuth(protocol.isRequireClientCert());
            newSocket.setUseClientMode(false);
            response.setSocketOverride(newSocket);

Thanks

Nick

_________________________________________________________________
Beyond Hotmail — see what else you can do with Windows Live.
http://clk.atdmt.com/UKM/go/134665375/direct/01/