I've just created a simple example, which shows how we can implement simple authentication for string-based protocol using Grizzly 2.0.

Server side is implemented as a chain of following Filters:

TransportFilter StringFilter MultiLineFilter ServerAuthFilter EchoFilter

Client side filter chain is following:

TransportFilter StringFilter MultiLineFilter ClientAuthFilter ClientFilter

The most interesting thing happens on client side inside ClientAuthFilter. If it appears, that we're sending some message via non-authenticated client - ClientAuthFilter suspends the message(s) sending and initializes authentication process, once authentication will be completed - ClientAuthFilter resumes the suspended message writes.

So communication happens on following layers:



Client Server TransportFilter TransportFilter StringFilter StringFilter MultiLineFilter MultiLineFilter ClientAuthFilter ServerAuthFilter ClientFilter EchoFilter

More...