// Inject the chain
IoFilterChainBuilder udpChainBuilder = new DefaultIoFilterChainBuilder();
((DefaultIoFilterChainBuilder)udpChainBuilder).addFirst( "codec",
new ProtocolCodecFilter(
KerberosUdpProtocolCodecFactory.getInstance() ) );
acceptor.setFilterChainBuilder( udpChainBuilder );
// Inject the protocol handler
acceptor.setHandler( new KerberosProtocolHandler( this, store ) );
// Bind to the configured address
acceptor.bind();
}
else
{
// Kerberos can use UDP or TCP
for ( Transport transport:transports )
{
IoAcceptor acceptor = transport.getAcceptor();
// Now, configure the acceptor
// Inject the chain
IoFilterChainBuilder chainBuilder = new DefaultIoFilterChainBuilder();
if ( transport instanceof TcpTransport )
{
// Now, configure the acceptor
// Disable the disconnection of the clients on unbind
acceptor.setCloseOnDeactivation( false );
// No Nagle's algorithm
((NioSocketAcceptor)acceptor).getSessionConfig().setTcpNoDelay( true );
// Allow the port to be reused even if the socket is in TIME_WAIT state
((NioSocketAcceptor)acceptor).setReuseAddress( true );
// Inject the codec
((DefaultIoFilterChainBuilder)chainBuilder).addFirst( "codec",
new ProtocolCodecFilter(
KerberosTcpProtocolCodecFactory.getInstance() ) );
}
else
{
// Inject the codec
((DefaultIoFilterChainBuilder)chainBuilder).addFirst( "codec",
new ProtocolCodecFilter(
KerberosUdpProtocolCodecFactory.getInstance() ) );
}
acceptor.setFilterChainBuilder( chainBuilder );