}
public void sessionStarted(SessionFilterChain filterChain) throws Exception {
// init engine
Session session = filterChain.getSession();
SocketAddress address = session.getRemoteAddress();
if (clientMode && (address instanceof InetSocketAddress)) {
InetSocketAddress netAddress = (InetSocketAddress) address;
engine = sslc.createSSLEngine(netAddress.getAddress()
.getHostAddress(), netAddress.getPort());
} else {
engine = sslc.createSSLEngine();
}
engine.setUseClientMode(clientMode);
engine.setNeedClientAuth(needClientAuth);
initSSLEngine(engine);
appBufferSize = engine.getSession().getApplicationBufferSize();
netBufferSize = engine.getSession().getPacketBufferSize();
// handshake
engine.beginHandshake();
super.sessionStarted(filterChain);
if (clientMode)
session.flush(new HandshakePacket());
}