You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2013/04/23 22:54:24 UTC
svn commit: r1471141 [5/11] - in /qpid/branches/QPID-4659/qpid/java: ./
amqp-1-0-client-jms/ amqp-1-0-client/ amqp-1-0-common/
amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/transport/
broker-plugins/access-control/src/main/java/org/apache/qpid...
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Tue Apr 23 20:54:19 2013
@@ -24,7 +24,6 @@ import java.lang.reflect.Type;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.security.AccessControlException;
-import java.security.KeyStoreException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -32,17 +31,19 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import javax.net.ssl.KeyManagerFactory;
-import java.security.cert.Certificate;
-
import org.apache.log4j.Logger;
import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.server.BrokerOptions;
+import org.apache.qpid.server.configuration.BrokerConfigurationStoreCreator;
import org.apache.qpid.server.configuration.ConfigurationEntryStore;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.logging.LogRecorder;
import org.apache.qpid.server.logging.RootMessageLogger;
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;
@@ -58,22 +59,19 @@ import org.apache.qpid.server.model.Stat
import org.apache.qpid.server.model.TrustStore;
import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.configuration.store.ManagementModeStoreHandler;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
-import org.apache.qpid.server.security.access.Operation;
-import org.apache.qpid.server.security.group.FileGroupManager;
-import org.apache.qpid.server.security.group.GroupManager;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderAdapter.SimpleAuthenticationProviderAdapter;
import org.apache.qpid.server.security.SecurityManager;
import org.apache.qpid.server.security.SubjectCreator;
+import org.apache.qpid.server.security.access.Operation;
+import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
+import org.apache.qpid.server.security.auth.manager.SimpleAuthenticationManager;
import org.apache.qpid.server.stats.StatisticsGatherer;
import org.apache.qpid.server.store.MessageStoreCreator;
import org.apache.qpid.server.util.MapValueConverter;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-import org.apache.qpid.transport.network.security.ssl.SSLUtil;
public class BrokerAdapter extends AbstractAdapter implements Broker, ConfigurationChangeListener
{
-
private static final Logger LOGGER = Logger.getLogger(BrokerAdapter.class);
@SuppressWarnings("serial")
@@ -95,19 +93,9 @@ 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);
- put(DEFAULT_AUTHENTICATION_PROVIDER, String.class);
- put(KEY_STORE_PATH, String.class);
- put(KEY_STORE_PASSWORD, String.class);
- put(KEY_STORE_CERT_ALIAS, String.class);
- put(TRUST_STORE_PATH, String.class);
- put(TRUST_STORE_PASSWORD, String.class);
- put(PEER_STORE_PATH, String.class);
- put(PEER_STORE_PASSWORD, String.class);
- put(GROUP_FILE, String.class);
put(VIRTUALHOST_STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE, Long.class);
put(VIRTUALHOST_STORE_TRANSACTION_IDLE_TIMEOUT_WARN, Long.class);
put(VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, Long.class);
@@ -133,12 +121,6 @@ public class BrokerAdapter extends Abstr
public static final long DEFAULT_STORE_TRANSACTION_IDLE_TIMEOUT_WARN = 0l;
public static final long DEFAULT_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE = 0l;
public static final long DEFAULT_STORE_TRANSACTION_OPEN_TIMEOUT_WARN = 0l;
- private static final String DEFAULT_KEY_STORE_NAME = "defaultKeyStore";
- private static final String DEFAULT_TRUST_STORE_NAME = "defaultTrustStore";
- private static final String DEFAULT_GROUP_PROVIDER_NAME = "defaultGroupProvider";
- private static final String DEFAULT_PEER_STORE_NAME = "defaultPeerStore";
-
- private static final String DUMMY_PASSWORD_MASK = "********";
@SuppressWarnings("serial")
private static final Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>(){{
@@ -182,25 +164,28 @@ public class BrokerAdapter extends Abstr
private final Map<UUID, AuthenticationProvider> _authenticationProviders = new HashMap<UUID, AuthenticationProvider>();
private final Map<String, GroupProvider> _groupProviders = new HashMap<String, GroupProvider>();
private final Map<UUID, ConfiguredObject> _plugins = new HashMap<UUID, ConfiguredObject>();
- private final Map<UUID, KeyStore> _keyStores = new HashMap<UUID, KeyStore>();
- private final Map<UUID, TrustStore> _trustStores = new HashMap<UUID, TrustStore>();
+ 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 AuthenticationProvider _defaultAuthenticationProvider;
+ private final AccessControlProviderFactory _accessControlProviderFactory;
private final PortFactory _portFactory;
private final SecurityManager _securityManager;
- private final UUID _defaultKeyStoreId;
- private final UUID _defaultTrustStoreId;
- private final Collection<String> _supportedStoreTypes;
+ private final Collection<String> _supportedVirtualHostStoreTypes;
+ private Collection<String> _supportedBrokerStoreTypes;
private final ConfigurationEntryStore _brokerStore;
- private boolean _managementMode;
+ private AuthenticationProvider _managementAuthenticationProvider;
+ private BrokerOptions _brokerOptions;
public BrokerAdapter(UUID id, Map<String, Object> attributes, StatisticsGatherer statisticsGatherer, VirtualHostRegistry virtualHostRegistry,
LogRecorder logRecorder, RootMessageLogger rootMessageLogger, AuthenticationProviderFactory authenticationProviderFactory,
- PortFactory portFactory, TaskExecutor taskExecutor, ConfigurationEntryStore brokerStore)
+ GroupProviderFactory groupProviderFactory, AccessControlProviderFactory accessControlProviderFactory, PortFactory portFactory, TaskExecutor taskExecutor,
+ ConfigurationEntryStore brokerStore, BrokerOptions brokerOptions)
{
super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), taskExecutor);
_statisticsGatherer = statisticsGatherer;
@@ -209,109 +194,20 @@ public class BrokerAdapter extends Abstr
_rootMessageLogger = rootMessageLogger;
_statistics = new StatisticsAdapter(statisticsGatherer);
_authenticationProviderFactory = authenticationProviderFactory;
+ _groupProviderFactory = groupProviderFactory;
+ _accessControlProviderFactory = accessControlProviderFactory;
_portFactory = portFactory;
- _securityManager = new SecurityManager((String)getAttribute(ACL_FILE));
- addChangeListener(_securityManager);
- _defaultKeyStoreId = UUIDGenerator.generateBrokerChildUUID(KeyStore.class.getSimpleName(), DEFAULT_KEY_STORE_NAME);
- _defaultTrustStoreId = UUIDGenerator.generateBrokerChildUUID(TrustStore.class.getSimpleName(), DEFAULT_TRUST_STORE_NAME);
- createBrokerChildrenFromAttributes();
- _supportedStoreTypes = new MessageStoreCreator().getStoreTypes();
+ _brokerOptions = brokerOptions;
+ _securityManager = new SecurityManager(this, _brokerOptions.isManagementMode());
+ _supportedVirtualHostStoreTypes = new MessageStoreCreator().getStoreTypes();
+ _supportedBrokerStoreTypes = new BrokerConfigurationStoreCreator().getStoreTypes();
_brokerStore = brokerStore;
- _managementMode = brokerStore instanceof ManagementModeStoreHandler;
- }
-
- /*
- * A temporary method to create broker children that can be only configured via broker attributes
- */
- private void createBrokerChildrenFromAttributes()
- {
- createGroupProvider();
- createKeyStore();
- createTrustStore();
- createPeerStore();
- }
-
- private void createGroupProvider()
- {
- String groupFile = (String) getAttribute(GROUP_FILE);
- if (groupFile != null)
+ if (_brokerOptions.isManagementMode())
{
- GroupManager groupManager = new FileGroupManager(groupFile);
- UUID groupProviderId = UUIDGenerator.generateBrokerChildUUID(GroupProvider.class.getSimpleName(),
- DEFAULT_GROUP_PROVIDER_NAME);
- GroupProviderAdapter groupProviderAdapter = new GroupProviderAdapter(groupProviderId, groupManager, this);
- _groupProviders.put(DEFAULT_GROUP_PROVIDER_NAME, groupProviderAdapter);
- }
- else
- {
- _groupProviders.remove(DEFAULT_GROUP_PROVIDER_NAME);
- }
- }
-
- private void createKeyStore()
- {
- Map<String, Object> actualAttributes = getActualAttributes();
- String keyStorePath = (String) getAttribute(KEY_STORE_PATH);
- if (keyStorePath != null)
- {
- Map<String, Object> keyStoreAttributes = new HashMap<String, Object>();
- keyStoreAttributes.put(KeyStore.NAME, DEFAULT_KEY_STORE_NAME);
- keyStoreAttributes.put(KeyStore.PATH, keyStorePath);
- keyStoreAttributes.put(KeyStore.PASSWORD, (String) actualAttributes.get(KEY_STORE_PASSWORD));
- keyStoreAttributes.put(KeyStore.TYPE, java.security.KeyStore.getDefaultType());
- keyStoreAttributes.put(KeyStore.CERTIFICATE_ALIAS, getAttribute(KEY_STORE_CERT_ALIAS));
- keyStoreAttributes.put(KeyStore.KEY_MANAGER_FACTORY_ALGORITHM, KeyManagerFactory.getDefaultAlgorithm());
- KeyStoreAdapter keyStoreAdapter = new KeyStoreAdapter(_defaultKeyStoreId, this, keyStoreAttributes);
- _keyStores.put(keyStoreAdapter.getId(), keyStoreAdapter);
- }
- else
- {
- _keyStores.remove(_defaultKeyStoreId);
- }
- }
-
- private void createTrustStore()
- {
- Map<String, Object> actualAttributes = getActualAttributes();
- String trustStorePath = (String) getAttribute(TRUST_STORE_PATH);
- if (trustStorePath != null)
- {
- Map<String, Object> trsustStoreAttributes = new HashMap<String, Object>();
- trsustStoreAttributes.put(TrustStore.NAME, DEFAULT_TRUST_STORE_NAME);
- trsustStoreAttributes.put(TrustStore.PATH, trustStorePath);
- trsustStoreAttributes.put(TrustStore.PEERS_ONLY, Boolean.FALSE);
- trsustStoreAttributes.put(TrustStore.PASSWORD, (String) actualAttributes.get(TRUST_STORE_PASSWORD));
- trsustStoreAttributes.put(TrustStore.TYPE, java.security.KeyStore.getDefaultType());
- trsustStoreAttributes.put(TrustStore.KEY_MANAGER_FACTORY_ALGORITHM, KeyManagerFactory.getDefaultAlgorithm());
- TrustStoreAdapter trustStore = new TrustStoreAdapter(_defaultTrustStoreId, this, trsustStoreAttributes);
- _trustStores.put(trustStore.getId(), trustStore);
- }
- else
- {
- _trustStores.remove(_defaultTrustStoreId);
- }
- }
-
- private void createPeerStore()
- {
- Map<String, Object> actualAttributes = getActualAttributes();
- String peerStorePath = (String) getAttribute(PEER_STORE_PATH);
- UUID peerStoreId = UUIDGenerator.generateBrokerChildUUID(TrustStore.class.getSimpleName(), DEFAULT_PEER_STORE_NAME);
- if (peerStorePath != null)
- {
- Map<String, Object> peerStoreAttributes = new HashMap<String, Object>();
- peerStoreAttributes.put(TrustStore.NAME, peerStoreId.toString());
- peerStoreAttributes.put(TrustStore.PATH, peerStorePath);
- peerStoreAttributes.put(TrustStore.PEERS_ONLY, Boolean.TRUE);
- peerStoreAttributes.put(TrustStore.PASSWORD, (String) actualAttributes.get(PEER_STORE_PASSWORD));
- peerStoreAttributes.put(TrustStore.TYPE, java.security.KeyStore.getDefaultType());
- peerStoreAttributes.put(TrustStore.KEY_MANAGER_FACTORY_ALGORITHM, KeyManagerFactory.getDefaultAlgorithm());
- TrustStoreAdapter trustStore = new TrustStoreAdapter(peerStoreId, this, peerStoreAttributes);
- _trustStores.put(trustStore.getId(), trustStore);
- }
- else
- {
- _trustStores.remove(peerStoreId);
+ AuthenticationManager authManager = new SimpleAuthenticationManager(BrokerOptions.MANAGEMENT_MODE_USER_NAME, _brokerOptions.getManagementModePassword());
+ AuthenticationProvider authenticationProvider = new SimpleAuthenticationProviderAdapter(UUID.randomUUID(), this,
+ authManager, Collections.<String, Object> emptyMap(), Collections.<String> emptySet());
+ _managementAuthenticationProvider = authenticationProvider;
}
}
@@ -321,7 +217,6 @@ public class BrokerAdapter extends Abstr
{
return new ArrayList<VirtualHost>(_vhostAdapters.values());
}
-
}
public Collection<Port> getPorts()
@@ -343,6 +238,10 @@ public class BrokerAdapter extends Abstr
public AuthenticationProvider findAuthenticationProviderByName(String authenticationProviderName)
{
+ if (isManagementMode())
+ {
+ return _managementAuthenticationProvider;
+ }
Collection<AuthenticationProvider> providers = getAuthenticationProviders();
for (AuthenticationProvider authenticationProvider : providers)
{
@@ -354,15 +253,20 @@ public class BrokerAdapter extends Abstr
return null;
}
- @Override
- public AuthenticationProvider getDefaultAuthenticationProvider()
+ public KeyStore findKeyStoreByName(String keyStoreName)
{
- return _defaultAuthenticationProvider;
+ synchronized(_keyStores)
+ {
+ return _keyStores.get(keyStoreName);
+ }
}
- public void setDefaultAuthenticationProvider(AuthenticationProvider provider)
+ public TrustStore findTrustStoreByName(String trustStoreName)
{
- _defaultAuthenticationProvider = provider;
+ synchronized(_trustStores)
+ {
+ return _trustStores.get(trustStoreName);
+ }
}
@Override
@@ -376,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
{
@@ -396,14 +289,14 @@ public class BrokerAdapter extends Abstr
// permission has already been granted to create the virtual host
// disable further access check on other operations, e.g. create exchange
- _securityManager.setAccessChecksDisabled(true);
+ SecurityManager.setAccessChecksDisabled(true);
try
{
virtualHostAdapter.setDesiredState(State.INITIALISING, State.ACTIVE);
}
finally
{
- _securityManager.setAccessChecksDisabled(false);
+ SecurityManager.setAccessChecksDisabled(false);
}
return virtualHostAdapter;
}
@@ -486,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();
@@ -522,10 +419,26 @@ 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);
}
+ else if(childClass == KeyStore.class)
+ {
+ return (C) createKeyStore(attributes);
+ }
+ else if(childClass == TrustStore.class)
+ {
+ return (C) createTrustStore(attributes);
+ }
+ else if(childClass == GroupProvider.class)
+ {
+ return (C) createGroupProvider(attributes);
+ }
else
{
throw new IllegalArgumentException("Cannot create child of class " + childClass.getSimpleName());
@@ -563,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;
@@ -599,6 +570,14 @@ public class BrokerAdapter extends Abstr
authenticationProvider.addChangeListener(this);
}
+ private GroupProvider createGroupProvider(Map<String, Object> attributes)
+ {
+ GroupProvider groupProvider = _groupProviderFactory.create(UUID.randomUUID(), this, attributes);
+ groupProvider.setDesiredState(State.INITIALISING, State.ACTIVE);
+ addGroupProvider(groupProvider);
+ return groupProvider;
+ }
+
private void addGroupProvider(GroupProvider groupProvider)
{
synchronized (_groupProviders)
@@ -613,45 +592,92 @@ public class BrokerAdapter extends Abstr
groupProvider.addChangeListener(this);
}
- private boolean deleteGroupProvider(GroupProvider object)
+ private boolean deleteGroupProvider(GroupProvider groupProvider)
+ {
+ GroupProvider removedGroupProvider = null;
+ synchronized (_groupProviders)
+ {
+ removedGroupProvider = _groupProviders.remove(groupProvider.getName());
+ }
+
+ if(removedGroupProvider != null)
+ {
+ removedGroupProvider.removeChangeListener(this);
+ }
+
+ return removedGroupProvider != null;
+ }
+
+ private KeyStore createKeyStore(Map<String, Object> attributes)
{
- throw new UnsupportedOperationException("Not implemented yet!");
+ KeyStore keyStore = new KeyStoreAdapter(UUIDGenerator.generateRandomUUID(), this, attributes);
+ addKeyStore(keyStore);
+
+ return keyStore;
+ }
+
+ private TrustStore createTrustStore(Map<String, Object> attributes)
+ {
+ TrustStore trustStore = new TrustStoreAdapter(UUIDGenerator.generateRandomUUID(), this, attributes);
+ addTrustStore(trustStore);
+
+ return trustStore;
}
private void addKeyStore(KeyStore keyStore)
{
synchronized (_keyStores)
{
- if(_keyStores.containsKey(keyStore.getId()))
+ if(_keyStores.containsKey(keyStore.getName()))
{
- throw new IllegalConfigurationException("Cannot add KeyStore because one with id " + keyStore.getId() + " already exists");
+ throw new IllegalConfigurationException("Can't add KeyStore because one with name " + keyStore.getName() + " already exists");
}
- _keyStores.put(keyStore.getId(), keyStore);
+ _keyStores.put(keyStore.getName(), keyStore);
}
keyStore.addChangeListener(this);
}
private boolean deleteKeyStore(KeyStore object)
{
- throw new UnsupportedOperationException("Not implemented yet!");
+ synchronized(_keyStores)
+ {
+ String name = object.getName();
+ KeyStore removedKeyStore = _keyStores.remove(name);
+ if(removedKeyStore != null)
+ {
+ removedKeyStore.removeChangeListener(this);
+ }
+
+ return removedKeyStore != null;
+ }
}
private void addTrustStore(TrustStore trustStore)
{
synchronized (_trustStores)
{
- if(_trustStores.containsKey(trustStore.getId()))
+ if(_trustStores.containsKey(trustStore.getName()))
{
- throw new IllegalConfigurationException("Cannot add TrustStore because one with id " + trustStore.getId() + " already exists");
+ throw new IllegalConfigurationException("Can't add TrustStore because one with name " + trustStore.getName() + " already exists");
}
- _trustStores.put(trustStore.getId(), trustStore);
+ _trustStores.put(trustStore.getName(), trustStore);
}
trustStore.addChangeListener(this);
}
private boolean deleteTrustStore(TrustStore object)
{
- throw new UnsupportedOperationException("Not implemented yet!");
+ synchronized(_trustStores)
+ {
+ String name = object.getName();
+ TrustStore removedTrustStore = _trustStores.remove(name);
+ if(removedTrustStore != null)
+ {
+ removedTrustStore.removeChangeListener(this);
+ }
+
+ return removedTrustStore != null;
+ }
}
@Override
@@ -718,21 +744,17 @@ public class BrokerAdapter extends Abstr
{
return QpidProperties.getReleaseVersion();
}
- else if(SUPPORTED_STORE_TYPES.equals(name))
+ else if(SUPPORTED_BROKER_STORE_TYPES.equals(name))
{
- return _supportedStoreTypes;
+ return _supportedBrokerStoreTypes;
}
- else if(SUPPORTED_AUTHENTICATION_PROVIDERS.equals(name))
+ else if(SUPPORTED_VIRTUALHOST_STORE_TYPES.equals(name))
{
- return _authenticationProviderFactory.getSupportedAuthenticationProviders();
+ return _supportedVirtualHostStoreTypes;
}
- else if (KEY_STORE_PASSWORD.equals(name) || TRUST_STORE_PASSWORD.equals(name) || PEER_STORE_PASSWORD.equals(name))
+ else if(SUPPORTED_AUTHENTICATION_PROVIDERS.equals(name))
{
- if (getActualAttributes().get(name) != null)
- {
- return DUMMY_PASSWORD_MASK;
- }
- return null;
+ return _authenticationProviderFactory.getSupportedAuthenticationProviders();
}
else if (MODEL_VERSION.equals(name))
{
@@ -760,6 +782,12 @@ public class BrokerAdapter extends Abstr
{
removedPort = _portAdapters.remove(portAdapter.getPort());
}
+
+ if (removedPort != null)
+ {
+ removedPort.removeChangeListener(this);
+ }
+
return removedPort != null;
}
@@ -770,6 +798,12 @@ public class BrokerAdapter extends Abstr
{
removedAuthenticationProvider = _authenticationProviders.remove(authenticationProvider.getId());
}
+
+ if(removedAuthenticationProvider != null)
+ {
+ removedAuthenticationProvider.removeChangeListener(this);
+ }
+
return removedAuthenticationProvider != null;
}
@@ -794,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
@@ -807,6 +842,11 @@ public class BrokerAdapter extends Abstr
changeState(_portAdapters, currentState,State.ACTIVE, false);
changeState(_plugins, currentState,State.ACTIVE, false);
+
+ if (isManagementMode())
+ {
+ CurrentActor.get().message(BrokerMessages.MANAGEMENT_MODE(BrokerOptions.MANAGEMENT_MODE_USER_NAME, _brokerOptions.getManagementModePassword()));
+ }
return true;
}
else if (desiredState == State.STOPPED)
@@ -865,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);
@@ -885,6 +929,7 @@ public class BrokerAdapter extends Abstr
{
childDeleted = deleteTrustStore((TrustStore)object);
}
+
if(childDeleted)
{
childRemoved(object);
@@ -938,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);
@@ -996,7 +1045,7 @@ public class BrokerAdapter extends Abstr
public SubjectCreator getSubjectCreator(SocketAddress localAddress)
{
InetSocketAddress inetSocketAddress = (InetSocketAddress)localAddress;
- AuthenticationProvider provider = _defaultAuthenticationProvider;
+ AuthenticationProvider provider = null;
Collection<Port> ports = getPorts();
for (Port p : ports)
{
@@ -1006,6 +1055,12 @@ public class BrokerAdapter extends Abstr
break;
}
}
+
+ if(provider == null)
+ {
+ throw new IllegalConfigurationException("Unable to determine authentication provider for address: " + localAddress);
+ }
+
return provider.getSubjectCreator();
}
@@ -1034,18 +1089,6 @@ public class BrokerAdapter extends Abstr
}
@Override
- public KeyStore getDefaultKeyStore()
- {
- return _keyStores.get(_defaultKeyStoreId);
- }
-
- @Override
- public TrustStore getDefaultTrustStore()
- {
- return _trustStores.get(_defaultTrustStoreId);
- }
-
- @Override
public TaskExecutor getTaskExecutor()
{
return super.getTaskExecutor();
@@ -1054,13 +1097,9 @@ public class BrokerAdapter extends Abstr
@Override
protected void changeAttributes(Map<String, Object> attributes)
{
- //TODO: Add management mode check
Map<String, Object> convertedAttributes = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES);
validateAttributes(convertedAttributes);
- boolean keyStoreChanged = false;
- boolean trustStoreChanged = false;
- boolean peerStoreChanged = false;
Collection<String> names = AVAILABLE_ATTRIBUTES;
for (String name : names)
{
@@ -1070,74 +1109,14 @@ public class BrokerAdapter extends Abstr
Object expected = getAttribute(name);
if (changeAttribute(name, expected, desired))
{
- if (GROUP_FILE.equals(name))
- {
- createGroupProvider();
- }
- else if (DEFAULT_AUTHENTICATION_PROVIDER.equals(name))
- {
- if (!_defaultAuthenticationProvider.getName().equals(desired))
- {
- _defaultAuthenticationProvider = findAuthenticationProviderByName((String)desired);
- }
- }
- else if (KEY_STORE_PATH.equals(name) || KEY_STORE_PASSWORD.equals(name) || KEY_STORE_CERT_ALIAS.equals(name))
- {
- keyStoreChanged = true;
- }
- else if (TRUST_STORE_PATH.equals(name) || TRUST_STORE_PASSWORD.equals(name))
- {
- trustStoreChanged = true;
- }
- else if (PEER_STORE_PATH.equals(name) || PEER_STORE_PASSWORD.equals(name))
- {
- peerStoreChanged = true;
- }
attributeSet(name, expected, desired);
}
}
}
- if (keyStoreChanged)
- {
- createKeyStore();
- }
- if (trustStoreChanged)
- {
- createTrustStore();
- }
- if (peerStoreChanged)
- {
- createPeerStore();
- }
}
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 groupFile = (String) convertedAttributes.get(GROUP_FILE);
- if (groupFile != null)
- {
- // create a group manager to validate the groups specified in file
- new FileGroupManager(groupFile);
- }
- validateKeyStoreAttributes(convertedAttributes, "key store", KEY_STORE_PATH, KEY_STORE_PASSWORD, KEY_STORE_CERT_ALIAS);
- validateKeyStoreAttributes(convertedAttributes, "trust store", TRUST_STORE_PATH, TRUST_STORE_PASSWORD, null);
- validateKeyStoreAttributes(convertedAttributes, "peer store", PEER_STORE_PATH, PEER_STORE_PASSWORD, null);
- String defaultAuthenticationProvider = (String) convertedAttributes.get(DEFAULT_AUTHENTICATION_PROVIDER);
- if (defaultAuthenticationProvider != null)
- {
- AuthenticationProvider provider = findAuthenticationProviderByName(defaultAuthenticationProvider);
- if (provider == null)
- {
- throw new IllegalConfigurationException("Authentication provider with name " + defaultAuthenticationProvider
- + " canot be set as a default as it does not exist");
- }
- }
String defaultVirtualHost = (String) convertedAttributes.get(DEFAULT_VIRTUAL_HOST);
if (defaultVirtualHost != null)
{
@@ -1176,59 +1155,6 @@ public class BrokerAdapter extends Abstr
}
}
- private void validateKeyStoreAttributes(Map<String, Object> convertedAttributes, String type, String pathAttribute,
- String passwordAttribute, String aliasAttribute)
- {
- String keyStoreFile = (String) convertedAttributes.get(pathAttribute);
- String password = (String) convertedAttributes.get(passwordAttribute);
- String alias = aliasAttribute!= null? (String) convertedAttributes.get(aliasAttribute) : null;
- if (keyStoreFile != null || password != null || alias != null)
- {
- if (keyStoreFile == null)
- {
- keyStoreFile = (String) getActualAttributes().get(pathAttribute);
- }
- if (password == null)
- {
- password = (String) getActualAttributes().get(passwordAttribute);
- }
- java.security.KeyStore keyStore = null;
- try
- {
- keyStore = SSLUtil.getInitializedKeyStore(keyStoreFile, password, java.security.KeyStore.getDefaultType());
- }
- catch (Exception e)
- {
- throw new IllegalConfigurationException("Cannot instantiate " + type + " at " + keyStoreFile, e);
- }
- if (aliasAttribute != null)
- {
- if (alias == null)
- {
- alias = (String) getActualAttributes().get(aliasAttribute);
- }
- if (alias != null)
- {
- Certificate cert = null;
- try
- {
- cert = keyStore.getCertificate(alias);
- }
- catch (KeyStoreException e)
- {
- // key store should be initialized above
- throw new RuntimeException("Key store has not been initialized", e);
- }
- if (cert == null)
- {
- throw new IllegalConfigurationException("Cannot find a certificate with alias " + alias + "in " + type
- + " : " + keyStoreFile);
- }
- }
- }
- }
- }
-
@Override
protected void authoriseSetAttribute(String name, Object expected, Object desired) throws AccessControlException
{
@@ -1260,6 +1186,15 @@ public class BrokerAdapter extends Abstr
@Override
public boolean isManagementMode()
{
- return _managementMode;
+ return _brokerOptions.isManagementMode();
+ }
+
+ @Override
+ public Collection<AccessControlProvider> getAccessControlProviders()
+ {
+ synchronized (_accessControlProviders)
+ {
+ return new ArrayList<AccessControlProvider>(_accessControlProviders.values());
+ }
}
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java Tue Apr 23 20:54:19 2013
@@ -24,6 +24,7 @@ import java.security.Principal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -48,9 +49,11 @@ public class GroupProviderAdapter extend
{
private final GroupManager _groupManager;
private final Broker _broker;
- public GroupProviderAdapter(UUID id, GroupManager groupManager, Broker broker)
+ private Collection<String> _supportedAttributes;
+
+ public GroupProviderAdapter(UUID id, Broker broker, GroupManager groupManager, Map<String, Object> attributes, Collection<String> attributeNames)
{
- super(id, broker.getTaskExecutor());
+ super(id, null, null, broker.getTaskExecutor());
if (groupManager == null)
{
@@ -58,13 +61,37 @@ public class GroupProviderAdapter extend
}
_groupManager = groupManager;
_broker = broker;
+ _supportedAttributes = createSupportedAttributes(attributeNames);
addParent(Broker.class, broker);
+
+ // set attributes now after all attribute names are known
+ if (attributes != null)
+ {
+ for (String name : _supportedAttributes)
+ {
+ if (attributes.containsKey(name))
+ {
+ changeAttribute(name, null, attributes.get(name));
+ }
+ }
+ }
+ }
+
+ protected Collection<String> createSupportedAttributes(Collection<String> factoryAttributes)
+ {
+ List<String> attributesNames = new ArrayList<String>(AVAILABLE_ATTRIBUTES);
+ if (factoryAttributes != null)
+ {
+ attributesNames.addAll(factoryAttributes);
+ }
+
+ return Collections.unmodifiableCollection(attributesNames);
}
@Override
public String getName()
{
- return _groupManager.getClass().getSimpleName();
+ return (String)getAttribute(NAME);
}
@Override
@@ -129,17 +156,13 @@ public class GroupProviderAdapter extend
@Override
public Collection<String> getAttributeNames()
{
- return GroupProvider.AVAILABLE_ATTRIBUTES;
+ return _supportedAttributes;
}
@Override
public Object getAttribute(String name)
{
- if (TYPE.equals(name))
- {
- return getName();
- }
- else if (CREATED.equals(name))
+ if (CREATED.equals(name))
{
// TODO
}
@@ -155,10 +178,6 @@ public class GroupProviderAdapter extend
{
return LifetimePolicy.PERMANENT;
}
- else if (NAME.equals(name))
- {
- return getName();
- }
else if (STATE.equals(name))
{
return State.ACTIVE; // TODO
@@ -220,11 +239,91 @@ public class GroupProviderAdapter extend
}
}
+ public GroupManager getGroupManager()
+ {
+ return _groupManager;
+ }
+
private SecurityManager getSecurityManager()
{
return _broker.getSecurityManager();
}
+ @Override
+ protected boolean setState(State currentState, State desiredState)
+ {
+ if (desiredState == State.ACTIVE)
+ {
+ _groupManager.open();
+ return true;
+ }
+ else if (desiredState == State.STOPPED)
+ {
+ _groupManager.close();
+ return true;
+ }
+ else if (desiredState == State.DELETED)
+ {
+ _groupManager.close();
+ _groupManager.onDelete();
+ return true;
+ }
+ return false;
+ }
+
+ public Set<Principal> getGroupPrincipalsForUser(String username)
+ {
+ return _groupManager.getGroupPrincipalsForUser(username);
+ }
+
+ @Override
+ protected void childAdded(ConfiguredObject child)
+ {
+ // no-op, prevent storing groups in the broker store
+ }
+
+ @Override
+ protected void childRemoved(ConfiguredObject child)
+ {
+ // no-op, as per above, groups are not in the store
+ }
+
+ @Override
+ protected void authoriseSetDesiredState(State currentState, State desiredState) throws AccessControlException
+ {
+ if(desiredState == State.DELETED)
+ {
+ if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), GroupProvider.class, Operation.DELETE))
+ {
+ throw new AccessControlException("Deletion of groups provider is denied");
+ }
+ }
+ }
+
+ @Override
+ protected void authoriseSetAttribute(String name, Object expected, Object desired) throws AccessControlException
+ {
+ if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), GroupProvider.class, Operation.UPDATE))
+ {
+ throw new AccessControlException("Setting of group provider attributes is denied");
+ }
+ }
+
+ @Override
+ protected void authoriseSetAttributes(Map<String, Object> attributes) throws AccessControlException
+ {
+ if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), GroupProvider.class, Operation.UPDATE))
+ {
+ throw new AccessControlException("Setting of group provider attributes is denied");
+ }
+ }
+
+ @Override
+ protected void changeAttributes(Map<String, Object> attributes)
+ {
+ throw new UnsupportedOperationException("Changing attributes on group providers is not supported.");
+ }
+
private class GroupAdapter extends AbstractAdapter implements Group
{
private final String _group;
@@ -526,23 +625,5 @@ public class GroupProviderAdapter extend
}
}
- @Override
- protected boolean setState(State currentState, State desiredState)
- {
- if (desiredState == State.ACTIVE)
- {
- return true;
- }
- else if (desiredState == State.STOPPED)
- {
- return true;
- }
- // TODO: DELETE state is ignored for now
- return false;
- }
- public Set<Principal> getGroupPrincipalsForUser(String username)
- {
- return _groupManager.getGroupPrincipalsForUser(username);
- }
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/KeyStoreAdapter.java Tue Apr 23 20:54:19 2013
@@ -20,23 +20,63 @@
*/
package org.apache.qpid.server.model.adapter;
+import java.lang.reflect.Type;
+import java.security.AccessControlException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import javax.net.ssl.KeyManagerFactory;
+
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.IntegrityViolationException;
import org.apache.qpid.server.model.KeyStore;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.security.access.Operation;
+import org.apache.qpid.server.util.MapValueConverter;
+import org.apache.qpid.transport.network.security.ssl.SSLUtil;
public class KeyStoreAdapter extends AbstractKeyStoreAdapter implements KeyStore
{
+ @SuppressWarnings("serial")
+ public static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{
+ put(NAME, String.class);
+ put(PATH, String.class);
+ put(PASSWORD, String.class);
+ put(TYPE, String.class);
+ put(CERTIFICATE_ALIAS, String.class);
+ put(KEY_MANAGER_FACTORY_ALGORITHM, String.class);
+ }});
+
+ @SuppressWarnings("serial")
+ public static final Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>(){{
+ put(KeyStore.TYPE, DEFAULT_KEYSTORE_TYPE);
+ put(KeyStore.KEY_MANAGER_FACTORY_ALGORITHM, KeyManagerFactory.getDefaultAlgorithm());
+ }});
+
+ private Broker _broker;
public KeyStoreAdapter(UUID id, Broker broker, Map<String, Object> attributes)
{
- super(id, broker, attributes);
- if (attributes.get(CERTIFICATE_ALIAS) != null)
- {
- changeAttribute(CERTIFICATE_ALIAS, null, attributes.get(CERTIFICATE_ALIAS));
- }
+ super(id, broker, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES));
+ _broker = broker;
+
+ String keyStorePath = (String)getAttribute(KeyStore.PATH);
+ String keyStorePassword = getPassword();
+ String keyStoreType = (String)getAttribute(KeyStore.TYPE);
+ String keyManagerFactoryAlgorithm = (String)getAttribute(KeyStore.KEY_MANAGER_FACTORY_ALGORITHM);
+ String certAlias = (String)getAttribute(KeyStore.CERTIFICATE_ALIAS);
+
+ validateKeyStoreAttributes(keyStoreType, keyStorePath, keyStorePassword,
+ certAlias, keyManagerFactoryAlgorithm);
}
@Override
@@ -45,4 +85,129 @@ public class KeyStoreAdapter extends Abs
return AVAILABLE_ATTRIBUTES;
}
+ @Override
+ protected boolean setState(State currentState, State desiredState)
+ {
+ if(desiredState == State.DELETED)
+ {
+ // verify that it is not in use
+ String storeName = getName();
+
+ Collection<Port> ports = new ArrayList<Port>(_broker.getPorts());
+ for (Port port : ports)
+ {
+ if (storeName.equals(port.getAttribute(Port.KEY_STORE)))
+ {
+ throw new IntegrityViolationException("Key store '" + storeName + "' can't be deleted as it is in use by a port:" + port.getName());
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ protected void authoriseSetDesiredState(State currentState, State desiredState) throws AccessControlException
+ {
+ if(desiredState == State.DELETED)
+ {
+ if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), KeyStore.class, Operation.DELETE))
+ {
+ throw new AccessControlException("Deletion of key store is denied");
+ }
+ }
+ }
+
+ @Override
+ protected void authoriseSetAttribute(String name, Object expected, Object desired) throws AccessControlException
+ {
+ authoriseSetAttribute();
+ }
+
+ @Override
+ protected void authoriseSetAttributes(Map<String, Object> attributes) throws AccessControlException
+ {
+ authoriseSetAttribute();
+ }
+
+ private void authoriseSetAttribute()
+ {
+ if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), KeyStore.class, Operation.UPDATE))
+ {
+ throw new AccessControlException("Setting key store attributes is denied");
+ }
+ }
+
+ @Override
+ protected void changeAttributes(Map<String, Object> attributes)
+ {
+ Map<String, Object> changedValues = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES);
+ if(changedValues.containsKey(KeyStore.NAME))
+ {
+ String newName = (String) changedValues.get(KeyStore.NAME);
+ if(!getName().equals(newName))
+ {
+ throw new IllegalConfigurationException("Changing the key store name is not allowed");
+ }
+ }
+
+ Map<String, Object> merged = generateEffectiveAttributes(changedValues);
+
+ String keyStorePath = (String)merged.get(KeyStore.PATH);
+ String keyStorePassword = (String) merged.get(KeyStore.PASSWORD);
+ String keyStoreType = (String)merged.get(KeyStore.TYPE);
+ String keyManagerFactoryAlgorithm = (String)merged.get(KeyStore.KEY_MANAGER_FACTORY_ALGORITHM);
+ String certAlias = (String)merged.get(KeyStore.CERTIFICATE_ALIAS);
+
+ validateKeyStoreAttributes(keyStoreType, keyStorePath, keyStorePassword,
+ certAlias, keyManagerFactoryAlgorithm);
+
+ super.changeAttributes(changedValues);
+ }
+
+ private void validateKeyStoreAttributes(String type, String keyStorePath,
+ String keyStorePassword, String alias,
+ String keyManagerFactoryAlgorithm)
+ {
+ java.security.KeyStore keyStore = null;
+ try
+ {
+ keyStore = SSLUtil.getInitializedKeyStore(keyStorePath, keyStorePassword, type);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalConfigurationException("Cannot instantiate key store at " + keyStorePath, e);
+ }
+
+ if (alias != null)
+ {
+ Certificate cert = null;
+ try
+ {
+ cert = keyStore.getCertificate(alias);
+ }
+ catch (KeyStoreException e)
+ {
+ // key store should be initialized above
+ throw new RuntimeException("Key store has not been initialized", e);
+ }
+ if (cert == null)
+ {
+ throw new IllegalConfigurationException("Cannot find a certificate with alias " + alias
+ + "in key store : " + keyStorePath);
+ }
+ }
+
+ try
+ {
+ KeyManagerFactory.getInstance(keyManagerFactoryAlgorithm);
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ throw new IllegalConfigurationException("Unknown keyManagerFactoryAlgorithm: "
+ + keyManagerFactoryAlgorithm);
+ }
+ }
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java Tue Apr 23 20:54:19 2013
@@ -37,12 +37,14 @@ import org.apache.qpid.server.model.Auth
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.Connection;
+import org.apache.qpid.server.model.KeyStore;
import org.apache.qpid.server.model.LifetimePolicy;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.Protocol;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.Statistics;
import org.apache.qpid.server.model.Transport;
+import org.apache.qpid.server.model.TrustStore;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.model.VirtualHostAlias;
import org.apache.qpid.server.security.access.Operation;
@@ -58,6 +60,8 @@ public class PortAdapter extends Abstrac
put(NAME, String.class);
put(PROTOCOLS, new ParameterizedTypeImpl(Set.class, Protocol.class));
put(TRANSPORTS, new ParameterizedTypeImpl(Set.class, Transport.class));
+ put(TRUST_STORES, new ParameterizedTypeImpl(Set.class, String.class));
+ put(KEY_STORE, String.class);
put(PORT, Integer.class);
put(TCP_NO_DELAY, Boolean.class);
put(RECEIVE_BUFFER_SIZE, Integer.class);
@@ -78,6 +82,24 @@ public class PortAdapter extends Abstrac
super(id, defaults, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), taskExecutor);
_broker = broker;
State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING);
+
+ Collection<Protocol> protocols = getProtocols();
+ boolean rmiRegistry = protocols != null && protocols.contains(Protocol.RMI);
+ if (!rmiRegistry)
+ {
+ String authProvider = (String)getAttribute(Port.AUTHENTICATION_PROVIDER);
+ if (authProvider == null)
+ {
+ throw new IllegalConfigurationException("An authentication provider must be specified for port : " + getName());
+ }
+ _authenticationProvider = broker.findAuthenticationProviderByName(authProvider);
+
+ if(_authenticationProvider == null)
+ {
+ throw new IllegalConfigurationException("The authentication provider '" + authProvider + "' could not be found for port : " + getName());
+ }
+ }
+
_state = new AtomicReference<State>(state);
addParent(Broker.class, broker);
}
@@ -346,11 +368,6 @@ public class PortAdapter extends Abstrac
return _authenticationProvider;
}
- public void setAuthenticationProvider(AuthenticationProvider authenticationProvider)
- {
- _authenticationProvider = authenticationProvider;
- }
-
@Override
protected void changeAttributes(Map<String, Object> attributes)
{
@@ -373,16 +390,40 @@ public class PortAdapter extends Abstrac
boolean requiresCertificate = (needClientCertificate != null && needClientCertificate.booleanValue())
|| (wantClientCertificate != null && wantClientCertificate.booleanValue());
- if (transports != null && transports.contains(Transport.SSL))
+ String keyStoreName = (String) merged.get(KEY_STORE);
+ boolean hasKeyStore = keyStoreName != null;
+ if(keyStoreName != null)
{
- if (_broker.getKeyStores().isEmpty())
+ if (_broker.findKeyStoreByName(keyStoreName) == null)
{
- throw new IllegalConfigurationException("Can't create port which requires SSL as the broker has no keystore configured.");
+ throw new IllegalConfigurationException("Can't find key store with name '" + keyStoreName + "' for port " + getName());
}
+ }
- if (_broker.getTrustStores().isEmpty() && requiresCertificate)
+ Set<String> trustStoreNames = (Set<String>) merged.get(TRUST_STORES);
+ boolean hasTrustStore = trustStoreNames != null && !trustStoreNames.isEmpty();
+ if(hasTrustStore)
+ {
+ for (String trustStoreName : trustStoreNames)
{
- throw new IllegalConfigurationException("Can't create port which requests SSL client certificates as the broker has no trust/peer stores configured.");
+ if (_broker.findTrustStoreByName(trustStoreName) == null)
+ {
+ throw new IllegalConfigurationException("Cannot find trust store with name '" + trustStoreName + "'");
+ }
+ }
+ }
+
+ boolean usesSsl = transports != null && transports.contains(Transport.SSL);
+ if (usesSsl)
+ {
+ if (keyStoreName == null)
+ {
+ throw new IllegalConfigurationException("Can't create port which requires SSL but has no key store configured.");
+ }
+
+ if (!hasTrustStore && requiresCertificate)
+ {
+ throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust store configured.");
}
}
else
@@ -393,9 +434,14 @@ public class PortAdapter extends Abstrac
}
}
- if (protocols != null && protocols.contains(Protocol.HTTPS) && _broker.getKeyStores().isEmpty())
+ if (protocols != null && protocols.contains(Protocol.HTTPS) && !hasKeyStore)
+ {
+ throw new IllegalConfigurationException("Can't create port which requires SSL but has no key store configured.");
+ }
+
+ if (protocols != null && protocols.contains(Protocol.RMI) && usesSsl)
{
- throw new IllegalConfigurationException("Can't create port which requires SSL as the broker has no keystore configured.");
+ throw new IllegalConfigurationException("Can't create RMI Registry port which requires SSL.");
}
String authenticationProviderName = (String)merged.get(AUTHENTICATION_PROVIDER);
@@ -418,6 +464,14 @@ public class PortAdapter extends Abstrac
+ authenticationProviderName + "'");
}
}
+ else
+ {
+ if (protocols != null && !protocols.contains(Protocol.RMI))
+ {
+ throw new IllegalConfigurationException("An authentication provider must be specified");
+ }
+ }
+
super.changeAttributes(converted);
}
@@ -450,4 +504,42 @@ public class PortAdapter extends Abstrac
throw new AccessControlException("Setting of port attributes is denied");
}
}
+
+ @Override
+ public KeyStore getKeyStore()
+ {
+ String keyStoreName = (String)getAttribute(Port.KEY_STORE);
+ KeyStore keyStore = _broker.findKeyStoreByName(keyStoreName);
+
+ if (keyStoreName != null && keyStore == null)
+ {
+ throw new IllegalConfigurationException("Can't find key store with name '" + keyStoreName + "' for port " + getName());
+ }
+
+ return keyStore;
+ }
+
+ @Override
+ public Collection<TrustStore> getTrustStores()
+ {
+ Set<String> trustStoreNames = (Set<String>) getAttribute(TRUST_STORES);
+ boolean hasTrustStoreName = trustStoreNames != null && !trustStoreNames.isEmpty();
+
+ final Collection<TrustStore> trustStores = new ArrayList<TrustStore>();
+ if(hasTrustStoreName)
+ {
+ for (String name : trustStoreNames)
+ {
+ TrustStore trustStore = _broker.findTrustStoreByName(name);
+ if (trustStore == null)
+ {
+ throw new IllegalConfigurationException("Can't find trust store with name '" + name + "' for port " + getName());
+ }
+
+ trustStores.add(trustStore);
+ }
+ }
+
+ return trustStores;
+ }
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java Tue Apr 23 20:54:19 2013
@@ -106,9 +106,9 @@ public class PortFactory
port = new AmqpPortAdapter(id, broker, attributes, defaults, broker.getTaskExecutor());
boolean useClientAuth = (Boolean) port.getAttribute(Port.NEED_CLIENT_AUTH) || (Boolean) port.getAttribute(Port.WANT_CLIENT_AUTH);
- if(useClientAuth && broker.getTrustStores().isEmpty())
+ if(useClientAuth && port.getTrustStores().isEmpty())
{
- throw new IllegalConfigurationException("Can't create port which requests SSL client certificates as the broker has no trust/peer stores configured.");
+ throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust stores configured.");
}
if(useClientAuth && !port.getTransports().contains(Transport.SSL))
@@ -142,13 +142,19 @@ public class PortFactory
defaults.put(Port.NAME, portValue + "-" + protocol.name());
port = new PortAdapter(id, broker, attributes, defaults, broker.getTaskExecutor());
+
+ boolean rmiPort = port.getProtocols().contains(Protocol.RMI);
+ if (rmiPort && port.getTransports().contains(Transport.SSL))
+ {
+ throw new IllegalConfigurationException("Can't create RMI registry port which requires SSL");
+ }
}
if(port.getTransports().contains(Transport.SSL) || port.getProtocols().contains(Protocol.HTTPS))
{
- if(broker.getKeyStores().isEmpty())
+ if(port.getKeyStore() == null)
{
- throw new IllegalConfigurationException("Can't create port which requires SSL as the broker has no keystore configured.");
+ throw new IllegalConfigurationException("Can't create port which requires SSL but has no key store configured.");
}
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/TrustStoreAdapter.java Tue Apr 23 20:54:19 2013
@@ -20,18 +20,61 @@
*/
package org.apache.qpid.server.model.adapter;
+import java.lang.reflect.Type;
+import java.security.AccessControlException;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.IntegrityViolationException;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.TrustStore;
+import org.apache.qpid.server.security.access.Operation;
+import org.apache.qpid.server.util.MapValueConverter;
+import org.apache.qpid.transport.network.security.ssl.SSLUtil;
public class TrustStoreAdapter extends AbstractKeyStoreAdapter implements TrustStore
{
+ @SuppressWarnings("serial")
+ public static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{
+ put(NAME, String.class);
+ put(PATH, String.class);
+ put(PASSWORD, String.class);
+ put(TYPE, String.class);
+ put(PEERS_ONLY, Boolean.class);
+ put(TRUST_MANAGER_FACTORY_ALGORITHM, String.class);
+ }});
+
+ @SuppressWarnings("serial")
+ public static final Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>(){{
+ put(TrustStore.TYPE, DEFAULT_KEYSTORE_TYPE);
+ put(TrustStore.PEERS_ONLY, Boolean.FALSE);
+ put(TrustStore.TRUST_MANAGER_FACTORY_ALGORITHM, TrustManagerFactory.getDefaultAlgorithm());
+ }});
+
+ private Broker _broker;
+
public TrustStoreAdapter(UUID id, Broker broker, Map<String, Object> attributes)
{
- super(id, broker, attributes);
+ super(id, broker, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES));
+ _broker = broker;
+
+ String trustStorePath = (String) getAttribute(TrustStore.PATH);
+ String trustStorePassword = getPassword();
+ String trustStoreType = (String) getAttribute(TrustStore.TYPE);
+ String trustManagerFactoryAlgorithm = (String) getAttribute(TrustStore.TRUST_MANAGER_FACTORY_ALGORITHM);
+
+ validateTrustStoreAttributes(trustStoreType, trustStorePath,
+ trustStorePassword, trustManagerFactoryAlgorithm);
}
@Override
@@ -40,4 +83,110 @@ public class TrustStoreAdapter extends A
return AVAILABLE_ATTRIBUTES;
}
+ @Override
+ protected boolean setState(State currentState, State desiredState)
+ {
+ if(desiredState == State.DELETED)
+ {
+ // verify that it is not in use
+ String storeName = getName();
+
+ Collection<Port> ports = new ArrayList<Port>(_broker.getPorts());
+ for (Port port : ports)
+ {
+ Collection<TrustStore> trustStores = port.getTrustStores();
+ for(TrustStore store : trustStores)
+ {
+ if (storeName.equals(store.getAttribute(TrustStore.NAME)))
+ {
+ throw new IntegrityViolationException("Trust store '" + storeName + "' can't be deleted as it is in use by a port: " + port.getName());
+ }
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ protected void authoriseSetDesiredState(State currentState, State desiredState) throws AccessControlException
+ {
+ if(desiredState == State.DELETED)
+ {
+ if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), TrustStore.class, Operation.DELETE))
+ {
+ throw new AccessControlException("Deletion of key store is denied");
+ }
+ }
+ }
+
+ @Override
+ protected void authoriseSetAttribute(String name, Object expected, Object desired) throws AccessControlException
+ {
+ authoriseSetAttribute();
+ }
+
+ @Override
+ protected void authoriseSetAttributes(Map<String, Object> attributes) throws AccessControlException
+ {
+ authoriseSetAttribute();
+ }
+
+ private void authoriseSetAttribute()
+ {
+ if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), TrustStore.class, Operation.UPDATE))
+ {
+ throw new AccessControlException("Setting key store attributes is denied");
+ }
+ }
+
+ @Override
+ protected void changeAttributes(Map<String, Object> attributes)
+ {
+ Map<String, Object> changedValues = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES);
+ if(changedValues.containsKey(TrustStore.NAME))
+ {
+ String newName = (String) changedValues.get(TrustStore.NAME);
+ if(!getName().equals(newName))
+ {
+ throw new IllegalConfigurationException("Changing the trust store name is not allowed");
+ }
+ }
+
+ Map<String, Object> merged = generateEffectiveAttributes(changedValues);
+
+ String trustStorePath = (String)merged.get(TrustStore.PATH);
+ String trustStorePassword = (String) merged.get(TrustStore.PASSWORD);
+ String trustStoreType = (String)merged.get(TrustStore.TYPE);
+ String trustManagerFactoryAlgorithm = (String)merged.get(TrustStore.TRUST_MANAGER_FACTORY_ALGORITHM);
+
+ validateTrustStoreAttributes(trustStoreType, trustStorePath,
+ trustStorePassword, trustManagerFactoryAlgorithm);
+
+ super.changeAttributes(changedValues);
+ }
+
+ private void validateTrustStoreAttributes(String type, String trustStorePath,
+ String password, String trustManagerFactoryAlgorithm)
+ {
+ try
+ {
+ SSLUtil.getInitializedKeyStore(trustStorePath, password, type);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalConfigurationException("Cannot instantiate trust store at " + trustStorePath, e);
+ }
+
+ try
+ {
+ TrustManagerFactory.getInstance(trustManagerFactoryAlgorithm);
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ throw new IllegalConfigurationException("Unknown trustManagerFactoryAlgorithm: " + trustManagerFactoryAlgorithm);
+ }
+ }
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java Tue Apr 23 20:54:19 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();
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java Tue Apr 23 20:54:19 2013
@@ -34,11 +34,12 @@ public interface ConfigurationStoreFacto
/**
* Creates and opens the store from a given location using initial store if provided.
* <p>
- * If location does not exists than a new store is created either empty or from the initial store if it is provided
+ * If location does not exist, or the overwrite option is specified, then a new store is created from the initial store if it is provided
*
* @param storeLocation store location
* @param initialStore initial store
+ * @param overwrite overwrite existing store with initial store
* @throws IllegalConfigurationException if store cannot be opened in the given location
*/
- public ConfigurationEntryStore createStore(String storeLocation, ConfigurationEntryStore initialStore);
+ public ConfigurationEntryStore createStore(String storeLocation, ConfigurationEntryStore initialStore, boolean overwrite);
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java Tue Apr 23 20:54:19 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.GroupProvider;
import org.apache.qpid.server.security.group.GroupManager;
public interface GroupManagerFactory
{
+ public static final String ATTRIBUTE_TYPE = GroupProvider.TYPE;
+
GroupManager createInstance(Map<String, Object> attributes);
+
+ /**
+ * Returns the authentication provider type
+ * @return authentication provider type
+ */
+ String getType();
+
+ /**
+ * Get the names of attributes the group manager 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/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v0_8/SubscriptionImpl.java
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v0_8/SubscriptionImpl.java:r1463061,1465459,1465590,1466482,1467334,1467922,1467930,1467932,1467938,1467940,1467992,1468815-1468816,1468830,1468875,1468953,1469256,1469914,1469916-1469917,1469937,1470439,1470454,1470457,1470463,1470474,1470897,1470899,1471004
Propchange: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v0_8/handler:r1463061,1465459,1465590,1466482,1467334,1467922,1467930,1467932,1467938,1467940,1467992,1468815-1468816,1468830,1468875,1468953,1469256,1469914,1469916-1469917,1469937,1470439,1470454,1470457,1470463,1470474,1470897,1470899,1471004
Propchange: qpid/branches/QPID-4659/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:r1463061,1465459,1465590,1466482,1467334,1467922,1467930,1467932,1467938,1467940,1467992,1468815-1468816,1468830,1468875,1468953,1469256,1469914,1469916-1469917,1469937,1470439,1470454,1470457,1470463,1470474,1470897,1470899,1471004
Propchange: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java:r1463061,1465459,1465590,1466482,1467334,1467922,1467930,1467932,1467938,1467940,1467992,1468815-1468816,1468830,1468875,1468953,1469256,1469914,1469916-1469917,1469937,1470439,1470454,1470457,1470463,1470474,1470897,1470899,1471004
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0.java Tue Apr 23 20:54:19 2013
@@ -22,6 +22,7 @@ package org.apache.qpid.server.protocol.
import java.net.SocketAddress;
import java.nio.ByteBuffer;
+import java.security.Principal;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -41,6 +42,7 @@ import org.apache.qpid.protocol.ServerPr
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.protocol.v1_0.Connection_1_0;
import org.apache.qpid.server.security.SubjectCreator;
+import org.apache.qpid.server.security.auth.UsernamePrincipal;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.transport.Sender;
import org.apache.qpid.transport.network.NetworkConnection;
@@ -170,6 +172,12 @@ public class ProtocolEngine_1_0_0 implem
{
return subjectCreator.createSaslServer(mechanism, fqdn, null);
}
+
+ @Override
+ public Principal getAuthenticatedPrincipal(SaslServer server)
+ {
+ return new UsernamePrincipal(server.getAuthorizationID());
+ }
};
}
Propchange: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0.java
------------------------------------------------------------------------------
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0.java:r1463061,1465459,1465590,1466482,1467334,1467922,1467930,1467932,1467938,1467940,1467992,1468815-1468816,1468830,1468875,1468953,1469256,1469914,1469916-1469917,1469937,1470439,1470454,1470457,1470463,1470474,1470897,1470899,1471004
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/ProtocolEngine_1_0_0.java:r1465459
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java Tue Apr 23 20:54:19 2013
@@ -23,6 +23,7 @@ package org.apache.qpid.server.protocol.
import java.io.PrintWriter;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
+import java.security.Principal;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.security.sasl.SaslException;
@@ -42,6 +43,7 @@ import org.apache.qpid.protocol.ServerPr
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.protocol.v1_0.Connection_1_0;
import org.apache.qpid.server.security.SubjectCreator;
+import org.apache.qpid.server.security.auth.UsernamePrincipal;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.transport.Sender;
import org.apache.qpid.transport.network.NetworkConnection;
@@ -162,7 +164,8 @@ public class ProtocolEngine_1_0_0_SASL i
Container container = new Container(_broker.getId().toString());
VirtualHost virtualHost = _broker.getVirtualHostRegistry().getVirtualHost((String)_broker.getAttribute(Broker.DEFAULT_VIRTUAL_HOST));
- _conn = new ConnectionEndpoint(container, asSaslServerProvider(_broker.getSubjectCreator(getLocalAddress())));
+ SubjectCreator subjectCreator = _broker.getSubjectCreator(getLocalAddress());
+ _conn = new ConnectionEndpoint(container, asSaslServerProvider(subjectCreator));
_conn.setRemoteAddress(getRemoteAddress());
_conn.setConnectionEventListener(new Connection_1_0(virtualHost, _conn, _connectionId));
_conn.setFrameOutputHandler(this);
@@ -189,7 +192,7 @@ public class ProtocolEngine_1_0_0_SASL i
_sender.send(HEADER.duplicate());
_sender.flush();
- _conn.initiateSASL();
+ _conn.initiateSASL(subjectCreator.getMechanisms().split(" "));
}
@@ -201,7 +204,13 @@ public class ProtocolEngine_1_0_0_SASL i
@Override
public SaslServer getSaslServer(String mechanism, String fqdn) throws SaslException
{
- return subjectCreator.createSaslServer(mechanism, fqdn, null);
+ return subjectCreator.createSaslServer(mechanism, fqdn, _network.getPeerPrincipal());
+ }
+
+ @Override
+ public Principal getAuthenticatedPrincipal(SaslServer server)
+ {
+ return new UsernamePrincipal(server.getAuthorizationID());
}
};
}
@@ -230,7 +239,7 @@ public class ProtocolEngine_1_0_0_SASL i
Binary bin = new Binary(data);
RAW_LOGGER.fine("RECV[" + getRemoteAddress() + "] : " + bin.toString());
}
- _readBytes += msg.remaining();
+ _readBytes += msg.remaining();
switch(_state)
{
case A:
@@ -392,7 +401,6 @@ public class ProtocolEngine_1_0_0_SASL i
RAW_LOGGER.fine("SEND[" + getRemoteAddress() + "] : " + bin.toString());
}
-
_sender.send(dup);
_sender.flush();
Propchange: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/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:r1465459
Merged /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/ProtocolEngine_1_0_0_SASL.java:r1463061,1465459,1465590,1466482,1467334,1467922,1467930,1467932,1467938,1467940,1467992,1468815-1468816,1468830,1468875,1468953,1469256,1469914,1469916-1469917,1469937,1470439,1470454,1470457,1470463,1470474,1470897,1470899,1471004
Propchange: qpid/branches/QPID-4659/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:r1463061,1465459,1465590,1466482,1467334,1467922,1467930,1467932,1467938,1467940,1467992,1468815-1468816,1468830,1468875,1468953,1469256,1469914,1469916-1469917,1469937,1470439,1470454,1470457,1470463,1470474,1470897,1470899,1471004
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/BaseQueue.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/BaseQueue.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/BaseQueue.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/BaseQueue.java Tue Apr 23 20:54:19 2013
@@ -38,6 +38,7 @@ public interface BaseQueue extends Trans
void enqueue(ServerMessage message, boolean transactional, PostEnqueueAction action) throws AMQException;
boolean isDurable();
+ boolean isDeleted();
AMQShortString getNameShortString();
}
Modified: qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java?rev=1471141&r1=1471140&r2=1471141&view=diff
==============================================================================
--- qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java (original)
+++ qpid/branches/QPID-4659/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java Tue Apr 23 20:54:19 2013
@@ -27,6 +27,7 @@ import java.util.TimerTask;
import org.apache.log4j.Logger;
import org.apache.qpid.common.Closeable;
import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.server.BrokerOptions;
import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.configuration.ConfigurationEntryStore;
import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
@@ -89,7 +90,7 @@ public class ApplicationRegistry impleme
initialiseStatistics();
}
- public void initialise() throws Exception
+ public void initialise(BrokerOptions brokerOptions) throws Exception
{
// Create the RootLogger to be used during broker operation
boolean statusUpdatesEnabled = Boolean.parseBoolean(System.getProperty(BrokerProperties.PROPERTY_STATUS_UPDATES, "true"));
@@ -112,7 +113,7 @@ public class ApplicationRegistry impleme
_taskExecutor = new TaskExecutor();
_taskExecutor.start();
- RecovererProvider provider = new DefaultRecovererProvider((StatisticsGatherer)this, _virtualHostRegistry, _logRecorder, _rootMessageLogger, _taskExecutor);
+ RecovererProvider provider = new DefaultRecovererProvider((StatisticsGatherer)this, _virtualHostRegistry, _logRecorder, _rootMessageLogger, _taskExecutor, brokerOptions);
ConfiguredObjectRecoverer<? extends ConfiguredObject> brokerRecoverer = provider.getRecoverer(Broker.class.getSimpleName());
_broker = (Broker) brokerRecoverer.create(provider, _store.getRootEntry());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org