use of javax.jms.JMSSecurityRuntimeException in project activemq-artemis by apache.
the class ActiveMQRAConnectionFactoryImpl method createXAContext.
@Override
public XAJMSContext createXAContext(String userName, String password) {
ActiveMQRASessionFactoryImpl conn = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_CONNECTION);
conn.setUserName(userName);
conn.setPassword(password);
try {
validateUser(conn);
} catch (JMSSecurityException e) {
JMSSecurityRuntimeException e2 = new JMSSecurityRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
} catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
}
return conn.createXAContext();
}
use of javax.jms.JMSSecurityRuntimeException in project activemq-artemis by apache.
the class ActiveMQRAConnectionFactoryImpl method createContext.
@Override
public JMSContext createContext(String userName, String password, int sessionMode) {
@SuppressWarnings("resource") ActiveMQRASessionFactoryImpl conn = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION);
conn.setUserName(userName);
conn.setPassword(password);
try {
validateUser(conn);
} catch (JMSSecurityException e) {
JMSSecurityRuntimeException e2 = new JMSSecurityRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
} catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
}
return conn.createContext(sessionMode);
}
use of javax.jms.JMSSecurityRuntimeException in project activemq-artemis by apache.
the class JMSSecurityTest method testSecurityOnJMSContext.
@Test
public void testSecurityOnJMSContext() throws Exception {
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("IDo", "Exist");
try {
JMSContext ctx = cf.createContext("Idont", "exist");
ctx.close();
} catch (JMSSecurityRuntimeException e) {
// expected
}
JMSContext ctx = cf.createContext("IDo", "Exist");
ctx.close();
}
Aggregations