activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugene Prokopiev <prokop...@stc.donpac.ru>
Subject Re: Advanced authentication and authorization scenario
Date Wed, 12 Jul 2006 18:15:46 GMT
> You could reuse the AuthorizationPlugin/AuthorizationBroker and just
> implement your own AuthorizationMap 

Thanks, it's very interesting idea ...

> - or just write your own broker
> interceptor and override the methods that the AuthorizationBroker does
> to add security checks to the broker however you wish.
> 
>>  Can I
>> implement only one class for intercept sending and recieving events with
>> user/group info and raise authentication exception if needed?
>>  Need I use
>> something like BrokerFilter and override some methods from it? How can I
>> turn on my descendant of BrokerFilter for existing broker in this case?
>> Can anybody give me a simple example?
> 
> 
> Yes
> 
> BTW take a look at how the logging interceptor is written; combining
> the BrokerFilter and BrokerPlugin in a single class...
> 
> http://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/util/

> 
> 
> http://incubator.apache.org/activemq/logging-interceptor.html

I already created this class:

public class MyPlugin extends BrokerPluginSupport {

	public void send(ConnectionContext context, Message messageSend) throws
Exception {
		System.out.println("SendMessage");
		super.send(context, messageSend);
	}

}

and describe it here:

<beans>
	<bean id="broker" class="org.apache.activemq.broker.BrokerService"
init-method="start" destroy-method="stop">
		<property name="persistent" value="false"/>
		<property name="transportConnectorURIs">
			<list>
				<value>tcp://localhost:61234</value>
			</list>
		</property>
		<property name="plugins">
			<list>
				<bean class="MyPlugin"/>
			</list>
		</property>
	</bean>
</beans>

So, which MutableBrokerFilter methods need I reimplement to catch (and
raise exception if needed) this producer code if producer use wrong
destination:

ActiveMQConnection connection =
ActiveMQConnection.makeConnection("producer1", "pw1",
"tcp://localhost:61234");
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("monitoring.m1");
MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage("Test Message String");
producer.send(message);
session.close();
connection.close();

Which method need I to catch for rejecting recieving message from this code:

ActiveMQConnection connection =
ActiveMQConnection.makeConnection("consumer1", "pw1",
"tcp://localhost:61234");
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("monitoring.m1");
MessageConsumer consumer = session.createConsumer(destination);
while (true) {
	Message message = consumer.receive(Long.MAX_VALUE);
}

Is it possible to change message destination in my filter or make a copy
of message and send it to another destination? How can I do it?

--
Thanks,
Eugene Prokopiev



Mime
View raw message