Search in sources :

Example 96 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.

the class SimpleAnonymousPluginTest method initCombosForTestAnonymousSendFails.

/**
 * @see {@link CombinationTestSupport}
 */
public void initCombosForTestAnonymousSendFails() {
    addCombinationValues("userName", new Object[] { null });
    addCombinationValues("password", new Object[] { null });
    addCombinationValues("destination", new Object[] { new ActiveMQQueue("TEST"), new ActiveMQTopic("TEST"), new ActiveMQQueue("USERS.FOO"), new ActiveMQTopic("USERS.FOO") });
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue)

Example 97 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.

the class SimpleAuthenticationPluginTest method testSecurityContextClearedOnPurge.

public void testSecurityContextClearedOnPurge() throws Exception {
    connection.close();
    ActiveMQConnectionFactory tcpFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
    ActiveMQConnection conn = (ActiveMQConnection) tcpFactory.createConnection("user", "password");
    Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    conn.start();
    final int numDests = broker.getRegionBroker().getDestinations().length;
    for (int i = 0; i < 10; i++) {
        MessageProducer p = sess.createProducer(new ActiveMQQueue("USERS.PURGE." + i));
        p.close();
    }
    assertTrue("dests are purged", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisified() throws Exception {
            LOG.info("dests, orig: " + numDests + ", now: " + broker.getRegionBroker().getDestinations().length);
            return (numDests + 1) == broker.getRegionBroker().getDestinations().length;
        }
    }));
    // verify removed from connection security context
    TransportConnection brokerConnection = broker.getTransportConnectors().get(0).getConnections().get(0);
    TransportConnectionState transportConnectionState = brokerConnection.lookupConnectionState(conn.getConnectionInfo().getConnectionId());
    assertEquals("no destinations", 0, transportConnectionState.getContext().getSecurityContext().getAuthorizedWriteDests().size());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnection(org.apache.activemq.broker.TransportConnection) ActiveMQConnection(org.apache.activemq.ActiveMQConnection) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) TransportConnectionState(org.apache.activemq.broker.TransportConnectionState) MessageProducer(javax.jms.MessageProducer) Session(javax.jms.Session)

Example 98 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.

the class SimpleSecurityBrokerSystemTest method testPopulateJMSXUserID.

/**
 * @throws javax.jms.JMSException
 */
public void testPopulateJMSXUserID() throws Exception {
    destination = new ActiveMQQueue("TEST");
    Connection connection = factory.createConnection("system", "manager");
    connections.add(connection);
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    sendMessages(session, destination, 1);
    // make sure that the JMSXUserID is exposed over JMX
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    CompositeData[] browse = (CompositeData[]) mbs.invoke(new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=TEST"), "browse", null, null);
    assertEquals("system", browse[0].get("JMSXUserID"));
    // And also via JMS.
    MessageConsumer consumer = session.createConsumer(destination);
    Message m = consumer.receive(1000);
    assertTrue(m.propertyExists("JMSXUserID"));
    assertEquals("system", m.getStringProperty("JMSXUserID"));
}
Also used : MessageConsumer(javax.jms.MessageConsumer) Message(javax.jms.Message) CompositeData(javax.management.openmbean.CompositeData) Connection(javax.jms.Connection) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) Session(javax.jms.Session) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 99 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.

the class SimpleSecurityBrokerSystemTest method createAuthorizationMap.

public static AuthorizationMap createAuthorizationMap() {
    DestinationMap readAccess = new DefaultAuthorizationMap();
    readAccess.put(new ActiveMQQueue(">"), ADMINS);
    readAccess.put(new ActiveMQQueue("USERS.>"), USERS);
    readAccess.put(new ActiveMQQueue("GUEST.>"), GUESTS);
    readAccess.put(new ActiveMQTopic(">"), ADMINS);
    readAccess.put(new ActiveMQTopic("USERS.>"), USERS);
    readAccess.put(new ActiveMQTopic("GUEST.>"), GUESTS);
    DestinationMap writeAccess = new DefaultAuthorizationMap();
    writeAccess.put(new ActiveMQQueue(">"), ADMINS);
    writeAccess.put(new ActiveMQQueue("USERS.>"), USERS);
    writeAccess.put(new ActiveMQQueue("GUEST.>"), USERS);
    writeAccess.put(new ActiveMQQueue("GUEST.>"), GUESTS);
    writeAccess.put(new ActiveMQTopic(">"), ADMINS);
    writeAccess.put(new ActiveMQTopic("USERS.>"), USERS);
    writeAccess.put(new ActiveMQTopic("GUEST.>"), USERS);
    writeAccess.put(new ActiveMQTopic("GUEST.>"), GUESTS);
    readAccess.put(new ActiveMQTopic("ActiveMQ.Advisory.>"), WILDCARD);
    writeAccess.put(new ActiveMQTopic("ActiveMQ.Advisory.>"), WILDCARD);
    DestinationMap adminAccess = new DefaultAuthorizationMap();
    adminAccess.put(new ActiveMQTopic(">"), ADMINS);
    adminAccess.put(new ActiveMQTopic(">"), USERS);
    adminAccess.put(new ActiveMQTopic(">"), GUESTS);
    adminAccess.put(new ActiveMQQueue(">"), ADMINS);
    adminAccess.put(new ActiveMQQueue(">"), USERS);
    adminAccess.put(new ActiveMQQueue(">"), GUESTS);
    return new SimpleAuthorizationMap(writeAccess, readAccess, adminAccess);
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) DestinationMap(org.apache.activemq.filter.DestinationMap)

Example 100 with ActiveMQQueue

use of org.apache.activemq.command.ActiveMQQueue in project activemq-artemis by apache.

the class XBeanSecurityWithGuestTest method initCombosForTestUserSendGoodPassword.

/**
 * @see {@link CombinationTestSupport}
 */
public void initCombosForTestUserSendGoodPassword() {
    addCombinationValues("userName", new Object[] { "system" });
    addCombinationValues("password", new Object[] { "manager" });
    addCombinationValues("destination", new Object[] { new ActiveMQQueue("test"), new ActiveMQTopic("test") });
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue)

Aggregations

ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)239 Session (javax.jms.Session)81 MessageProducer (javax.jms.MessageProducer)78 MessageConsumer (javax.jms.MessageConsumer)76 TextMessage (javax.jms.TextMessage)73 Test (org.junit.Test)66 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)54 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)44 Message (javax.jms.Message)36 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)33 Connection (javax.jms.Connection)32 Destination (javax.jms.Destination)27 CountDownLatch (java.util.concurrent.CountDownLatch)20 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)18 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)18 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)18 SessionInfo (org.apache.activemq.command.SessionInfo)18 Message (org.apache.activemq.command.Message)17 BasicOpenWireTest (org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest)16 ProducerInfo (org.apache.activemq.command.ProducerInfo)16