Hello,

I have got the authentication working with IBM MQSeries using the JMS 
Point to Point sampler. 

I modified the code as follows:

In the class org.apache.jmeter.protocol.jms.sampler.JMSSampler I have 
added 2 methods:

        /**
         * RKU: get us the user 
         * 
         * @param context
         * @return
         * @throws NamingException
         */
        private String getUser(Context context) throws NamingException{
                Hashtable env = context.getEnvironment();
                return (String) env.get("java.naming.security.principal");
        }
 
        /**
         * RKU: get us the password 
         * 
         * @param context
         * @return
         * @throws NamingException
         */
        private String getPassword(Context context) throws 
NamingException{
                Hashtable env = context.getEnvironment();
                return (String) env.get("java.naming.security.credentials"
);
        } 

In the same class I have replaced the line that creates the queue 
connection in the method threadStarted() of the same class:

                        if (null != getUser(context) && null != 
getPassword(context)){
                                System.out.println("calling 
createQueueConnection with explicit user and password");
                                connection = 
factory.createQueueConnection(getUser(context), getPassword(context));
                        }else{
                                System.out.println("calling 
createQueueConnection without explicit authentication");
                                connection = 
factory.createQueueConnection();
                        }

The properties java.naming.security.principal and 
java.naming.security.credentials can be set from the sampler panel indeed.

Getting the JMeter source compiled with the ant build script works like a 
charm.

I have tested setting these properties with the original jmeter build and 
the same JMeter testplan and JNDI repository but then the message is not 
delivered.

I have searched for the string Context.SECURITY_PRINCIPAL in the JMeter 
source and there is one such word in the JMS package. This code appears to 
be there for publish subscribe. We are however using the Point 2 Point 
sampler.

The code below is for a standalone JMS client and I could not find the 
equivalent code in the JMSSampler.

Perhaps IBM MQSeries uses different properties for the user and the 
password but I am not very knowledgeable in this area.

I am confused about what to do next. 


Met Vriendelijke Groet,
Ronald van de Kuil

Stuck in the past somewhere in the future? NO WAY!!!



"Fitzpatrick, Adrian" <[EMAIL PROTECTED]> 
17-07-2008 19:22
Please respond to
"JMeter Users List" <jmeter-user@jakarta.apache.org>


To
"JMeter Users List" <jmeter-user@jakarta.apache.org>
cc
Dick Sol/Netherlands/[EMAIL PROTECTED]
Subject
RE: JMS in combination with authentication







Hi,

We have used the JMS sampler with authentication with WebLogic and it
(nearly) works - I think what we have done should be applicable for you as
well. The "nearly" is because we have had to open a support case with BEA 
on
an issue we are having with JMS authorisation (i.e. after authentication),
but I dont think this will affect you.

Anyway, what we needed to do to use authentication was to add the 
properties
for authentication to the JNDI properties section of the JMS sampler. 

The properties we added were "java.naming.security.principal" (username) 
and
"java.naming.security.credentials" (password). 

If you look at the JMeter code, you will see it adds all properties from 
this
section to the Initial context, so you shouldn't have to change the code 
at
all. 

Note - the two properties we are adding correspond to the values of the 
Java
static variables Context.SECURITY_PRINCIPAL and 
Context.SECURITY_CREDENTIALS.
If we were coding a standalone Java client to connect our JMS server, 
these
are the variables we would reference when supplying authentication 
details.
Eg. - 

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "http://127.0.0.1:7001";);
env.put(Context.SECURITY_PRINCIPAL, "weblogic"); 
env.put(Context.SECURITY_CREDENTIALS, "weblogic"); 
InitialContext ic = new InitialContext(env);
QueueConnectionFactory qconFactory = (QueueConnectionFactory)
ic.lookup("myConnFact");
QueueConnection qcon = qconFactory.createQueueConnection();
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueSession queue = (Queue) ic.lookup("myQueue");
QueueSender qsender = qsession.createSender(queue);

I'm not familar with MQSeries, but if that Java code would look different 
for
you JMS clients, then you'll need to adjust the way you use the JMS 
sampler
accordingly.

Hope this helps - let me know how you get on!

Regards,

Adrian


-----Original Message-----
From: Ronald Van de Kuil [mailto:[EMAIL PROTECTED]
Sent: 17 July 2008 15:24
To: JMeter Users List
Cc: Dick Sol
Subject: JMS in combination with authentication


Hello JMeter users,

I have figured out how to send JMS messages to IBM MQSeries. We can send 
messages to a queue manager which is not secured with a user and a 
password.

The trick is easy:
- use the com.sun.jndi.fscontext.RefFSContextFactory class as initial 
context factory with a url to the JNDI repository;
- use IBM JMSAdmin tool to create a JNDI mapping between your JMS world 
and the MQ world in your JNDI repository;

We are trying to take it a step further by sending a message to a 
queuemanager that has a user and a password set.

Unfortunatly we have been struggling with getting it to work for a two 
days now after having tried various approaches.

I can see in the source of jmeter that all calls to the queue connection 
factory are of the type:

public QueueConnection createQueueConnection() throws JMSException

Am I right that I will have to modify the code of jmeter to get it to 
supply the user and password. Like as in:

public QueueConnection createQueueConnection(String userName, String 
password) throws JMSException

Can anyone advise me on what to do next?


Thanx / Met Vriendelijke Groet,
Ronald van de Kuil

Stuck in the past somewhere in the future? NO WAY!!!

Tenzij hierboven anders aangegeven: / Unless stated otherwise above:
IBM Nederland B.V.
Gevestigd te Amsterdam
Inschrijving Handelsregister Amsterdam Nr. 33054214


************************

This message has been delivered to the Internet by the Revenue Internet 
e-mail service (OP)

*************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Tenzij hierboven anders aangegeven: / Unless stated otherwise above:
IBM Nederland B.V.
Gevestigd te Amsterdam
Inschrijving Handelsregister Amsterdam Nr. 33054214

Reply via email to