Search in sources :

Example 1 with ActiveMQSecurityManager

use of org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager in project activemq-artemis by apache.

the class ActiveMQServers method newActiveMQServer.

public static ActiveMQServer newActiveMQServer(final Configuration config, final boolean enablePersistence) {
    ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager, enablePersistence);
    return server;
}
Also used : 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) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager)

Example 2 with ActiveMQSecurityManager

use of org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager in project activemq-artemis by apache.

the class StompProtocolManager method validateUser.

public boolean validateUser(String login, String passcode, RemotingConnection remotingConnection) {
    boolean validated = true;
    ActiveMQSecurityManager sm = server.getSecurityManager();
    if (sm != null && server.getConfiguration().isSecurityEnabled()) {
        if (sm instanceof ActiveMQSecurityManager3) {
            validated = ((ActiveMQSecurityManager3) sm).validateUser(login, passcode, remotingConnection) != null;
        } else if (sm instanceof ActiveMQSecurityManager2) {
            validated = ((ActiveMQSecurityManager2) sm).validateUser(login, passcode, CertificateUtil.getCertsFromConnection(remotingConnection));
        } else {
            validated = sm.validateUser(login, passcode);
        }
    }
    return validated;
}
Also used : ActiveMQSecurityManager2(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager2) ActiveMQSecurityManager3(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager3) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager)

Example 3 with ActiveMQSecurityManager

use of org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager in project activemq-artemis by apache.

the class Run method execute.

@Override
public Object execute(ActionContext context) throws Exception {
    super.execute(context);
    ManagementContextDTO managementDTO = getManagementDTO();
    managementContext = ManagementFactory.create(managementDTO);
    Artemis.printBanner();
    BrokerDTO broker = getBrokerDTO();
    addShutdownHook(broker.server.getConfigurationFile().getParentFile());
    ActiveMQSecurityManager security = SecurityManagerFactory.create(broker.security);
    server = BrokerFactory.createServer(broker.server, security);
    managementContext.start();
    server.start();
    if (broker.web != null) {
        broker.components.add(broker.web);
    }
    for (ComponentDTO componentDTO : broker.components) {
        Class clazz = this.getClass().getClassLoader().loadClass(componentDTO.componentClassName);
        ExternalComponent component = (ExternalComponent) clazz.newInstance();
        component.configure(componentDTO, getBrokerInstance(), getBrokerHome());
        component.start();
        server.getServer().addExternalComponent(component);
    }
    return null;
}
Also used : ManagementContextDTO(org.apache.activemq.artemis.dto.ManagementContextDTO) ComponentDTO(org.apache.activemq.artemis.dto.ComponentDTO) ExternalComponent(org.apache.activemq.artemis.components.ExternalComponent) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager) BrokerDTO(org.apache.activemq.artemis.dto.BrokerDTO)

Example 4 with ActiveMQSecurityManager

use of org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager in project activemq-artemis by apache.

the class HangConsumerTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createDefaultInVMConfig().setMessageExpiryScanPeriod(10);
    ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    server = addServer(new MyActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager));
    server.start();
    locator = createInVMNonHALocator();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) 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) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager) Before(org.junit.Before)

Example 5 with ActiveMQSecurityManager

use of org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager 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)

Aggregations

ActiveMQSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager)16 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)10 SecurityConfiguration (org.apache.activemq.artemis.core.config.impl.SecurityConfiguration)8 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)8 InVMLoginModule (org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule)8 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)7 Configuration (org.apache.activemq.artemis.core.config.Configuration)7 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)7 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 Map (java.util.Map)3 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)3 ActiveMQSecurityException (org.apache.activemq.artemis.api.core.ActiveMQSecurityException)3 Message (org.apache.activemq.artemis.api.core.Message)3 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)3 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)3 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)3 CheckType (org.apache.activemq.artemis.core.security.CheckType)3