You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by TheKK <jk...@gmail.com> on 2007/04/19 17:58:56 UTC

Configure Simple Authentication Plugin in apache-activemq-4.1.1

Hi All,


I am basically trying to authenticate users while creating connection using
the Simple Authentication Plugin.

activemq.xml
===============
<plugins>
     <simpleAuthenticationPlugin userGroups="#groups" 
userPasswords="#users"/>
 </plugins>


  
    <!-- Added by KK for Authentication starts -->
    <bean id="users" class="java.util.HashMap">
      <map>
         <entry key="kk" value="abc123"/>
      </map>
    </bean>
    <bean id="groups" class="java.util.HashMap">
       <map>
         <entry key="kk" value="admin"/>
        </map>
  </bean>




Code Snippet
============

public class SimpleProducer {
    
    private static final org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory
            .getLog(SimpleProducer.class);

     public static void main(String[] args) {
        ConnectionFactory connectionFactory = null;
        Connection connection = null;
        Session session = null;
        Topic topic = null;
        MessageProducer producer = null;
        final int NUM_MSGS=20;
        
        
        final String url="tcp://localhost:61616";
            
      
		try {
			connectionFactory = new ActiveMQConnectionFactory(url);
			log.info("Got ConnectionFactory");
			
			connection = connectionFactory.createConnection("kk","abc");
			log.info("Got Connection");
			
			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
			log.info("Got Session");
			
			topic = session.createTopic("eMeterTopic");
			log.info("Got Destination");
			
			producer = session.createProducer(topic);
			log.info("Got Producer");
			producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
			
            TextMessage message = session.createTextMessage();
            
            for (int i = 0; i < NUM_MSGS; i++) {
                message.setText("This is message " + (i + 1));
                log.info("Sending message: " + message.getText());
                Thread.sleep(5000);
                producer.send(message);
            }
            
            producer.send(session.createMessage());
           
		} catch (Exception e1) {
				e1.printStackTrace();
				
		} finally {
            if (connection != null) {
                try {
                    connection.close();
                }
                catch (JMSException e) {
                }
            }
        }
    }
}



While running the SimpleProducer application,with wrong credentials it does
not throw any exception like user is invalid or user is not authtenticated. 


So,Please let me know the correct steps to configure Simple Authentication
Plugin in apache-activemq-4.1.1.

Thanks in advance,
KK
-- 
View this message in context: http://www.nabble.com/Configure-Simple-Authentication-Plugin-in-apache-activemq-4.1.1-tf3607805s2354.html#a10080142
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Configure Simple Authentication Plugin in apache-activemq-4.1.1

Posted by TheKK <jk...@gmail.com>.
Hi James,
I followed the steps mentioned in the below url and it works fine now.
https://bugzilla.spamassassin.org/activemq/browse/AMQ-982
https://bugzilla.spamassassin.org/activemq/browse/AMQ-982 

Thanks James.

Wbr,
KK


James.Strachan wrote:
> 
> BTW with the wrong credentials its the createConnection() which should
> fail
> 
> On 4/24/07, James Strachan  wrote:
>> Could you show us the complete activemq.xml and the activemq log
>> please? Are you running the broker using the activemq script?
>>
>> On 4/19/07, TheKK  wrote:
>> >
>> > Hi All,
>> >
>> >
>> > I am basically trying to authenticate users while creating connection
>> using
>> > the Simple Authentication Plugin.
>> >
>> > activemq.xml
>> > ===============
>> > 
>> >       > userPasswords="#users"/>
>> >  
>> >
>> >
>> >
>> >     
>> >     
>> >       
>> >          
>> >       
>> >     
>> >     
>> >        
>> >          
>> >         
>> >   
>> >
>> >
>> >
>> >
>> > Code Snippet
>> > ============
>> >
>> > public class SimpleProducer {
>> >
>> >     private static final org.apache.commons.logging.Log log =
>> > org.apache.commons.logging.LogFactory
>> >             .getLog(SimpleProducer.class);
>> >
>> >      public static void main(String[] args) {
>> >         ConnectionFactory connectionFactory = null;
>> >         Connection connection = null;
>> >         Session session = null;
>> >         Topic topic = null;
>> >         MessageProducer producer = null;
>> >         final int NUM_MSGS=20;
>> >
>> >
>> >         final String url="tcp://localhost:61616";
>> >
>> >
>> >                 try {
>> >                         connectionFactory = new
>> ActiveMQConnectionFactory(url);
>> >                         log.info("Got ConnectionFactory");
>> >
>> >                         connection =
>> connectionFactory.createConnection("kk","abc");
>> >                         log.info("Got Connection");
>> >
>> >                         session = connection.createSession(false,
>> Session.AUTO_ACKNOWLEDGE);
>> >                         log.info("Got Session");
>> >
>> >                         topic = session.createTopic("eMeterTopic");
>> >                         log.info("Got Destination");
>> >
>> >                         producer = session.createProducer(topic);
>> >                         log.info("Got Producer");
>> >                        
>> producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>> >
>> >             TextMessage message = session.createTextMessage();
>> >
>> >             for (int i = 0; i < NUM_MSGS; i++) {
>> >                 message.setText("This is message " + (i + 1));
>> >                 log.info("Sending message: " + message.getText());
>> >                 Thread.sleep(5000);
>> >                 producer.send(message);
>> >             }
>> >
>> >             producer.send(session.createMessage());
>> >
>> >                 } catch (Exception e1) {
>> >                                 e1.printStackTrace();
>> >
>> >                 } finally {
>> >             if (connection != null) {
>> >                 try {
>> >                     connection.close();
>> >                 }
>> >                 catch (JMSException e) {
>> >                 }
>> >             }
>> >         }
>> >     }
>> > }
>> >
>> >
>> >
>> > While running the SimpleProducer application,with wrong credentials it
>> does
>> > not throw any exception like user is invalid or user is not
>> authtenticated.
>> >
>> >
>> > So,Please let me know the correct steps to configure Simple
>> Authentication
>> > Plugin in apache-activemq-4.1.1.
>> >
>> > Thanks in advance,
>> > KK
>> > --
>> > View this message in context:
>> http://www.nabble.com/Configure-Simple-Authentication-Plugin-in-apache-activemq-4.1.1-tf3607805s2354.html#a10080142
>> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>> >
>> >
>>
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
> 
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Configure-Simple-Authentication-Plugin-in-apache-activemq-4.1.1-tf3607805s2354.html#a10156841
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Configure Simple Authentication Plugin in apache-activemq-4.1.1

Posted by James Strachan <ja...@gmail.com>.
BTW with the wrong credentials its the createConnection() which should fail

On 4/24/07, James Strachan <ja...@gmail.com> wrote:
> Could you show us the complete activemq.xml and the activemq log
> please? Are you running the broker using the activemq script?
>
> On 4/19/07, TheKK <jk...@gmail.com> wrote:
> >
> > Hi All,
> >
> >
> > I am basically trying to authenticate users while creating connection using
> > the Simple Authentication Plugin.
> >
> > activemq.xml
> > ===============
> > <plugins>
> >      <simpleAuthenticationPlugin userGroups="#groups"
> > userPasswords="#users"/>
> >  </plugins>
> >
> >
> >
> >     <!-- Added by KK for Authentication starts -->
> >     <bean id="users" class="java.util.HashMap">
> >       <map>
> >          <entry key="kk" value="abc123"/>
> >       </map>
> >     </bean>
> >     <bean id="groups" class="java.util.HashMap">
> >        <map>
> >          <entry key="kk" value="admin"/>
> >         </map>
> >   </bean>
> >
> >
> >
> >
> > Code Snippet
> > ============
> >
> > public class SimpleProducer {
> >
> >     private static final org.apache.commons.logging.Log log =
> > org.apache.commons.logging.LogFactory
> >             .getLog(SimpleProducer.class);
> >
> >      public static void main(String[] args) {
> >         ConnectionFactory connectionFactory = null;
> >         Connection connection = null;
> >         Session session = null;
> >         Topic topic = null;
> >         MessageProducer producer = null;
> >         final int NUM_MSGS=20;
> >
> >
> >         final String url="tcp://localhost:61616";
> >
> >
> >                 try {
> >                         connectionFactory = new ActiveMQConnectionFactory(url);
> >                         log.info("Got ConnectionFactory");
> >
> >                         connection = connectionFactory.createConnection("kk","abc");
> >                         log.info("Got Connection");
> >
> >                         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> >                         log.info("Got Session");
> >
> >                         topic = session.createTopic("eMeterTopic");
> >                         log.info("Got Destination");
> >
> >                         producer = session.createProducer(topic);
> >                         log.info("Got Producer");
> >                         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
> >
> >             TextMessage message = session.createTextMessage();
> >
> >             for (int i = 0; i < NUM_MSGS; i++) {
> >                 message.setText("This is message " + (i + 1));
> >                 log.info("Sending message: " + message.getText());
> >                 Thread.sleep(5000);
> >                 producer.send(message);
> >             }
> >
> >             producer.send(session.createMessage());
> >
> >                 } catch (Exception e1) {
> >                                 e1.printStackTrace();
> >
> >                 } finally {
> >             if (connection != null) {
> >                 try {
> >                     connection.close();
> >                 }
> >                 catch (JMSException e) {
> >                 }
> >             }
> >         }
> >     }
> > }
> >
> >
> >
> > While running the SimpleProducer application,with wrong credentials it does
> > not throw any exception like user is invalid or user is not authtenticated.
> >
> >
> > So,Please let me know the correct steps to configure Simple Authentication
> > Plugin in apache-activemq-4.1.1.
> >
> > Thanks in advance,
> > KK
> > --
> > View this message in context: http://www.nabble.com/Configure-Simple-Authentication-Plugin-in-apache-activemq-4.1.1-tf3607805s2354.html#a10080142
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
> >
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>


-- 
James
-------
http://macstrac.blogspot.com/

Re: Configure Simple Authentication Plugin in apache-activemq-4.1.1

Posted by James Strachan <ja...@gmail.com>.
Could you show us the complete activemq.xml and the activemq log
please? Are you running the broker using the activemq script?

On 4/19/07, TheKK <jk...@gmail.com> wrote:
>
> Hi All,
>
>
> I am basically trying to authenticate users while creating connection using
> the Simple Authentication Plugin.
>
> activemq.xml
> ===============
> <plugins>
>      <simpleAuthenticationPlugin userGroups="#groups"
> userPasswords="#users"/>
>  </plugins>
>
>
>
>     <!-- Added by KK for Authentication starts -->
>     <bean id="users" class="java.util.HashMap">
>       <map>
>          <entry key="kk" value="abc123"/>
>       </map>
>     </bean>
>     <bean id="groups" class="java.util.HashMap">
>        <map>
>          <entry key="kk" value="admin"/>
>         </map>
>   </bean>
>
>
>
>
> Code Snippet
> ============
>
> public class SimpleProducer {
>
>     private static final org.apache.commons.logging.Log log =
> org.apache.commons.logging.LogFactory
>             .getLog(SimpleProducer.class);
>
>      public static void main(String[] args) {
>         ConnectionFactory connectionFactory = null;
>         Connection connection = null;
>         Session session = null;
>         Topic topic = null;
>         MessageProducer producer = null;
>         final int NUM_MSGS=20;
>
>
>         final String url="tcp://localhost:61616";
>
>
>                 try {
>                         connectionFactory = new ActiveMQConnectionFactory(url);
>                         log.info("Got ConnectionFactory");
>
>                         connection = connectionFactory.createConnection("kk","abc");
>                         log.info("Got Connection");
>
>                         session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>                         log.info("Got Session");
>
>                         topic = session.createTopic("eMeterTopic");
>                         log.info("Got Destination");
>
>                         producer = session.createProducer(topic);
>                         log.info("Got Producer");
>                         producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
>             TextMessage message = session.createTextMessage();
>
>             for (int i = 0; i < NUM_MSGS; i++) {
>                 message.setText("This is message " + (i + 1));
>                 log.info("Sending message: " + message.getText());
>                 Thread.sleep(5000);
>                 producer.send(message);
>             }
>
>             producer.send(session.createMessage());
>
>                 } catch (Exception e1) {
>                                 e1.printStackTrace();
>
>                 } finally {
>             if (connection != null) {
>                 try {
>                     connection.close();
>                 }
>                 catch (JMSException e) {
>                 }
>             }
>         }
>     }
> }
>
>
>
> While running the SimpleProducer application,with wrong credentials it does
> not throw any exception like user is invalid or user is not authtenticated.
>
>
> So,Please let me know the correct steps to configure Simple Authentication
> Plugin in apache-activemq-4.1.1.
>
> Thanks in advance,
> KK
> --
> View this message in context: http://www.nabble.com/Configure-Simple-Authentication-Plugin-in-apache-activemq-4.1.1-tf3607805s2354.html#a10080142
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
James
-------
http://macstrac.blogspot.com/