Search in sources :

Example 1 with LegacyLDAPSecuritySettingPlugin

use of org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin in project activemq-artemis by apache.

the class LegacyLDAPSecuritySettingPluginListenerTest method setUp.

@Before
public void setUp() throws Exception {
    locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getCanonicalName()));
    testDir = temporaryFolder.getRoot().getAbsolutePath();
    LegacyLDAPSecuritySettingPlugin legacyLDAPSecuritySettingPlugin = new LegacyLDAPSecuritySettingPlugin();
    Map<String, String> map = new HashMap<>();
    map.put(LegacyLDAPSecuritySettingPlugin.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    map.put(LegacyLDAPSecuritySettingPlugin.CONNECTION_URL, "ldap://localhost:1024");
    map.put(LegacyLDAPSecuritySettingPlugin.CONNECTION_USERNAME, "uid=admin,ou=system");
    map.put(LegacyLDAPSecuritySettingPlugin.CONNECTION_PASSWORD, "secret");
    map.put(LegacyLDAPSecuritySettingPlugin.CONNECTION_PROTOCOL, "s");
    map.put(LegacyLDAPSecuritySettingPlugin.AUTHENTICATION, "simple");
    map.put(LegacyLDAPSecuritySettingPlugin.ENABLE_LISTENER, "true");
    legacyLDAPSecuritySettingPlugin.init(map);
    ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("LDAPLogin");
    Configuration configuration = new ConfigurationImpl().setSecurityEnabled(true).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())).setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)).setPersistenceEnabled(false).addSecuritySettingPlugin(legacyLDAPSecuritySettingPlugin);
    server = ActiveMQServers.newActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, false);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) HashMap(java.util.HashMap) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) LegacyLDAPSecuritySettingPlugin(org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin) Before(org.junit.Before)

Example 2 with LegacyLDAPSecuritySettingPlugin

use of org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin in project activemq-artemis by apache.

the class LegacyLDAPSecuritySettingPluginTest method setUp.

@Before
public void setUp() throws Exception {
    locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getCanonicalName()));
    testDir = temporaryFolder.getRoot().getAbsolutePath();
    LegacyLDAPSecuritySettingPlugin legacyLDAPSecuritySettingPlugin = new LegacyLDAPSecuritySettingPlugin().setInitialContextFactory("com.sun.jndi.ldap.LdapCtxFactory").setConnectionURL("ldap://localhost:1024").setConnectionUsername("uid=admin,ou=system").setConnectionPassword("secret").setConnectionProtocol("s").setAuthentication("simple");
    ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("LDAPLogin");
    Configuration configuration = new ConfigurationImpl().setSecurityEnabled(true).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getCanonicalName())).setJournalDirectory(ActiveMQTestBase.getJournalDir(testDir, 0, false)).setBindingsDirectory(ActiveMQTestBase.getBindingsDir(testDir, 0, false)).setPagingDirectory(ActiveMQTestBase.getPageDir(testDir, 0, false)).setLargeMessagesDirectory(ActiveMQTestBase.getLargeMessagesDir(testDir, 0, false)).setPersistenceEnabled(false).addSecuritySettingPlugin(legacyLDAPSecuritySettingPlugin);
    server = ActiveMQServers.newActiveMQServer(configuration, ManagementFactory.getPlatformMBeanServer(), securityManager, false);
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) LegacyLDAPSecuritySettingPlugin(org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin) Before(org.junit.Before)

Example 3 with LegacyLDAPSecuritySettingPlugin

use of org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin in project activemq-artemis by apache.

the class FileConfigurationTest method testSecuritySettingPlugin.

@Test
public void testSecuritySettingPlugin() throws Exception {
    FileConfiguration fc = new FileConfiguration();
    FileDeploymentManager deploymentManager = new FileDeploymentManager("securitySettingPlugin.xml");
    deploymentManager.addDeployable(fc);
    deploymentManager.readConfiguration();
    List<SecuritySettingPlugin> securitySettingPlugins = fc.getSecuritySettingPlugins();
    SecuritySettingPlugin securitySettingPlugin = securitySettingPlugins.get(0);
    assertTrue(securitySettingPlugin instanceof LegacyLDAPSecuritySettingPlugin);
    LegacyLDAPSecuritySettingPlugin legacyLDAPSecuritySettingPlugin = (LegacyLDAPSecuritySettingPlugin) securitySettingPlugin;
    assertEquals(legacyLDAPSecuritySettingPlugin.getInitialContextFactory(), "testInitialContextFactory");
    assertEquals(legacyLDAPSecuritySettingPlugin.getConnectionURL(), "testConnectionURL");
    assertEquals(legacyLDAPSecuritySettingPlugin.getConnectionUsername(), "testConnectionUsername");
    assertEquals(legacyLDAPSecuritySettingPlugin.getConnectionPassword(), "testConnectionPassword");
    assertEquals(legacyLDAPSecuritySettingPlugin.getConnectionProtocol(), "testConnectionProtocol");
    assertEquals(legacyLDAPSecuritySettingPlugin.getAuthentication(), "testAuthentication");
    assertEquals(legacyLDAPSecuritySettingPlugin.getDestinationBase(), "testDestinationBase");
    assertEquals(legacyLDAPSecuritySettingPlugin.getFilter(), "testFilter");
    assertEquals(legacyLDAPSecuritySettingPlugin.getRoleAttribute(), "testRoleAttribute");
    assertEquals(legacyLDAPSecuritySettingPlugin.getAdminPermissionValue(), "testAdminPermissionValue");
    assertEquals(legacyLDAPSecuritySettingPlugin.getReadPermissionValue(), "testReadPermissionValue");
    assertEquals(legacyLDAPSecuritySettingPlugin.getWritePermissionValue(), "testWritePermissionValue");
    assertEquals(legacyLDAPSecuritySettingPlugin.isEnableListener(), false);
}
Also used : SecuritySettingPlugin(org.apache.activemq.artemis.core.server.SecuritySettingPlugin) LegacyLDAPSecuritySettingPlugin(org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) LegacyLDAPSecuritySettingPlugin(org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin) Test(org.junit.Test)

Aggregations

LegacyLDAPSecuritySettingPlugin (org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin)3 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)2 Configuration (org.apache.activemq.artemis.core.config.Configuration)2 ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)2 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)2 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)2 Before (org.junit.Before)2 HashMap (java.util.HashMap)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 FileDeploymentManager (org.apache.activemq.artemis.core.config.FileDeploymentManager)1 SecuritySettingPlugin (org.apache.activemq.artemis.core.server.SecuritySettingPlugin)1 Test (org.junit.Test)1