You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2013/04/19 18:30:31 UTC
svn commit: r1469945 [1/2] - in /qpid/branches/0.22/qpid/java: ./
amqp-1-0-client-jms/ amqp-1-0-client/ amqp-1-0-common/
broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/
broker-plugins/access-control/src/test/...
Author: robbie
Date: Fri Apr 19 16:30:28 2013
New Revision: 1469945
URL: http://svn.apache.org/r1469945
Log:
QPID-4753: move ACL config from broker attribute to a top level entity
merged from trunk r1469937
Added:
qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/FileAccessControlProviderAttributeDescriptions.properties
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/FileAccessControlProviderAttributeDescriptions.properties
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/accesscontrolprovider/
- copied from r1469937, qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/accesscontrolprovider/
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/accesscontrolprovider/showAclFile.html
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/accesscontrolprovider/showAclFile.html
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/
- copied from r1469937, qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/AclFile.js
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/accesscontrolprovider/AclFile.js
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAccessControlProvider.js
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAccessControlProvider.js
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/showAccessControlProvider.html
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/resources/showAccessControlProvider.html
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AccessControlProviderRecoverer.java
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AccessControlProviderRecoverer.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AccessControlProvider.java
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AccessControlProvider.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderFactory.java
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderFactory.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/FileAccessControlProviderConstants.java
- copied unchanged from r1469937, qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/access/FileAccessControlProviderConstants.java
Modified:
qpid/branches/0.22/qpid/java/ (props changed)
qpid/branches/0.22/qpid/java/amqp-1-0-client/ (props changed)
qpid/branches/0.22/qpid/java/amqp-1-0-client-jms/ (props changed)
qpid/branches/0.22/qpid/java/amqp-1-0-common/ (props changed)
qpid/branches/0.22/qpid/java/broker/ (props changed)
qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java
qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactory.java
qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactoryTest.java
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html
qpid/branches/0.22/qpid/java/broker/bin/ (props changed)
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData_1_0.java (props changed)
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_1_0_0.java (props changed)
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_1_0_0_SASL.java (props changed)
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ (props changed)
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ (props changed)
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AccessControl.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/ (props changed)
qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java
qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostImplTest.java
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedConnection.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedExchange.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/UserManagement.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/annotations/MBeanAttribute.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/annotations/MBeanConstructor.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/annotations/MBeanDescription.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/annotations/MBeanOperation.java (props changed)
qpid/branches/0.22/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/annotations/MBeanOperationParameter.java (props changed)
qpid/branches/0.22/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java (props changed)
qpid/branches/0.22/qpid/java/systests/src/main/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
qpid/branches/0.22/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java
qpid/branches/0.22/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java
qpid/branches/0.22/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java (props changed)
qpid/branches/0.22/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java
qpid/branches/0.22/qpid/java/test-profiles/ (props changed)
qpid/branches/0.22/qpid/java/test-profiles/CPPExcludes (props changed)
qpid/branches/0.22/qpid/java/test-profiles/Excludes (props changed)
qpid/branches/0.22/qpid/java/test-profiles/JavaBDBExcludes (props changed)
qpid/branches/0.22/qpid/java/test-profiles/JavaExcludes (props changed)
qpid/branches/0.22/qpid/java/test-profiles/JavaPre010Excludes (props changed)
qpid/branches/0.22/qpid/java/test-profiles/JavaTransientExcludes (props changed)
qpid/branches/0.22/qpid/java/test-profiles/XAExcludes (props changed)
qpid/branches/0.22/qpid/java/test-profiles/cpp.async.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/cpp.cluster.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/cpp.noprefetch.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/cpp.ssl.excludes (props changed)
qpid/branches/0.22/qpid/java/test-profiles/cpp.ssl.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/cpp.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/java-bdb-spawn.0-9-1.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/java-bdb.0-9-1.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/java-dby-spawn.0-9-1.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/java-dby.0-9-1.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/java-mms-spawn.0-10.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/java-mms-spawn.0-9-1.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/java-mms.0-9-1.testprofile (props changed)
qpid/branches/0.22/qpid/java/test-profiles/log4j-test.xml (props changed)
qpid/branches/0.22/qpid/java/test-profiles/test-provider.properties (props changed)
qpid/branches/0.22/qpid/java/test-profiles/test_resources/ (props changed)
qpid/branches/0.22/qpid/java/test-profiles/testprofile.defaults (props changed)
Propchange: qpid/branches/0.22/qpid/java/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java:r1469937
Propchange: qpid/branches/0.22/qpid/java/amqp-1-0-client/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/amqp-1-0-client:r1469937
Propchange: qpid/branches/0.22/qpid/java/amqp-1-0-client-jms/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/amqp-1-0-client-jms:r1469937
Propchange: qpid/branches/0.22/qpid/java/amqp-1-0-common/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/amqp-1-0-common:r1469937
Propchange: qpid/branches/0.22/qpid/java/broker/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker:r1469937
Modified: qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java Fri Apr 19 16:30:28 2013
@@ -29,6 +29,7 @@ import javax.security.auth.Subject;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.lang.ObjectUtils;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.security.Result;
import org.apache.qpid.server.security.SecurityManager;
import org.apache.qpid.server.security.AccessControl;
@@ -44,6 +45,7 @@ public class DefaultAccessControl implem
private static final Logger _logger = Logger.getLogger(DefaultAccessControl.class);
private RuleSet _ruleSet;
+ private File _aclFile;
public DefaultAccessControl(String fileName)
{
@@ -51,10 +53,8 @@ public class DefaultAccessControl implem
{
_logger.debug("Creating AccessControl instance using file: " + fileName);
}
- File aclFile = new File(fileName);
- ConfigurationFile configFile = new PlainConfiguration(aclFile);
- _ruleSet = configFile.load();
+ _aclFile = new File(fileName);
}
DefaultAccessControl(RuleSet rs) throws ConfigurationException
@@ -62,6 +62,45 @@ public class DefaultAccessControl implem
_ruleSet = rs;
}
+ public void open()
+ {
+ if(_aclFile != null)
+ {
+ if (!_aclFile.exists())
+ {
+ throw new IllegalConfigurationException("ACL file '" + _aclFile + "' is not found");
+ }
+
+ ConfigurationFile configFile = new PlainConfiguration(_aclFile);
+ _ruleSet = configFile.load();
+ }
+ }
+
+ @Override
+ public void close()
+ {
+ //no-op
+ }
+
+ @Override
+ public void onDelete()
+ {
+ //no-op
+ }
+
+ @Override
+ public void onCreate()
+ {
+ //verify file exists
+ if(_aclFile != null)
+ {
+ if (!_aclFile.exists())
+ {
+ throw new IllegalConfigurationException("ACL file '" + _aclFile + "' is not found");
+ }
+ }
+ }
+
public Result getDefault()
{
return _ruleSet.getDefault();
@@ -119,4 +158,5 @@ public class DefaultAccessControl implem
return Result.DENIED;
}
}
+
}
Modified: qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactory.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactory.java (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactory.java Fri Apr 19 16:30:28 2013
@@ -20,40 +20,60 @@
*/
package org.apache.qpid.server.security.access.plugins;
-import java.io.File;
+import static org.apache.qpid.server.security.access.FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE;
+import static org.apache.qpid.server.security.access.FileAccessControlProviderConstants.PATH;
+import static org.apache.qpid.server.util.MapValueConverter.getStringAttribute;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.plugin.AccessControlFactory;
import org.apache.qpid.server.security.AccessControl;
+import org.apache.qpid.server.util.ResourceBundleLoader;
public class DefaultAccessControlFactory implements AccessControlFactory
{
- public static final String ATTRIBUTE_ACL_FILE = "aclFile";
+ public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.access.plugins.FileAccessControlProviderAttributeDescriptions";
+
+ public static final Collection<String> ATTRIBUTES = Collections.<String> unmodifiableList(Arrays.asList(
+ ATTRIBUTE_TYPE,
+ PATH
+ ));
- public AccessControl createInstance(Map<String, Object> aclConfiguration)
+ public AccessControl createInstance(Map<String, Object> attributes)
{
- if (aclConfiguration != null)
+ if(attributes == null || !ACL_FILE_PROVIDER_TYPE.equals(attributes.get(ATTRIBUTE_TYPE)))
+ {
+ return null;
+ }
+
+ String path = getStringAttribute(PATH, attributes, null);
+ if (path == null || "".equals(path.trim()))
{
- Object aclFile = aclConfiguration.get(ATTRIBUTE_ACL_FILE);
- if (aclFile != null)
- {
- if (aclFile instanceof String)
- {
- String aclPath = (String) aclFile;
- if (!new File(aclPath).exists())
- {
- throw new IllegalConfigurationException("ACL file '" + aclPath + "' is not found");
- }
- return new DefaultAccessControl(aclPath);
- }
- else
- {
- throw new IllegalConfigurationException("Expected '" + ATTRIBUTE_ACL_FILE + "' attribute value of type String but was " + aclFile.getClass()
- + ": " + aclFile);
- }
- }
+ throw new IllegalConfigurationException("Path to ACL was not specified!");
}
- return null;
+
+ return new DefaultAccessControl(path);
+ }
+
+ @Override
+ public String getType()
+ {
+ return ACL_FILE_PROVIDER_TYPE;
+ }
+
+ @Override
+ public Collection<String> getAttributeNames()
+ {
+ return ATTRIBUTES;
+ }
+
+ @Override
+ public Map<String, String> getAttributeDescriptions()
+ {
+ return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
}
}
Modified: qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactoryTest.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactoryTest.java (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactoryTest.java Fri Apr 19 16:30:28 2013
@@ -6,7 +6,9 @@ import java.util.Map;
import java.util.regex.Pattern;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.GroupProvider;
import org.apache.qpid.server.security.AccessControl;
+import org.apache.qpid.server.security.access.FileAccessControlProviderConstants;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
@@ -25,8 +27,10 @@ public class DefaultAccessControlFactory
File aclFile = TestFileUtils.createTempFile(this, ".acl", "ACL ALLOW all all");
DefaultAccessControlFactory factory = new DefaultAccessControlFactory();
Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(DefaultAccessControlFactory.ATTRIBUTE_ACL_FILE, aclFile.getAbsolutePath());
+ attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
+ attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath());
AccessControl acl = factory.createInstance(attributes);
+ acl.open();
assertNotNull("ACL was not created from acl file: " + aclFile.getAbsolutePath(), acl);
}
@@ -37,33 +41,17 @@ public class DefaultAccessControlFactory
assertFalse("ACL file " + aclFile.getAbsolutePath() + " actually exists but should not", aclFile.exists());
DefaultAccessControlFactory factory = new DefaultAccessControlFactory();
Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(DefaultAccessControlFactory.ATTRIBUTE_ACL_FILE, aclFile.getAbsolutePath());
+ attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
+ attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath());
try
{
- factory.createInstance(attributes);
- fail("It should not be possible to create ACL from non existing file");
+ AccessControl control = factory.createInstance(attributes);
+ control.open();
+ fail("It should not be possible to create and initialise ACL with non existing file");
}
catch (IllegalConfigurationException e)
{
- assertTrue("Unexpected exception message", Pattern.matches("ACL file '.*' is not found", e.getMessage()));
- }
- }
-
- public void testCreateInstanceWhenAclFileIsSpecifiedAsNonString()
- {
- DefaultAccessControlFactory factory = new DefaultAccessControlFactory();
- Map<String, Object> attributes = new HashMap<String, Object>();
- Integer aclFile = new Integer(0);
- attributes.put(DefaultAccessControlFactory.ATTRIBUTE_ACL_FILE, aclFile);
- try
- {
- factory.createInstance(attributes);
- fail("It should not be possible to create ACL from Integer");
- }
- catch (IllegalConfigurationException e)
- {
- assertEquals("Unexpected exception message", "Expected '" + DefaultAccessControlFactory.ATTRIBUTE_ACL_FILE
- + "' attribute value of type String but was " + Integer.class + ": " + aclFile, e.getMessage());
+ assertTrue("Unexpected exception message: " + e.getMessage(), Pattern.matches("ACL file '.*' is not found", e.getMessage()));
}
}
}
Modified: qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java Fri Apr 19 16:30:28 2013
@@ -47,6 +47,7 @@ import org.apache.qpid.server.management
import org.apache.qpid.server.management.plugin.servlet.rest.RestServlet;
import org.apache.qpid.server.management.plugin.servlet.rest.SaslServlet;
import org.apache.qpid.server.management.plugin.servlet.rest.StructureServlet;
+import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Binding;
import org.apache.qpid.server.model.Broker;
@@ -283,6 +284,7 @@ public class HttpManagement extends Abst
addRestServlet(root, "broker");
addRestServlet(root, "virtualhost", VirtualHost.class);
addRestServlet(root, "authenticationprovider", AuthenticationProvider.class);
+ addRestServlet(root, "accesscontrolprovider", AccessControlProvider.class);
addRestServlet(root, "user", AuthenticationProvider.class, User.class);
addRestServlet(root, "groupprovider", GroupProvider.class);
addRestServlet(root, "group", GroupProvider.class, Group.class);
Modified: qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java Fri Apr 19 16:30:28 2013
@@ -31,6 +31,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.qpid.server.management.plugin.servlet.rest.action.ListAccessControlProviderAttributes;
import org.apache.qpid.server.management.plugin.servlet.rest.action.ListAuthenticationProviderAttributes;
import org.apache.qpid.server.management.plugin.servlet.rest.action.ListGroupProviderAttributes;
import org.apache.qpid.server.management.plugin.servlet.rest.action.ListMessageStoreTypes;
@@ -55,6 +56,8 @@ public class HelperServlet extends Abstr
_actions.put(listMessageStoreTypes.getName(), listMessageStoreTypes);
Action groupProviderAttributes = new ListGroupProviderAttributes();
_actions.put(groupProviderAttributes.getName(), groupProviderAttributes);
+ Action aclProviderAttributes = new ListAccessControlProviderAttributes();
+ _actions.put(aclProviderAttributes.getName(), aclProviderAttributes);
}
@Override
Modified: qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js Fri Apr 19 16:30:28 2013
@@ -33,6 +33,7 @@ define(["dojo/_base/xhr",
"qpid/management/addPort",
"qpid/management/addKeystore",
"qpid/management/addGroupProvider",
+ "qpid/management/addAccessControlProvider",
"dojox/grid/enhanced/plugins/Pagination",
"dojox/grid/enhanced/plugins/IndirectSelection",
"dijit/layout/AccordionContainer",
@@ -43,7 +44,7 @@ define(["dojo/_base/xhr",
"dijit/form/CheckBox",
"dojo/store/Memory",
"dojo/domReady!"],
- function (xhr, parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid, registry, addAuthenticationProvider, addVirtualHost, addPort, addKeystore, addGroupProvider) {
+ function (xhr, parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid, registry, addAuthenticationProvider, addVirtualHost, addPort, addKeystore, addGroupProvider, addAccessControlProvider) {
function Broker(name, parent, controller) {
this.name = name;
@@ -80,15 +81,6 @@ define(["dojo/_base/xhr",
name: "defaultVirtualHost"})
}
}, {
- name: "aclFile",
- createWidget: function(brokerData) {
- return new dijit.form.ValidationTextBox({
- required: false,
- value: brokerData.aclFile,
- label: "ACL file location:",
- name: "aclFile"})
- }
- }, {
name: "statisticsReportingPeriod",
createWidget: function(brokerData) {
return new dijit.form.ValidationTextBox({
@@ -473,6 +465,21 @@ define(["dojo/_base/xhr",
warning + "Are you sure you want to delete group provider");
}
);
+
+ var addAccessControlButton = query(".addAccessControlProvider", contentPane.containerNode)[0];
+ connect.connect(registry.byNode(addAccessControlButton), "onClick",
+ function(evt){addAccessControlProvider.show();});
+
+ var deleteAccessControlProviderButton = query(".deleteAccessControlProvider", contentPane.containerNode)[0];
+ connect.connect(registry.byNode(deleteAccessControlProviderButton), "onClick",
+ function(evt){
+ util.deleteGridSelections(
+ that.brokerUpdater,
+ that.brokerUpdater.accessControlProvidersGrid.grid,
+ "rest/accesscontrolprovider",
+ "Are you sure you want to delete access control provider");
+ }
+ );
}});
};
@@ -626,7 +633,20 @@ define(["dojo/_base/xhr",
that.controller.show("groupprovider", name, brokerObj);
});
}, gridProperties, EnhancedGrid);
-
+ var aclData = that.brokerData.accesscontrolproviders ? that.brokerData.accesscontrolproviders :[];
+ that.accessControlProvidersGrid =
+ new UpdatableStore(aclData, query(".broker-access-control-providers")[0],
+ [ { name: "Name", field: "name", width: "60%"},
+ { name: "Type", field: "type", width: "40%"}
+ ], function(obj) {
+ connect.connect(obj.grid, "onRowDblClick", obj.grid,
+ function(evt){
+ var idx = evt.rowIndex,
+ theItem = this.getItem(idx);
+ var name = obj.dataStore.getValue(theItem,"name");
+ that.controller.show("accesscontrolprovider", name, brokerObj);
+ });
+ }, gridProperties, EnhancedGrid);
});
xhr.get({url: "rest/logrecords", sync: properties.useSyncGet, handleAs: "json"})
@@ -725,6 +745,11 @@ define(["dojo/_base/xhr",
{
that.groupProvidersGrid.update(that.brokerData.groupproviders);
}
+ if (that.accessControlProvidersGrid)
+ {
+ var data = that.brokerData.accesscontrolproviders ? that.brokerData.accesscontrolproviders :[];
+ that.accessControlProvidersGrid.update(data);
+ }
});
Modified: qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js Fri Apr 19 16:30:28 2013
@@ -31,15 +31,17 @@ define(["dojo/dom",
"qpid/management/group/Group",
"qpid/management/KeyStore",
"qpid/management/TrustStore",
+ "qpid/management/AccessControlProvider",
"dojo/ready",
"dojo/domReady!"],
- function (dom, registry, ContentPane, Broker, VirtualHost, Exchange, Queue, Connection, AuthProvider, GroupProvider, Group, KeyStore, TrustStore, ready) {
+ function (dom, registry, ContentPane, Broker, VirtualHost, Exchange, Queue, Connection, AuthProvider, GroupProvider, Group, KeyStore, TrustStore, AccessControlProvider, ready) {
var controller = {};
var constructors = { broker: Broker, virtualhost: VirtualHost, exchange: Exchange,
queue: Queue, connection: Connection,
authenticationprovider: AuthProvider, groupprovider: GroupProvider,
- group: Group, keystore: KeyStore, truststore: TrustStore };
+ group: Group, keystore: KeyStore, truststore: TrustStore,
+ accesscontrolprovider: AccessControlProvider};
var tabDiv = dom.byId("managedViews");
Modified: qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js Fri Apr 19 16:30:28 2013
@@ -281,6 +281,8 @@ define(["dojo/_base/xhr",
controller.show("keystore", details.keystore, {broker: {type:"broker", name:""}});
} else if (details.type == 'truststore') {
controller.show("truststore", details.truststore, {broker: {type:"broker", name:""}});
+ } else if (details.type == 'accesscontrolprovider') {
+ controller.show("accesscontrolprovider", details.accesscontrolprovider, {broker: {type:"broker", name:""}});
}
};
Modified: qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html (original)
+++ qpid/branches/0.22/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html Fri Apr 19 16:30:28 2013
@@ -53,18 +53,10 @@
<div class="formLabel-labelCell" style="float:left; width: 250px;">Broker store location:</div>
<div id="brokerAttribute.storePath" style="float:left;"></div>
</div>
- <div id="brokerAttribute.defaultAuthenticationProvider.container" style="display: none; clear:both">
- <div class="formLabel-labelCell" style="float:left; width: 250px;">Default authentication provider:</div>
- <div id="brokerAttribute.defaultAuthenticationProvider" style="float:left;"></div>
- </div>
<div id="brokerAttribute.defaultVirtualHost.container" style="display: none; clear:both; clear:both;">
<div class="formLabel-labelCell" style="float:left; width: 250px;">Default virtual host:</div>
<div id="brokerAttribute.defaultVirtualHost" style="float:left;"></div>
</div>
- <div id="brokerAttribute.aclFile.container" style="display: none; clear:both">
- <div class="formLabel-labelCell" style="float:left; width: 250px;">ACL file location:</div>
- <div id="brokerAttribute.aclFile" style="float:left;"></div>
- </div>
<div id="brokerAttribute.statisticsReportingPeriod.container" style="display: none; clear:both">
<div class="formLabel-labelCell" style="float:left; width: 250px;">Statistics reporting period:</div>
<div id="brokerAttribute.statisticsReportingPeriod" style="float:left;"></div>
@@ -191,6 +183,12 @@
<button data-dojo-type="dijit.form.Button" class="deleteGroupProvider">Delete Group Provider</button>
</div>
<br/>
+ <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Access Control Providers'">
+ <div class="broker-access-control-providers"></div>
+ <button data-dojo-type="dijit.form.Button" class="addAccessControlProvider">Add Access Control Provider</button>
+ <button data-dojo-type="dijit.form.Button" class="deleteAccessControlProvider">Delete Access Control Provider</button>
+ </div>
+ <br/>
<div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Log File', open: false">
<div class="broker-logfile"></div>
</div>
Propchange: qpid/branches/0.22/qpid/java/broker/bin/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/bin:r1469937
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java Fri Apr 19 16:30:28 2013
@@ -51,5 +51,4 @@ public class AuthenticationProviderRecov
return authenticationProvider;
}
-
}
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java Fri Apr 19 16:30:28 2013
@@ -40,6 +40,7 @@ import org.apache.qpid.server.model.Brok
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.KeyStore;
import org.apache.qpid.server.model.TrustStore;
+import org.apache.qpid.server.model.adapter.AccessControlProviderFactory;
import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
import org.apache.qpid.server.model.adapter.BrokerAdapter;
import org.apache.qpid.server.model.adapter.GroupProviderFactory;
@@ -54,18 +55,20 @@ public class BrokerRecoverer implements
private final LogRecorder _logRecorder;
private final RootMessageLogger _rootMessageLogger;
private final AuthenticationProviderFactory _authenticationProviderFactory;
+ private final AccessControlProviderFactory _accessControlProviderFactory;
private final PortFactory _portFactory;
private final TaskExecutor _taskExecutor;
private final BrokerOptions _brokerOptions;
private final GroupProviderFactory _groupProviderFactory;
public BrokerRecoverer(AuthenticationProviderFactory authenticationProviderFactory, GroupProviderFactory groupProviderFactory,
- PortFactory portFactory, StatisticsGatherer statisticsGatherer, VirtualHostRegistry virtualHostRegistry,
- LogRecorder logRecorder, RootMessageLogger rootMessageLogger, TaskExecutor taskExecutor, BrokerOptions brokerOptions)
+ AccessControlProviderFactory accessControlProviderFactory, PortFactory portFactory, StatisticsGatherer statisticsGatherer,
+ VirtualHostRegistry virtualHostRegistry, LogRecorder logRecorder, RootMessageLogger rootMessageLogger, TaskExecutor taskExecutor, BrokerOptions brokerOptions)
{
_groupProviderFactory = groupProviderFactory;
_portFactory = portFactory;
_authenticationProviderFactory = authenticationProviderFactory;
+ _accessControlProviderFactory = accessControlProviderFactory;
_statisticsGatherer = statisticsGatherer;
_virtualHostRegistry = virtualHostRegistry;
_logRecorder = logRecorder;
@@ -79,8 +82,8 @@ public class BrokerRecoverer implements
{
StoreConfigurationChangeListener storeChangeListener = new StoreConfigurationChangeListener(entry.getStore());
BrokerAdapter broker = new BrokerAdapter(entry.getId(), entry.getAttributes(), _statisticsGatherer, _virtualHostRegistry,
- _logRecorder, _rootMessageLogger, _authenticationProviderFactory, _groupProviderFactory, _portFactory,
- _taskExecutor, entry.getStore(), _brokerOptions);
+ _logRecorder, _rootMessageLogger, _authenticationProviderFactory, _groupProviderFactory, _accessControlProviderFactory,
+ _portFactory, _taskExecutor, entry.getStore(), _brokerOptions);
broker.addChangeListener(storeChangeListener);
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java Fri Apr 19 16:30:28 2013
@@ -25,6 +25,7 @@ import org.apache.qpid.server.configurat
import org.apache.qpid.server.configuration.RecovererProvider;
import org.apache.qpid.server.logging.LogRecorder;
import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.GroupProvider;
@@ -33,10 +34,12 @@ import org.apache.qpid.server.model.Plug
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.TrustStore;
import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.adapter.AccessControlProviderFactory;
import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
import org.apache.qpid.server.model.adapter.GroupProviderFactory;
import org.apache.qpid.server.model.adapter.PortFactory;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.plugin.AccessControlFactory;
import org.apache.qpid.server.plugin.AuthenticationManagerFactory;
import org.apache.qpid.server.plugin.GroupManagerFactory;
import org.apache.qpid.server.plugin.PluginFactory;
@@ -52,6 +55,7 @@ public class DefaultRecovererProvider im
private final LogRecorder _logRecorder;
private final RootMessageLogger _rootMessageLogger;
private final AuthenticationProviderFactory _authenticationProviderFactory;
+ private final AccessControlProviderFactory _accessControlProviderFactory;
private final PortFactory _portFactory;
private final GroupProviderFactory _groupProviderFactory;
private final QpidServiceLoader<PluginFactory> _pluginFactoryServiceLoader;
@@ -62,6 +66,7 @@ public class DefaultRecovererProvider im
LogRecorder logRecorder, RootMessageLogger rootMessageLogger, TaskExecutor taskExecutor, BrokerOptions brokerOptions)
{
_authenticationProviderFactory = new AuthenticationProviderFactory(new QpidServiceLoader<AuthenticationManagerFactory>());
+ _accessControlProviderFactory = new AccessControlProviderFactory(new QpidServiceLoader<AccessControlFactory>());
_groupProviderFactory = new GroupProviderFactory(new QpidServiceLoader<GroupManagerFactory>());
_portFactory = new PortFactory();
_brokerStatisticsGatherer = brokerStatisticsGatherer;
@@ -78,13 +83,17 @@ public class DefaultRecovererProvider im
{
if (Broker.class.getSimpleName().equals(type))
{
- return new BrokerRecoverer(_authenticationProviderFactory, _groupProviderFactory, _portFactory, _brokerStatisticsGatherer, _virtualHostRegistry,
- _logRecorder, _rootMessageLogger, _taskExecutor, _brokerOptions);
+ return new BrokerRecoverer(_authenticationProviderFactory, _groupProviderFactory, _accessControlProviderFactory, _portFactory, _brokerStatisticsGatherer,
+ _virtualHostRegistry, _logRecorder, _rootMessageLogger, _taskExecutor, _brokerOptions);
}
else if(VirtualHost.class.getSimpleName().equals(type))
{
return new VirtualHostRecoverer(_brokerStatisticsGatherer);
}
+ else if(AccessControlProvider.class.getSimpleName().equals(type))
+ {
+ return new AccessControlProviderRecoverer(_accessControlProviderFactory);
+ }
else if(AuthenticationProvider.class.getSimpleName().equals(type))
{
return new AuthenticationProviderRecoverer(_authenticationProviderFactory);
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java Fri Apr 19 16:30:28 2013
@@ -12,6 +12,7 @@ import org.apache.qpid.server.BrokerOpti
import org.apache.qpid.server.configuration.ConfigurationEntry;
import org.apache.qpid.server.configuration.ConfigurationEntryStore;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.Protocol;
import org.apache.qpid.server.model.State;
@@ -25,6 +26,7 @@ public class ManagementModeStoreHandler
private static final String MANAGEMENT_MODE_PORT_PREFIX = "MANAGEMENT-MODE-PORT-";
private static final String PORT_TYPE = Port.class.getSimpleName();
private static final String VIRTUAL_HOST_TYPE = VirtualHost.class.getSimpleName();
+ private static final String ACCESS_CONTROL_PROVIDER_TYPE = AccessControlProvider.class.getSimpleName();
private static final String ATTRIBUTE_STATE = VirtualHost.STATE;
private static final Object MANAGEMENT_MODE_AUTH_PROVIDER = "mm-auth";
@@ -253,6 +255,10 @@ public class ManagementModeStoreHandler
{
quiesce = true;
}
+ else if (ACCESS_CONTROL_PROVIDER_TYPE.equals(entryType))
+ {
+ quiesce = true;
+ }
else if (PORT_TYPE.equalsIgnoreCase(entryType))
{
if (attributes == null)
Propchange: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData_1_0.java
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/message/MessageMetaData_1_0.java:r1469937
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java Fri Apr 19 16:30:28 2013
@@ -21,11 +21,9 @@
package org.apache.qpid.server.model;
import java.net.SocketAddress;
-import java.security.AccessControlException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Map;
import org.apache.qpid.server.logging.LogRecorder;
import org.apache.qpid.server.logging.RootMessageLogger;
@@ -81,12 +79,6 @@ public interface Broker extends Configur
String VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE = "virtualhost.storeTransactionOpenTimeoutClose";
String VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_WARN = "virtualhost.storeTransactionOpenTimeoutWarn";
- /*
- * A temporary attribute to pass the path to ACL file.
- * TODO: It should be a part of AuthorizationProvider.
- */
- String ACL_FILE = "aclFile";
-
// Attributes
Collection<String> AVAILABLE_ATTRIBUTES =
Collections.unmodifiableList(
@@ -129,8 +121,7 @@ public interface Broker extends Configur
VIRTUALHOST_STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE,
VIRTUALHOST_STORE_TRANSACTION_IDLE_TIMEOUT_WARN,
VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE,
- VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_WARN,
- ACL_FILE
+ VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_WARN
));
//children
@@ -140,9 +131,7 @@ public interface Broker extends Configur
Collection<AuthenticationProvider> getAuthenticationProviders();
- VirtualHost createVirtualHost(String name, State initialState, boolean durable,
- LifetimePolicy lifetime, long ttl, Map<String, Object> attributes)
- throws AccessControlException, IllegalArgumentException;
+ Collection<AccessControlProvider> getAccessControlProviders();
Collection<GroupProvider> getGroupProviders();
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java Fri Apr 19 16:30:28 2013
@@ -52,6 +52,7 @@ public class Model
{
addRelationship(Broker.class, VirtualHost.class);
addRelationship(Broker.class, Port.class);
+ addRelationship(Broker.class, AccessControlProvider.class);
addRelationship(Broker.class, AuthenticationProvider.class);
addRelationship(Broker.class, GroupProvider.class);
addRelationship(Broker.class, TrustStore.class);
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Fri Apr 19 16:30:28 2013
@@ -43,6 +43,7 @@ import org.apache.qpid.server.logging.Ro
import org.apache.qpid.server.logging.actors.BrokerActor;
import org.apache.qpid.server.logging.actors.CurrentActor;
import org.apache.qpid.server.logging.messages.BrokerMessages;
+import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ConfigurationChangeListener;
@@ -92,7 +93,6 @@ public class BrokerAdapter extends Abstr
put(CONNECTION_HEART_BEAT_DELAY, Integer.class);
put(STATISTICS_REPORTING_PERIOD, Integer.class);
- put(ACL_FILE, String.class);
put(NAME, String.class);
put(DEFAULT_VIRTUAL_HOST, String.class);
@@ -166,9 +166,11 @@ public class BrokerAdapter extends Abstr
private final Map<UUID, ConfiguredObject> _plugins = new HashMap<UUID, ConfiguredObject>();
private final Map<String, KeyStore> _keyStores = new HashMap<String, KeyStore>();
private final Map<String, TrustStore> _trustStores = new HashMap<String, TrustStore>();
+ private final Map<UUID, AccessControlProvider> _accessControlProviders = new HashMap<UUID, AccessControlProvider>();
private final GroupProviderFactory _groupProviderFactory;
private final AuthenticationProviderFactory _authenticationProviderFactory;
+ private final AccessControlProviderFactory _accessControlProviderFactory;
private final PortFactory _portFactory;
private final SecurityManager _securityManager;
@@ -182,8 +184,8 @@ public class BrokerAdapter extends Abstr
public BrokerAdapter(UUID id, Map<String, Object> attributes, StatisticsGatherer statisticsGatherer, VirtualHostRegistry virtualHostRegistry,
LogRecorder logRecorder, RootMessageLogger rootMessageLogger, AuthenticationProviderFactory authenticationProviderFactory,
- GroupProviderFactory groupProviderFactory, PortFactory portFactory, TaskExecutor taskExecutor, ConfigurationEntryStore brokerStore,
- BrokerOptions brokerOptions)
+ GroupProviderFactory groupProviderFactory, AccessControlProviderFactory accessControlProviderFactory, PortFactory portFactory, TaskExecutor taskExecutor,
+ ConfigurationEntryStore brokerStore, BrokerOptions brokerOptions)
{
super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), taskExecutor);
_statisticsGatherer = statisticsGatherer;
@@ -193,13 +195,13 @@ public class BrokerAdapter extends Abstr
_statistics = new StatisticsAdapter(statisticsGatherer);
_authenticationProviderFactory = authenticationProviderFactory;
_groupProviderFactory = groupProviderFactory;
+ _accessControlProviderFactory = accessControlProviderFactory;
_portFactory = portFactory;
- _securityManager = new SecurityManager((String)getAttribute(ACL_FILE));
- addChangeListener(_securityManager);
+ _brokerOptions = brokerOptions;
+ _securityManager = new SecurityManager(this, _brokerOptions.isManagementMode());
_supportedVirtualHostStoreTypes = new MessageStoreCreator().getStoreTypes();
_supportedBrokerStoreTypes = new BrokerConfigurationStoreCreator().getStoreTypes();
_brokerStore = brokerStore;
- _brokerOptions = brokerOptions;
if (_brokerOptions.isManagementMode())
{
AuthenticationManager authManager = new SimpleAuthenticationManager(BrokerOptions.MANAGEMENT_MODE_USER_NAME, _brokerOptions.getManagementModePassword());
@@ -278,17 +280,6 @@ public class BrokerAdapter extends Abstr
}
}
- public VirtualHost createVirtualHost(final String name,
- final State initialState,
- final boolean durable,
- final LifetimePolicy lifetime,
- final long ttl,
- final Map<String, Object> attributes)
- throws AccessControlException, IllegalArgumentException
- {
- return null; //TODO
- }
-
private VirtualHost createVirtualHost(final Map<String, Object> attributes)
throws AccessControlException, IllegalArgumentException
{
@@ -388,6 +379,10 @@ public class BrokerAdapter extends Abstr
{
return (Collection<C>) getPorts();
}
+ else if(clazz == AccessControlProvider.class)
+ {
+ return (Collection<C>) getAccessControlProviders();
+ }
else if(clazz == AuthenticationProvider.class)
{
return (Collection<C>) getAuthenticationProviders();
@@ -424,6 +419,10 @@ public class BrokerAdapter extends Abstr
{
return (C) createPort(attributes);
}
+ else if(childClass == AccessControlProvider.class)
+ {
+ return (C) createAccessControlProvider(attributes);
+ }
else if(childClass == AuthenticationProvider.class)
{
return (C) createAuthenticationProvider(attributes);
@@ -477,6 +476,64 @@ public class BrokerAdapter extends Abstr
return port;
}
+ private AccessControlProvider createAccessControlProvider(Map<String, Object> attributes)
+ {
+ AccessControlProvider accessControlProvider = null;
+ synchronized (_accessControlProviders)
+ {
+ accessControlProvider = _accessControlProviderFactory.create(UUID.randomUUID(), this, attributes);
+ addAccessControlProvider(accessControlProvider);
+ }
+
+ boolean quiesce = isManagementMode() ;
+ accessControlProvider.setDesiredState(State.INITIALISING, quiesce ? State.QUIESCED : State.ACTIVE);
+
+ return accessControlProvider;
+ }
+
+ /**
+ * @throws IllegalConfigurationException if an AuthenticationProvider with the same name already exists
+ */
+ private void addAccessControlProvider(AccessControlProvider accessControlProvider)
+ {
+ String name = accessControlProvider.getName();
+ synchronized (_authenticationProviders)
+ {
+ if (_accessControlProviders.containsKey(accessControlProvider.getId()))
+ {
+ throw new IllegalConfigurationException("Can't add AccessControlProvider because one with id " + accessControlProvider.getId() + " already exists");
+ }
+ for (AccessControlProvider provider : _accessControlProviders.values())
+ {
+ if (provider.getName().equals(name))
+ {
+ throw new IllegalConfigurationException("Can't add AccessControlProvider because one with name " + name + " already exists");
+ }
+ }
+ _accessControlProviders.put(accessControlProvider.getId(), accessControlProvider);
+ }
+
+ accessControlProvider.addChangeListener(this);
+ accessControlProvider.addChangeListener(_securityManager);
+ }
+
+ private boolean deleteAccessControlProvider(AccessControlProvider accessControlProvider)
+ {
+ AccessControlProvider removedAccessControlProvider = null;
+ synchronized (_accessControlProviders)
+ {
+ removedAccessControlProvider = _accessControlProviders.remove(accessControlProvider.getId());
+ }
+
+ if(removedAccessControlProvider != null)
+ {
+ removedAccessControlProvider.removeChangeListener(this);
+ removedAccessControlProvider.removeChangeListener(_securityManager);
+ }
+
+ return removedAccessControlProvider != null;
+ }
+
private AuthenticationProvider createAuthenticationProvider(Map<String, Object> attributes)
{
AuthenticationProvider authenticationProvider = null;
@@ -771,6 +828,7 @@ public class BrokerAdapter extends Abstr
{
changeState(_groupProviders, currentState, State.ACTIVE, false);
changeState(_authenticationProviders, currentState, State.ACTIVE, false);
+ changeState(_accessControlProviders, currentState, State.ACTIVE, false);
CurrentActor.set(new BrokerActor(getRootMessageLogger()));
try
@@ -847,6 +905,10 @@ public class BrokerAdapter extends Abstr
{
childDeleted = deleteAuthenticationProvider((AuthenticationProvider)object);
}
+ else if(object instanceof AccessControlProvider)
+ {
+ childDeleted = deleteAccessControlProvider((AccessControlProvider)object);
+ }
else if(object instanceof Port)
{
childDeleted = deletePort((Port)object);
@@ -921,6 +983,10 @@ public class BrokerAdapter extends Abstr
{
addAuthenticationProvider((AuthenticationProvider)object);
}
+ else if(object instanceof AccessControlProvider)
+ {
+ addAccessControlProvider((AccessControlProvider)object);
+ }
else if(object instanceof Port)
{
addPort((Port)object);
@@ -1051,13 +1117,6 @@ public class BrokerAdapter extends Abstr
private void validateAttributes(Map<String, Object> convertedAttributes)
{
- String aclFile = (String) convertedAttributes.get(ACL_FILE);
- if (aclFile != null)
- {
- // create a security manager to validate the ACL specified in file
- new SecurityManager(aclFile);
- }
-
String defaultVirtualHost = (String) convertedAttributes.get(DEFAULT_VIRTUAL_HOST);
if (defaultVirtualHost != null)
{
@@ -1129,4 +1188,13 @@ public class BrokerAdapter extends Abstr
{
return _brokerOptions.isManagementMode();
}
+
+ @Override
+ public Collection<AccessControlProvider> getAccessControlProviders()
+ {
+ synchronized (_accessControlProviders)
+ {
+ return new ArrayList<AccessControlProvider>(_accessControlProviders.values());
+ }
+ }
}
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java Fri Apr 19 16:30:28 2013
@@ -18,11 +18,34 @@
*/
package org.apache.qpid.server.plugin;
+import java.util.Collection;
import java.util.Map;
+import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.security.AccessControl;
public interface AccessControlFactory
{
+ public static final String ATTRIBUTE_TYPE = AccessControlProvider.TYPE;
+
AccessControl createInstance(Map<String, Object> attributes);
+
+ /**
+ * Returns the access control provider type
+ * @return authentication provider type
+ */
+ String getType();
+
+ /**
+ * Get the names of attributes of the access control which can be passed into
+ * {@link #createInstance(Map)} to create the group manager
+ *
+ * @return the collection of attribute names
+ */
+ Collection<String> getAttributeNames();
+
+ /**
+ * @return returns human readable descriptions for the attributes
+ */
+ Map<String, String> getAttributeDescriptions();
}
Propchange: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_1_0_0.java
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_1_0_0.java:r1469937
Propchange: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_1_0_0_SASL.java
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_1_0_0_SASL.java:r1469937
Propchange: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0:r1469937
Propchange: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue:r1469937
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AccessControl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AccessControl.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AccessControl.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/AccessControl.java Fri Apr 19 16:30:28 2013
@@ -42,4 +42,25 @@ public interface AccessControl
* Authorise an operation on an object defined by a set of properties.
*/
Result authorise(Operation operation, ObjectType objectType, ObjectProperties properties);
+
+ /**
+ * Called to open any resources required by the implementation.
+ */
+ void open();
+
+ /**
+ * Called to close any resources required by the implementation.
+ */
+ void close();
+
+ /**
+ * Called when deleting to allow clearing any resources used by the implementation.
+ */
+ void onDelete();
+
+ /**
+ * Called when first creating (but not when recovering after startup) to allow
+ * creating any resources required by the implementation.
+ */
+ void onCreate();
}
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/security/SecurityManager.java Fri Apr 19 16:30:28 2013
@@ -23,6 +23,7 @@ import org.apache.log4j.Logger;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ConfigurationChangeListener;
import org.apache.qpid.server.model.ConfiguredObject;
@@ -30,6 +31,7 @@ import org.apache.qpid.server.model.Stat
import org.apache.qpid.server.plugin.AccessControlFactory;
import org.apache.qpid.server.plugin.QpidServiceLoader;
import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.security.access.FileAccessControlProviderConstants;
import org.apache.qpid.server.security.access.ObjectProperties;
import org.apache.qpid.server.security.access.ObjectType;
import org.apache.qpid.server.security.access.Operation;
@@ -53,22 +55,13 @@ import static org.apache.qpid.server.sec
import javax.security.auth.Subject;
import java.net.SocketAddress;
-import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * The security manager contains references to all loaded {@link AccessControl}s and delegates security decisions to them based
- * on virtual host name. The plugins can be external <em>OSGi</em> .jar files that export the required classes or just internal
- * objects for simpler plugins.
- *
- * @see AccessControl
- */
public class SecurityManager implements ConfigurationChangeListener
{
private static final Logger _logger = Logger.getLogger(SecurityManager.class);
@@ -78,9 +71,12 @@ public class SecurityManager implements
public static final ThreadLocal<Boolean> _accessChecksDisabled = new ClearingThreadLocal(false);
- private Map<String, AccessControl> _globalPlugins = new ConcurrentHashMap<String, AccessControl>();
- private Map<String, AccessControl> _hostPlugins = new ConcurrentHashMap<String, AccessControl>();
- private Map<String, List<String>> _aclConfigurationToPluginNamesMapping = new ConcurrentHashMap<String, List<String>>();
+ private ConcurrentHashMap<String, AccessControl> _globalPlugins = new ConcurrentHashMap<String, AccessControl>();
+ private ConcurrentHashMap<String, AccessControl> _hostPlugins = new ConcurrentHashMap<String, AccessControl>();
+
+ private boolean _managementMode;
+
+ private Broker _broker;
/**
* A special ThreadLocal, which calls remove() on itself whenever the value is
@@ -128,34 +124,53 @@ public class SecurityManager implements
}
/*
- * Used by the VirtualHost to allow deferring to the broker level security plugins if required.
+ * Used by the Broker.
*/
- public SecurityManager(SecurityManager parent, String aclFile)
+ public SecurityManager(Broker broker, boolean managementMode)
{
- this(aclFile);
-
- // our global plugins are the parent's host plugins
- _globalPlugins = parent._hostPlugins;
+ _managementMode = managementMode;
+ _broker = broker;
}
- public SecurityManager(String aclFile)
+ /*
+ * Used by the VirtualHost to allow deferring to the broker level security plugins if required.
+ */
+ public SecurityManager(SecurityManager parent, String aclFile, String vhostName)
{
- configureACLPlugin(aclFile);
+ if(!_managementMode)
+ {
+ configureVirtualHostAclPlugin(aclFile, vhostName);
+
+ // our global plugins are the parent's host plugins
+ _globalPlugins = parent._hostPlugins;
+ }
}
- private void configureACLPlugin(String aclFile)
+ private void configureVirtualHostAclPlugin(String aclFile, String vhostName)
{
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put("aclFile", aclFile);
-
- for (AccessControlFactory provider : (new QpidServiceLoader<AccessControlFactory>()).instancesOf(AccessControlFactory.class))
+ if(aclFile != null)
{
- AccessControl accessControl = provider.createInstance(attributes);
- if(accessControl != null)
- {
- addHostPlugin(accessControl);
+ Map<String, Object> attributes = new HashMap<String, Object>();
+
+ attributes.put(AccessControlProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
+ attributes.put(FileAccessControlProviderConstants.PATH, aclFile);
- mapAclConfigurationToPluginName(aclFile, accessControl.getClass().getName());
+ for (AccessControlFactory provider : (new QpidServiceLoader<AccessControlFactory>()).instancesOf(AccessControlFactory.class))
+ {
+ AccessControl accessControl = provider.createInstance(attributes);
+ accessControl.open();
+ if(accessControl != null)
+ {
+ String pluginTypeName = getPluginTypeName(accessControl);
+ _hostPlugins.put(pluginTypeName, accessControl);
+
+ if(_logger.isDebugEnabled())
+ {
+ _logger.debug("Added access control to host plugins with name: " + vhostName);
+ }
+
+ break;
+ }
}
}
@@ -165,15 +180,9 @@ public class SecurityManager implements
}
}
- private void mapAclConfigurationToPluginName(String aclFile, String pluginName)
+ private String getPluginTypeName(AccessControl accessControl)
{
- List<String> pluginNames = _aclConfigurationToPluginNamesMapping.get(aclFile);
- if (pluginNames == null)
- {
- pluginNames = new ArrayList<String>();
- _aclConfigurationToPluginNamesMapping.put(aclFile, pluginNames);
- }
- pluginNames.add(pluginName);
+ return accessControl.getClass().getName();
}
public static Subject getThreadSubject()
@@ -191,15 +200,6 @@ public class SecurityManager implements
return _logger;
}
- private static class CachedPropertiesMap extends LinkedHashMap<String, PublishAccessCheck>
- {
- @Override
- protected boolean removeEldestEntry(Entry<String, PublishAccessCheck> eldest)
- {
- return size() >= 200;
- }
- }
-
private abstract class AccessCheck
{
abstract Result allowed(AccessControl plugin);
@@ -500,16 +500,72 @@ public class SecurityManager implements
}
}
-
- public void addHostPlugin(AccessControl plugin)
- {
- _hostPlugins.put(plugin.getClass().getName(), plugin);
- }
-
@Override
public void stateChanged(ConfiguredObject object, State oldState, State newState)
{
- // no op
+ if(_managementMode)
+ {
+ //AccessControl is disabled in ManagementMode
+ return;
+ }
+
+ if(object instanceof AccessControlProvider)
+ {
+ if(newState == State.ACTIVE)
+ {
+ synchronized (_hostPlugins)
+ {
+ AccessControl accessControl = ((AccessControlProvider)object).getAccessControl();
+ String pluginTypeName = getPluginTypeName(accessControl);
+
+ _hostPlugins.put(pluginTypeName, accessControl);
+ }
+ }
+ else if(newState == State.DELETED)
+ {
+ synchronized (_hostPlugins)
+ {
+ AccessControl control = ((AccessControlProvider)object).getAccessControl();
+ String pluginTypeName = getPluginTypeName(control);
+
+ // Remove the type->control mapping for this type key only if the
+ // given control is actually referred to.
+ if(_hostPlugins.containsValue(control))
+ {
+ // If we are removing this control, check if another of the same
+ // type already exists on the broker and use it in instead.
+ AccessControl other = null;
+ Collection<AccessControlProvider> providers = _broker.getAccessControlProviders();
+ for(AccessControlProvider p : providers)
+ {
+ if(p == object || p.getActualState() != State.ACTIVE)
+ {
+ //we don't count ourself as another
+ continue;
+ }
+
+ AccessControl ac = p.getAccessControl();
+ if(pluginTypeName.equals(getPluginTypeName(ac)))
+ {
+ other = ac;
+ break;
+ }
+ }
+
+ if(other != null)
+ {
+ //Another control of this type was found, use it instead
+ _hostPlugins.replace(pluginTypeName, control, other);
+ }
+ else
+ {
+ //No other was found, remove the type entirely
+ _hostPlugins.remove(pluginTypeName);
+ }
+ }
+ }
+ }
+ }
}
@Override
@@ -527,29 +583,7 @@ public class SecurityManager implements
@Override
public void attributeSet(ConfiguredObject object, String attributeName, Object oldAttributeValue, Object newAttributeValue)
{
- if (object instanceof Broker && Broker.ACL_FILE.equals(attributeName))
- {
- // the code below is not thread safe, however, it should be fine in a management mode
- // as there will be no user connected
-
- if (oldAttributeValue != null)
- {
- List<String> pluginNames = _aclConfigurationToPluginNamesMapping.remove(oldAttributeValue);
- if (pluginNames != null)
- {
- for (String name : pluginNames)
- {
- _hostPlugins.remove(name);
- }
- }
- }
- if (newAttributeValue != null)
- {
- configureACLPlugin((String)newAttributeValue);
- }
- _immediatePublishPropsCache.clear();
- _publishPropsCache.clear();
- }
+ // no op
}
public boolean authoriseConfiguringBroker(String configuredObjectName, Class<? extends ConfiguredObject> configuredObjectType, Operation configuredObjectOperation)
Propchange: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost:r1469937
Modified: qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java Fri Apr 19 16:30:28 2013
@@ -131,7 +131,7 @@ public class VirtualHostImpl implements
CurrentActor.get().message(VirtualHostMessages.CREATED(_name));
- _securityManager = new SecurityManager(parentSecurityManager, _vhostConfig.getConfig().getString("security.acl"));
+ _securityManager = new SecurityManager(parentSecurityManager, _vhostConfig.getConfig().getString("security.acl"), _name);
_connectionRegistry = new ConnectionRegistry();
_connectionRegistry.addRegistryChangeListener(this);
Modified: qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java Fri Apr 19 16:30:28 2013
@@ -48,6 +48,7 @@ import org.apache.qpid.server.model.Plug
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.TrustStore;
import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.adapter.AccessControlProviderFactory;
import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
import org.apache.qpid.server.model.adapter.GroupProviderFactory;
import org.apache.qpid.server.model.adapter.PortFactory;
@@ -71,8 +72,8 @@ public class BrokerRecovererTest extends
{
super.setUp();
- _brokerRecoverer = new BrokerRecoverer(mock(AuthenticationProviderFactory.class), mock(GroupProviderFactory.class), mock(PortFactory.class), mock(StatisticsGatherer.class),
- mock(VirtualHostRegistry.class), mock(LogRecorder.class), mock(RootMessageLogger.class), mock(TaskExecutor.class), mock(BrokerOptions.class));
+ _brokerRecoverer = new BrokerRecoverer(mock(AuthenticationProviderFactory.class), mock(GroupProviderFactory.class), mock(AccessControlProviderFactory.class), mock(PortFactory.class),
+ mock(StatisticsGatherer.class), mock(VirtualHostRegistry.class), mock(LogRecorder.class), mock(RootMessageLogger.class), mock(TaskExecutor.class), mock(BrokerOptions.class));
when(_brokerEntry.getId()).thenReturn(_brokerId);
when(_brokerEntry.getChildren()).thenReturn(_brokerEntryChildren);
@@ -98,7 +99,6 @@ public class BrokerRecovererTest extends
attributes.put(Broker.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS, 2);
attributes.put(Broker.QUEUE_DEAD_LETTER_QUEUE_ENABLED, true);
attributes.put(Broker.VIRTUALHOST_HOUSEKEEPING_CHECK_PERIOD, 1l);
- attributes.put(Broker.ACL_FILE, "/path/to/acl");
attributes.put(Broker.CONNECTION_SESSION_COUNT_LIMIT, 1000);
attributes.put(Broker.CONNECTION_HEART_BEAT_DELAY, 2000);
attributes.put(Broker.STATISTICS_REPORTING_PERIOD, 4000);
Modified: qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java?rev=1469945&r1=1469944&r2=1469945&view=diff
==============================================================================
--- qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java (original)
+++ qpid/branches/0.22/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java Fri Apr 19 16:30:28 2013
@@ -70,7 +70,6 @@ public abstract class ConfigurationEntry
_brokerAttributes.put(Broker.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS, 2);
_brokerAttributes.put(Broker.QUEUE_DEAD_LETTER_QUEUE_ENABLED, true);
_brokerAttributes.put(Broker.VIRTUALHOST_HOUSEKEEPING_CHECK_PERIOD, 1);
- _brokerAttributes.put(Broker.ACL_FILE, "/path/to/acl");
_brokerAttributes.put(Broker.CONNECTION_SESSION_COUNT_LIMIT, 1000);
_brokerAttributes.put(Broker.CONNECTION_HEART_BEAT_DELAY, 2000);
_brokerAttributes.put(Broker.STATISTICS_REPORTING_PERIOD, 4000);
@@ -180,7 +179,6 @@ public abstract class ConfigurationEntry
attributes.put(Broker.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS, 12);
attributes.put(Broker.QUEUE_DEAD_LETTER_QUEUE_ENABLED, false);
attributes.put(Broker.VIRTUALHOST_HOUSEKEEPING_CHECK_PERIOD, 11);
- attributes.put(Broker.ACL_FILE, "/path/to/acl1");
attributes.put(Broker.CONNECTION_SESSION_COUNT_LIMIT, 11000);
attributes.put(Broker.CONNECTION_HEART_BEAT_DELAY, 12000);
attributes.put(Broker.STATISTICS_REPORTING_PERIOD, 14000);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org