use of org.apache.activemq.artemis.core.config.impl.SecurityConfiguration in project activemq-artemis by apache.
the class StompWithClientIdValidationTest method createServer.
@Override
protected JMSServerManager createServer() throws Exception {
Configuration config = createBasicConfig().setSecurityEnabled(isSecurityEnabled()).setPersistenceEnabled(isPersistenceEnabled()).addAcceptorConfiguration("stomp", "tcp://localhost:61613?enabledProtocols=STOMP").addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration()) {
@Override
public String validateUser(String user, String password, RemotingConnection remotingConnection) {
String validatedUser = super.validateUser(user, password, remotingConnection);
if (validatedUser == null) {
return null;
}
if ("STOMP".equals(remotingConnection.getProtocolName())) {
final String clientId = remotingConnection.getClientID();
/*
* perform some kind of clientId validation, e.g. check presence or format
*/
if (clientId == null || clientId.length() == 0) {
System.err.println("ClientID not set!");
return null;
}
}
return validatedUser;
}
};
securityManager.getConfiguration().addUser(defUser, defPass);
ActiveMQServer activeMqServer = addServer(ActiveMQServers.newActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager));
JMSConfiguration jmsConfig = new JMSConfigurationImpl();
server = new JMSServerManagerImpl(activeMqServer, jmsConfig);
server.setRegistry(new JndiBindingRegistry(new InVMNamingContext()));
return server;
}
use of org.apache.activemq.artemis.core.config.impl.SecurityConfiguration in project activemq-artemis by apache.
the class ActiveMQTestBase method createColocatedInVMFailoverServer.
protected ActiveMQServer createColocatedInVMFailoverServer(final boolean realFiles, final Configuration configuration, final int pageSize, final int maxAddressSize, final Map<String, AddressSettings> settings, NodeManager liveNodeManager, NodeManager backupNodeManager, final int id) {
ActiveMQServer server;
ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
configuration.setPersistenceEnabled(realFiles);
server = new ColocatedActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, liveNodeManager, backupNodeManager);
try {
server.setIdentity("Server " + id);
for (Map.Entry<String, AddressSettings> setting : settings.entrySet()) {
server.getAddressSettingsRepository().addMatch(setting.getKey(), setting.getValue());
}
AddressSettings defaultSetting = new AddressSettings();
defaultSetting.setPageSizeBytes(pageSize);
defaultSetting.setMaxSizeBytes(maxAddressSize);
server.getAddressSettingsRepository().addMatch("#", defaultSetting);
return server;
} finally {
addServer(server);
}
}
use of org.apache.activemq.artemis.core.config.impl.SecurityConfiguration in project activemq-artemis by apache.
the class ActiveMQMessageHandlerSecurityTest method testSimpleMessageReceivedOnQueueWithSecurityFails.
@Test
public void testSimpleMessageReceivedOnQueueWithSecurityFails() throws Exception {
SecurityConfiguration emptyConfiguration = new SecurityConfiguration();
((ActiveMQJAASSecurityManager) server.getSecurityManager()).setConfiguration(emptyConfiguration);
ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
MyBootstrapContext ctx = new MyBootstrapContext();
qResourceAdapter.start(ctx);
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(qResourceAdapter);
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
spec.setUser("dodgyuser");
spec.setPassword("dodgypassword");
spec.setSetupAttempts(0);
qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
CountDownLatch latch = new CountDownLatch(1);
DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
qResourceAdapter.endpointActivation(endpointFactory, spec);
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(0, ((LocalQueueBinding) binding).getQueue().getConsumerCount());
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
qResourceAdapter.stop();
}
use of org.apache.activemq.artemis.core.config.impl.SecurityConfiguration in project activemq-artemis by apache.
the class ActiveMQServers method newActiveMQServer.
public static ActiveMQServer newActiveMQServer(final Configuration config, final MBeanServer mbeanServer, final boolean enablePersistence, String user, String password) {
SecurityConfiguration securityConfiguration = new SecurityConfiguration();
securityConfiguration.addUser(user, password);
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), securityConfiguration);
ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, mbeanServer, securityManager, enablePersistence);
return server;
}
use of org.apache.activemq.artemis.core.config.impl.SecurityConfiguration in project activemq-artemis by apache.
the class ActiveMQServers method newActiveMQServer.
public static ActiveMQServer newActiveMQServer(final Configuration config, final MBeanServer mbeanServer, final boolean enablePersistence) {
ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, mbeanServer, securityManager, enablePersistence);
return server;
}
Aggregations