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);
}
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");
}
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));
}
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));
}
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));
}
Aggregations