ARTEMIS-4587 Config security setting plugins by using broker properties
This commit is contained in:
parent
efe450298d
commit
6ebd390330
|
@ -25,6 +25,10 @@ import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||||
|
|
||||||
public interface SecuritySettingPlugin extends Serializable {
|
public interface SecuritySettingPlugin extends Serializable {
|
||||||
|
|
||||||
|
default void setInit(Map<String, String> props) {
|
||||||
|
init(props);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the plugin with the given configuration options. This method is called by the broker when the file-based
|
* Initialize the plugin with the given configuration options. This method is called by the broker when the file-based
|
||||||
* configuration is read (see {@code org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser#parseSecurity(org.w3c.dom.Element, org.apache.activemq.artemis.core.config.Configuration)}.
|
* configuration is read (see {@code org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser#parseSecurity(org.w3c.dom.Element, org.apache.activemq.artemis.core.config.Configuration)}.
|
||||||
|
|
|
@ -66,6 +66,7 @@ import org.apache.activemq.artemis.core.security.Role;
|
||||||
import org.apache.activemq.artemis.core.server.ComponentConfigurationRoutingType;
|
import org.apache.activemq.artemis.core.server.ComponentConfigurationRoutingType;
|
||||||
import org.apache.activemq.artemis.core.server.JournalType;
|
import org.apache.activemq.artemis.core.server.JournalType;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
||||||
|
import org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin;
|
||||||
import org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin;
|
import org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin;
|
||||||
import org.apache.activemq.artemis.core.server.routing.KeyType;
|
import org.apache.activemq.artemis.core.server.routing.KeyType;
|
||||||
import org.apache.activemq.artemis.core.server.routing.policies.ConsistentHashModuloPolicy;
|
import org.apache.activemq.artemis.core.server.routing.policies.ConsistentHashModuloPolicy;
|
||||||
|
@ -2184,6 +2185,34 @@ public class ConfigurationImplTest extends ServerTestBase {
|
||||||
Assert.assertTrue(configuration.getStatus().contains("LOG_ALL_EVENTS"));
|
Assert.assertTrue(configuration.getStatus().contains("LOG_ALL_EVENTS"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSecuritySettingPluginFromBrokerProperties() throws Exception {
|
||||||
|
|
||||||
|
final ConfigurationImpl configuration = new ConfigurationImpl();
|
||||||
|
|
||||||
|
Properties insertionOrderedProperties = new ConfigurationImpl.InsertionOrderedProperties();
|
||||||
|
insertionOrderedProperties.put("securitySettingPlugins.\"org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin.class\".init", "initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory,connectionURL=ldap://localhost:1024");
|
||||||
|
|
||||||
|
configuration.parsePrefixedProperties(insertionOrderedProperties, null);
|
||||||
|
|
||||||
|
Assert.assertEquals(1, configuration.getSecuritySettingPlugins().size());
|
||||||
|
Assert.assertEquals("com.sun.jndi.ldap.LdapCtxFactory", ((LegacyLDAPSecuritySettingPlugin)(configuration.getSecuritySettingPlugins().get(0))).getInitialContextFactory());
|
||||||
|
Assert.assertEquals("ldap://localhost:1024", ((LegacyLDAPSecuritySettingPlugin)(configuration.getSecuritySettingPlugins().get(0))).getConnectionURL());
|
||||||
|
|
||||||
|
Assert.assertTrue(configuration.getStatus().contains("\"errors\":[]"));
|
||||||
|
|
||||||
|
// verify invalid map errors out
|
||||||
|
insertionOrderedProperties = new ConfigurationImpl.InsertionOrderedProperties();
|
||||||
|
|
||||||
|
// possible to change any attribute, but plugins only registered on start
|
||||||
|
insertionOrderedProperties.put("securitySettingPlugins.\"org.apache.activemq.artemis.core.server.impl.LegacyLDAPSecuritySettingPlugin.class\".init", "initialContextFactory");
|
||||||
|
|
||||||
|
configuration.parsePrefixedProperties(insertionOrderedProperties, null);
|
||||||
|
|
||||||
|
Assert.assertFalse(configuration.getStatus().contains("\"errors\":[]"));
|
||||||
|
Assert.assertTrue(configuration.getStatus().contains("initialContextFactory"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To test ARTEMIS-926
|
* To test ARTEMIS-926
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
|
|
Loading…
Reference in New Issue