I have some Java code that connects to a JMS broker and listens for
messages.
I'd like to implement the same code using Jython so I can extend it
without hacking the Java.
I'm having trouble with the authentication mechanism. When I run the
Java code it will honor the SASL_POLICY_NOPLAINTEXT=false option in the
jndi.properties file and allow me to authenticate with a plaintext password.
But when I run the same code in Jython it appears to ignore the option
and fails to authenticate with a plaintext password, complaining that it
has no implementation for PLAIN. It is reading the jndi.properties file
because that's where it picks up the provider URL.
The jndi.properties file specifies no security on the connection:
> java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
> jboss.naming.client.connect.timeout=10000
> java.naming.provider.url=remote://135.111.133.79:1099
> jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
> jboss.naming.client.remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
> jboss.naming.client.connect.options.org.xnio.Options.SSL_STARTTLS=false
The original Java code looks like this:
> Hashtable env = new Hashtable();
> env.put(Context.SECURITY_PRINCIPAL, user );
> env.put(Context.SECURITY_CREDENTIALS, password);
>
> jndiContext = new InitialContext(env);
>
> try
> {
>
> topicConnectionFactory = (TopicConnectionFactory)
> jndiContext.lookup(CONNECTION_FACTORY);
> }
and the same code in Python/Jython is:
> environment = java.util.Hashtable()
>
> environment['Context.SECURITY_PRINCIPAL'] = self.user
> environment['Context.SECURITY_CREDENTIALS'] = self.password
>
> self.jndiContext = InitialContext(environment)
> self.topicConnectionFactory = self.jndiContext.lookup(self.CONNECTION_FACTORY)
and the exception that fires on the lookup() call using Jython:
> (<type 'javax.naming.AuthenticationException'>, javax.naming.AuthenticationException: Failed to connect to any server. Servers tried: [remote://135.111.133.79:1099 (Authentication failed: all available authentication mechanisms failed:
> PLAIN: No implementation found)] [Root exception is javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed:
> PLAIN: No implementation found], <traceback object at 0x2>)
The same "library" JAR file is used for the Java and Jython invocations,
so I would expect them to work the same.
Any ideas would be greatly appreciated.
Thanks
Bob
|