How to pass data between methods in BrokerFilter?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to pass data between methods in BrokerFilter?

booya1227
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?
Reply | Threaded
Open this post in threaded view
|

Re: How to pass data between methods in BrokerFilter?

christopher.l.shannon
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 <[hidden email]> 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.
>