Broker 10.5 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | webMethods Messaging Administration | Configuring Messaging Clients for Basic Authentication | Enabling Basic Authentication Clients Using the webMethods APIs for JMS
 
Enabling Basic Authentication Clients Using the webMethods APIs for JMS
You use the following webMethods API for JMS to pass the basic authentication credentials to Broker Server. This API allows JMS clients to create a connection with Broker by using the user identity you specify. The API throws JMSSecurityException if client authentication fails due to an invalid user name or password.
createConnection(String userName, String password)
When you pass only a username and password combination, the webMethods API for JMS creates a basic authentication connection.
If you have already specified the keystore through the property file, or through the WmJMSConfig.setSSLKeystore() API, then the value of username corresponds to SSL DN and the value of password corresponds to the SSL keystore password. However, if keystore is not already specified, then the value of username corresponds to the basic authentication user name and the value for password corresponds to the password that the basic authentication user will use.
WmConnectionFactoryfactory = new WmConnectionFactoryfactory();
factory.setClientGroup(CLIENT_GROUP);
factory.setClientID("testClient");
factory.setBrokerName("Broker #1");
factory.setBrokerHost("localhost");
 
String username="sag";
String password="SoftwareAG123";
 
connection = factory.createConnection(username, password);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// continue with publish or subscribe