Search in sources :

Example 6 with SecurityConfiguration

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

the class ShutdownOnCriticalIOErrorMoveNextTest method createServer.

ActiveMQServer createServer(String folder) throws Exception {
    final AtomicBoolean blocked = new AtomicBoolean(false);
    Configuration conf = createConfig(folder);
    ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    conf.setPersistenceEnabled(true);
    ActiveMQServer server = new ActiveMQServerImpl(conf, securityManager) {

        @Override
        protected StorageManager createStorageManager() {
            JournalStorageManager storageManager = new JournalStorageManager(conf, getCriticalAnalyzer(), executorFactory, scheduledPool, ioExecutorFactory, shutdownOnCriticalIO) {

                @Override
                protected Journal createMessageJournal(Configuration config, IOCriticalErrorListener criticalErrorListener, int fileSize) {
                    return new JournalImpl(ioExecutorFactory, fileSize, config.getJournalMinFiles(), config.getJournalPoolFiles(), config.getJournalCompactMinFiles(), config.getJournalCompactPercentage(), config.getJournalFileOpenTimeout(), journalFF, "activemq-data", "amq", journalFF.getMaxIO(), 0, criticalErrorListener) {

                        @Override
                        protected void moveNextFile(boolean scheduleReclaim) throws Exception {
                            super.moveNextFile(scheduleReclaim);
                            if (blocked.get()) {
                                throw new IllegalStateException("forcibly down");
                            }
                        }
                    };
                }

                @Override
                public void storeMessage(Message message) throws Exception {
                    super.storeMessage(message);
                    blocked.set(true);
                }
            };
            this.getCriticalAnalyzer().add(storageManager);
            return storageManager;
        }
    };
    return server;
}
Also used : IOCriticalErrorListener(org.apache.activemq.artemis.core.io.IOCriticalErrorListener) Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) Message(org.apache.activemq.artemis.api.core.Message) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl)

Example 7 with SecurityConfiguration

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

the class ActiveMQServerControlTest method setUp.

// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    connectorConfig = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
    conf = createDefaultNettyConfig().setJMXManagementEnabled(true).addConnectorConfiguration(connectorConfig.getName(), connectorConfig);
    conf.setSecurityEnabled(true);
    SecurityConfiguration securityConfiguration = new SecurityConfiguration();
    securityConfiguration.addUser("guest", "guest");
    securityConfiguration.addUser("myUser", "myPass");
    securityConfiguration.addRole("guest", "guest");
    securityConfiguration.addRole("myUser", "guest");
    securityConfiguration.setDefaultUser("guest");
    ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), securityConfiguration);
    server = addServer(ActiveMQServers.newActiveMQServer(conf, mbeanServer, securityManager, true));
    server.start();
    HashSet<Role> role = new HashSet<>();
    role.add(new Role("guest", true, true, true, true, true, true, true, true, true, true));
    server.getSecurityRepository().addMatch("#", role);
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 8 with SecurityConfiguration

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

the class JMSServerStartStopTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    FileConfiguration fc = new FileConfiguration();
    FileJMSConfiguration fileConfiguration = new FileJMSConfiguration();
    FileDeploymentManager deploymentManager = new FileDeploymentManager("server-start-stop-config1.xml");
    deploymentManager.addDeployable(fc);
    deploymentManager.addDeployable(fileConfiguration);
    deploymentManager.readConfiguration();
    ActiveMQJAASSecurityManager sm = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    ActiveMQServer server = addServer(new ActiveMQServerImpl(fc, sm));
    jmsServer = new JMSServerManagerImpl(server, fileConfiguration);
    jmsServer.setRegistry(null);
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) Before(org.junit.Before)

Example 9 with SecurityConfiguration

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

the class SendAckFailTest method startServer.

public ActiveMQServer startServer(boolean fail) {
    try {
        // ActiveMQServerImpl server = (ActiveMQServerImpl) createServer(true, true);
        AtomicInteger count = new AtomicInteger(0);
        ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
        Configuration configuration = createDefaultConfig(true);
        ActiveMQServer server = new ActiveMQServerImpl(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager) {

            @Override
            public StorageManager createStorageManager() {
                StorageManager original = super.createStorageManager();
                return new StorageManagerDelegate(original) {

                    @Override
                    public void storeMessage(Message message) throws Exception {
                        if (fail) {
                            if (count.incrementAndGet() == 110) {
                                System.out.println("Failing " + message);
                                System.out.flush();
                                Thread.sleep(100);
                                Runtime.getRuntime().halt(-1);
                            }
                        }
                        super.storeMessage(message);
                    }
                };
            }
        };
        System.out.println("Location::" + server.getConfiguration().getJournalLocation().getAbsolutePath());
        server.start();
        return server;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) PagedMessage(org.apache.activemq.artemis.core.paging.PagedMessage) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) Message(org.apache.activemq.artemis.api.core.Message) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) StorageManager(org.apache.activemq.artemis.core.persistence.StorageManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager)

Example 10 with SecurityConfiguration

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

the class ConfigurationTest method getActiveMQServer.

protected ActiveMQServer getActiveMQServer(String brokerConfig) throws Exception {
    FileConfiguration fc = new FileConfiguration();
    FileJMSConfiguration fileConfiguration = new FileJMSConfiguration();
    FileDeploymentManager deploymentManager = new FileDeploymentManager(brokerConfig);
    deploymentManager.addDeployable(fc);
    deploymentManager.addDeployable(fileConfiguration);
    deploymentManager.readConfiguration();
    ActiveMQJAASSecurityManager sm = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    return addServer(new ActiveMQServerImpl(fc, sm));
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)

Aggregations

SecurityConfiguration (org.apache.activemq.artemis.core.config.impl.SecurityConfiguration)22 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)21 InVMLoginModule (org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule)19 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)8 ActiveMQSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager)8 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)7 Configuration (org.apache.activemq.artemis.core.config.Configuration)6 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)4 Message (org.apache.activemq.artemis.api.core.Message)3 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)3 FileDeploymentManager (org.apache.activemq.artemis.core.config.FileDeploymentManager)3 FileConfiguration (org.apache.activemq.artemis.core.config.impl.FileConfiguration)3 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)3 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)3 Before (org.junit.Before)3 File (java.io.File)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2