Hi  evryone,
Pls show me how I can  create an embeded broker with authorization and
authentication?

** I have an activemq.xml like this : 

<beans xmlns="http://activemq.org/config/1.0";>
        <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
        <broker useJmx="true">  
                <memoryManager>  
                <usageManager id="memory-manager" limit="1048576"/>
        </memoryManager>        
        <plugins>
              <!--  use JAAS to authenticate using the login.config file on the
classpath to configure JAAS -->
              <jaasAuthenticationPlugin configuration="activemq-domain" />
              <!--  lets configure a destination based authorization mechanism
-->
              <authorizationPlugin>
                <map>
                  <authorizationMap>
                    <authorizationEntries>
                      <authorizationEntry queue=">" read="mygroup" 
write="mygroup"
admin="mygroup" />
                      <authorizationEntry queue="USERS.>" read="mygroup"
write="mygroup" admin="mygroup" />
                      <authorizationEntry queue="GUEST.>" read="mygroup"
write="mygroup" admin="mygroup" />
                    </authorizationEntries>
                  </authorizationMap>
                </map>
              </authorizationPlugin>
            </plugins>

            <transportConnectors>
               <transportConnector name="default" uri="tcp://localhost:61616"
discoveryUri="multicast://default"/>
               <transportConnector name="stomp"   
uri="stomp://localhost:62626"/>
            </transportConnectors>
            
            <networkConnectors>
              <!-- by default just auto discover the other brokers -->
              <networkConnector name="default" uri="multicast://default"/>
              <!--
              <networkConnector name="host1 and host2"
uri="static://(tcp://host1:61616,tcp://host2:61616)" failover="true"/>
              -->
            </networkConnectors>    
  </broker>  
</beans>

** I have login.config file like this:

activemq-domain {
org.apache.activemq.jaas.PropertiesLoginModule required 
debug=true  
org.apache.activemq.jaas.properties.group="groups.properties"
org.apache.activemq.jaas.properties.user="users.properties";
};

** the content groups.properties and users.properties file like this:

myuser=mygroup

myuser=handsomeboy

** All these file are locate in the package "bin/mybroker".
In my class, i have wrote :
    System.setProperty("java.security.auth.login.config",
ClassLoader.getSystemResource ("mybroker/login.config").toString());
                        
                        Resource resc = new UrlResource( 
ClassLoader.getSystemResource(
"mybroker/activemq.xml"));
                        ResourceXmlApplicationContext context = new
ResourceXmlApplicationContext(resc);
                        XBeanBrokerService service = (XBeanBrokerService)
context.getBean(context.getBeanNamesForType(BrokerService.class)[0]);
                        service.start();
                        service.afterPropertiesSet();

** when the broker start, it seem to be ok, there's no error.but when i
wrote a Jms client to connection to the destination like this code:

ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("mygroup", "handsomeboy","tcp://localhost:61616");
                        Connection connection = 
connectionFactory.createConnection();
                        connection.setClientID("HomeServer");
                        connection.start();

=> error has occured : Invalid username and password.

How can i fix this error?

I use activemq-core 4.1 SNAPSHOT.jar +
activeio-core.3.o.SNAPSHOT.jar+activemq-jaas .4.1.SNAPSHOT.jar,
spring.jar(ver1.2.8)+ xbean-spring-2.2.jar

Thank you.. 
-- 
View this message in context: 
http://www.nabble.com/Embedded-Broker-and-Jaas-tf2316610.html#a6443287
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to