Thursday Feb 25, 2010

Grizzly 2.0: simple authentication example

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 <- Buffer -> StringFilter <- String -> MultiLineFilter <- MultiLinePacket w/ auth headers -> ServerAuthFilter <- MultiLinePacket w/o auth headers -> EchoFilter

Client side filter chain is following:

TransportFilter <- Buffer -> StringFilter <- String -> MultiLineFilter <- MultiLinePacket w/ auth headers -> ClientAuthFilter <- MultiLinePacket w/o auth headers -> 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 <- Authentication messages -> ServerAuthFilter
ClientFilter <-- Cusom Messages --> EchoFilter
About

oleksiys

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today