Search in sources :

Example 61 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class SecurityNotificationTest method setUp.

// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setSecurityEnabled(true);
    server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    notifQueue = RandomUtil.randomSimpleString();
    ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
    securityManager.getConfiguration().addUser("admin", "admin");
    securityManager.getConfiguration().addUser("guest", "guest");
    securityManager.getConfiguration().setDefaultUser("guest");
    Role role = new Role("notif", true, true, true, true, true, true, true, true, true, true);
    Set<Role> roles = new HashSet<>();
    roles.add(role);
    server.getSecurityRepository().addMatch(ActiveMQDefaultConfiguration.getDefaultManagementNotificationAddress().toString(), roles);
    securityManager.getConfiguration().addRole("admin", "notif");
    ServerLocator locator = createInVMNonHALocator();
    ClientSessionFactory sf = createSessionFactory(locator);
    adminSession = sf.createSession("admin", "admin", false, true, true, false, 1);
    adminSession.start();
    adminSession.createTemporaryQueue(ActiveMQDefaultConfiguration.getDefaultManagementNotificationAddress(), notifQueue);
    notifConsumer = adminSession.createConsumer(notifQueue);
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) Configuration(org.apache.activemq.artemis.core.config.Configuration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 62 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class OpenWireTestBase method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    server = this.createServer(realStore, true);
    Configuration serverConfig = server.getConfiguration();
    serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(false).setAutoCreateAddresses(false).setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ")).setAutoCreateAddresses(true));
    serverConfig.setSecurityEnabled(enableSecurity);
    extraServerConfig(serverConfig);
    if (enableSecurity) {
        ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
        securityManager.getConfiguration().addRole("openwireSender", "sender");
        securityManager.getConfiguration().addUser("openwireSender", "SeNdEr");
        // sender cannot receive
        Role senderRole = new Role("sender", true, false, false, false, true, true, false, false, true, true);
        securityManager.getConfiguration().addRole("openwireReceiver", "receiver");
        securityManager.getConfiguration().addUser("openwireReceiver", "ReCeIvEr");
        // receiver cannot send
        Role receiverRole = new Role("receiver", false, true, false, false, true, true, false, true, false, false);
        securityManager.getConfiguration().addRole("openwireGuest", "guest");
        securityManager.getConfiguration().addUser("openwireGuest", "GuEsT");
        // guest cannot do anything
        Role guestRole = new Role("guest", false, false, false, false, false, false, false, false, false, false);
        securityManager.getConfiguration().addRole("openwireDestinationManager", "manager");
        securityManager.getConfiguration().addUser("openwireDestinationManager", "DeStInAtIoN");
        Role destRole = new Role("manager", false, false, false, false, true, true, false, false, false, false);
        Set<Role> roles = new HashSet<>();
        roles.add(senderRole);
        roles.add(receiverRole);
        roles.add(guestRole);
        roles.add(destRole);
        server.getConfiguration().putSecurityRoles("#", roles);
    }
    mbeanServer = MBeanServerFactory.createMBeanServer();
    server.setMBeanServer(mbeanServer);
    addServer(server);
    jmsServer = new JMSServerManagerImpl(server);
    namingContext = new InVMNamingContext();
    jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
    jmsServer.start();
    registerConnectionFactory();
    System.out.println("debug: server started");
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) HashSet(java.util.HashSet) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Before(org.junit.Before)

Example 63 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class ManagementServiceImplTest method testHandleManagementMessageWithOperationWhichFails.

@Test
public void testHandleManagementMessageWithOperationWhichFails() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    // invoke attribute and operation on the server
    CoreMessage message = new CoreMessage(1, 100);
    ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "thereIsNoSuchOperation");
    ICoreMessage reply = server.getManagementService().handleMessage(message);
    Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
    Assert.assertNotNull(ManagementHelper.getResult(reply));
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) Configuration(org.apache.activemq.artemis.core.config.Configuration) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) Test(org.junit.Test)

Example 64 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class ManagementServiceImplTest method testHandleManagementMessageWithKnownAttribute.

@Test
public void testHandleManagementMessageWithKnownAttribute() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    // invoke attribute and operation on the server
    ICoreMessage message = new CoreMessage(1, 100);
    ManagementHelper.putAttribute(message, ResourceNames.BROKER, "attribute.Does.Not.Exist");
    ICoreMessage reply = server.getManagementService().handleMessage(message);
    Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
    Assert.assertNotNull(ManagementHelper.getResult(reply));
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) Configuration(org.apache.activemq.artemis.core.config.Configuration) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) Test(org.junit.Test)

Example 65 with Configuration

use of org.apache.activemq.artemis.core.config.Configuration in project activemq-artemis by apache.

the class ManagementServiceImplTest method testHandleManagementMessageWithUnknowResource.

@Test
public void testHandleManagementMessageWithUnknowResource() throws Exception {
    Configuration config = createBasicConfig().setJMXManagementEnabled(false);
    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
    server.start();
    // invoke attribute and operation on the server
    ICoreMessage message = new CoreMessage(1, 100);
    ManagementHelper.putOperationInvocation(message, "Resouce.Does.Not.Exist", "toString");
    ICoreMessage reply = server.getManagementService().handleMessage(message);
    Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
    Assert.assertNotNull(ManagementHelper.getResult(reply));
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) Configuration(org.apache.activemq.artemis.core.config.Configuration) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) Test(org.junit.Test)

Aggregations

Configuration (org.apache.activemq.artemis.core.config.Configuration)331 Test (org.junit.Test)143 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)120 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)109 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)108 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)101 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)93 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)90 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)81 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)78 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)78 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)72 Before (org.junit.Before)59 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)58 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)57 HashMap (java.util.HashMap)56 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)52 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)35 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)35 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)34