You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Germán Borbolla Flores <gb...@insys-corp.com.mx> on 2007/06/20 18:28:48 UTC

Question regarding filters

Hello, we've developed an in-house framework for secure communications 
using our own mechanism for handshaking and encryption, right now this 
framework is using blocking sockets, I'm migrating it to use MINA so we 
can improve its scalability.

I will like to implement handshaking and encryption as filters, but i 
have found a little issue while doing this, I need that both filters are 
able to send data back to its peer during the processing of an incoming 
message that is while the invocation of messageReceived. Right now I'm 
doing this by invoking session.write and setting and attribute in the 
session so any "upper" filter, such as ProtocolCodecFilter (I extended 
it so it can handle this special case) know that it should ignore this 
message. I don't like this workaround so I've been wondering is there is 
a more elegant or correct way to do this?

If there isn't any, I was thinking about changing IoFilter and add to 
each method a previousFilter so I could just invoke 
previousFilter.filterWrite. Is this possible? Should I work on it and 
send a patch or commit the change?

Thanks in advance.

German Borbolla Flores
Project Lead
Insys
Mexico, DF Mexico

Re: Question regarding filters

Posted by peter royal <pr...@apache.org>.
On Jun 20, 2007, at 9:50 AM, Germán Borbolla Flores wrote:
> Thanks for the quick response
>
> As far as I understand in messageReceived nextFilter points to the  
> filter "up" in the chain so if I set the following filter chain:
>
>        acceptorConfig.getFilterChain().addLast("cipher", new  
> CipherFilter());
>        acceptorConfig.getFilterChain().addLast("codec", new  
> InsysProtocolCodecFilter(new StringCodecFactory()));

filterWrite goes the other way in the chain, as its an "outbound"  
event :)

-pete



-- 
proyal@apache.org - http://fotap.org/~osi




Re: Question regarding filters

Posted by Germán Borbolla Flores <gb...@insys-corp.com.mx>.
peter royal wrote:
> On Jun 20, 2007, at 9:28 AM, Germán Borbolla Flores wrote:
>   
>> If there isn't any, I was thinking about changing IoFilter and add  
>> to each method a previousFilter so I could just invoke  
>> previousFilter.filterWrite. Is this possible? Should I work on it  
>> and send a patch or commit the change?
>>     
>
> I believe if you call NextFilter.filterWrite in your IoFilter, it  
> will do what you want.
>
> -pete
>
>   
Thanks for the quick response

As far as I understand in messageReceived nextFilter points to the 
filter "up" in the chain so if I set the following filter chain:

        acceptorConfig.getFilterChain().addLast("cipher", new 
CipherFilter());
        acceptorConfig.getFilterChain().addLast("codec", new 
InsysProtocolCodecFilter(new StringCodecFactory()));

while executing messageReceived of filter "cipher" nextFilter will point 
to "codec"?
will I still need to set the session attribute, so that filter ignores 
the request an just delegates the request to nextFilter?

Re: Question regarding filters

Posted by Germán Borbolla Flores <gb...@insys-corp.com.mx>.
After testing your recomendation everything worked, thanks a lot.

I will like to take the oportunity to thank everyone involved in the 
development of this excelent framework, congratulations for the excelent 
work.

peter royal wrote:
> On Jun 20, 2007, at 9:28 AM, Germán Borbolla Flores wrote:
>   
>> If there isn't any, I was thinking about changing IoFilter and add  
>> to each method a previousFilter so I could just invoke  
>> previousFilter.filterWrite. Is this possible? Should I work on it  
>> and send a patch or commit the change?
>>     
>
> I believe if you call NextFilter.filterWrite in your IoFilter, it  
> will do what you want.
>
> -pete
>
>   

Re: Question regarding filters

Posted by peter royal <pr...@apache.org>.
On Jun 20, 2007, at 9:28 AM, Germán Borbolla Flores wrote:
> If there isn't any, I was thinking about changing IoFilter and add  
> to each method a previousFilter so I could just invoke  
> previousFilter.filterWrite. Is this possible? Should I work on it  
> and send a patch or commit the change?

I believe if you call NextFilter.filterWrite in your IoFilter, it  
will do what you want.

-pete

-- 
proyal@apache.org - http://fotap.org/~osi