You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by booya1227 <ha...@gmail.com> on 2015/06/15 21:54:13 UTC

How to pass data between methods in BrokerFilter?

I have developed a custom BrokerPlugin using BrokerFilter for Security
purposes. 
The plugin performs its own custom authentication in the addConnection()
method. 
During the authentication we return an authorization parameter(String) that
allows 
us to identify which topic(s) a client is allowed to subscribe. In the
addConsumer() 
method we determine whether or not a client is allowed to subscribe to a
topic 
based on our own search rules using the parameter from the the custom
authentication. 
Therefore, I need to be able to stash the authorization parameter from the
custom 
authentication in the addConnection() method so it will be there for
addConsumer() method. 
I had thought I could stash it in the ConnectionContext class, but
setUserName() method 
is protected (not public). I ended up using a HashMap that uses the
ConnectionId as the 
key and store the parameter in the map. Is there a better way to solve the
problem than
using a HashMap? And is there a way that I can use the ConnectionContext
class or any 
other Class?




--
View this message in context: http://activemq.2283324.n4.nabble.com/How-to-pass-data-between-methods-in-BrokerFilter-tp4697799.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: How to pass data between methods in BrokerFilter?

Posted by Christopher Shannon <ch...@gmail.com>.
Yes, a concurrent hash map would work well for this.  If you look at other
broker filter implementations such as the AdvisoryBroker, they all use maps
to share data between method calls.

Also take a look at http://activemq.apache.org/security.html and see if you
can use or extend one of the security plugins as that may make it easier to
handle your security requirements.

On Monday, June 15, 2015, booya1227 <ha...@gmail.com> wrote:

> I have developed a custom BrokerPlugin using BrokerFilter for Security
> purposes.
> The plugin performs its own custom authentication in the addConnection()
> method.
> During the authentication we return an authorization parameter(String) that
> allows
> us to identify which topic(s) a client is allowed to subscribe. In the
> addConsumer()
> method we determine whether or not a client is allowed to subscribe to a
> topic
> based on our own search rules using the parameter from the the custom
> authentication.
> Therefore, I need to be able to stash the authorization parameter from the
> custom
> authentication in the addConnection() method so it will be there for
> addConsumer() method.
> I had thought I could stash it in the ConnectionContext class, but
> setUserName() method
> is protected (not public). I ended up using a HashMap that uses the
> ConnectionId as the
> key and store the parameter in the map. Is there a better way to solve the
> problem than
> using a HashMap? And is there a way that I can use the ConnectionContext
> class or any
> other Class?
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/How-to-pass-data-between-methods-in-BrokerFilter-tp4697799.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>