Search in sources :

Example 1 with JMSSecurityRuntimeException

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();
}
Also used : JMSSecurityRuntimeException(javax.jms.JMSSecurityRuntimeException) JMSSecurityException(javax.jms.JMSSecurityException) JMSException(javax.jms.JMSException) JMSRuntimeException(javax.jms.JMSRuntimeException)

Example 2 with JMSSecurityRuntimeException

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);
}
Also used : JMSSecurityRuntimeException(javax.jms.JMSSecurityRuntimeException) JMSSecurityException(javax.jms.JMSSecurityException) JMSException(javax.jms.JMSException) JMSRuntimeException(javax.jms.JMSRuntimeException)

Example 3 with JMSSecurityRuntimeException

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();
}
Also used : JMSSecurityRuntimeException(javax.jms.JMSSecurityRuntimeException) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) JMSContext(javax.jms.JMSContext) Test(org.junit.Test)

Aggregations

JMSSecurityRuntimeException (javax.jms.JMSSecurityRuntimeException)3 JMSException (javax.jms.JMSException)2 JMSRuntimeException (javax.jms.JMSRuntimeException)2 JMSSecurityException (javax.jms.JMSSecurityException)2 JMSContext (javax.jms.JMSContext)1 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)1 Test (org.junit.Test)1