diff options
author | Robert Godfrey <rgodfrey@apache.org> | 2014-08-25 15:28:50 +0000 |
---|---|---|
committer | Robert Godfrey <rgodfrey@apache.org> | 2014-08-25 15:28:50 +0000 |
commit | 9556a8d9c53be396a25cd4c29842b79e99bc1746 (patch) | |
tree | bf6f92cfaee1883199c743bd25359841af3e7f1b | |
parent | 19478e74524f27e26f01117b1b973829718ed44d (diff) | |
download | qpid-python-9556a8d9c53be396a25cd4c29842b79e99bc1746.tar.gz |
Merging from trunk r1618473:1618815 in the Java tree
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.30@1620348 13f79535-47bb-0310-9956-ffa450edef68
82 files changed, 913 insertions, 182 deletions
diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolTypeConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolTypeConstructor.java index b96e1ab47b..b75bba8c6a 100644 --- a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolTypeConstructor.java +++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/codec/SymbolTypeConstructor.java @@ -20,19 +20,20 @@ */ package org.apache.qpid.amqp_1_0.codec; -import org.apache.qpid.amqp_1_0.type.AmqpErrorException; -import org.apache.qpid.amqp_1_0.type.Symbol; - import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.apache.qpid.amqp_1_0.type.AmqpErrorException; +import org.apache.qpid.amqp_1_0.type.Symbol; public class SymbolTypeConstructor extends VariableWidthTypeConstructor { private static final Charset ASCII = Charset.forName("US-ASCII"); - private static final ConcurrentHashMap<BinaryString, Symbol> SYMBOL_MAP = + private static final ConcurrentMap<BinaryString, Symbol> SYMBOL_MAP = new ConcurrentHashMap<BinaryString, Symbol>(2048); public static SymbolTypeConstructor getInstance(int i) @@ -89,4 +90,4 @@ public class SymbolTypeConstructor extends VariableWidthTypeConstructor } -}
\ No newline at end of file +} diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Symbol.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Symbol.java index de4e86f201..93be3ee873 100644 --- a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Symbol.java +++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/Symbol.java @@ -22,11 +22,12 @@ package org.apache.qpid.amqp_1_0.type; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; public final class Symbol implements Comparable<Symbol>, CharSequence { private final String _underlying; - private static final ConcurrentHashMap<String, Symbol> _symbols = new ConcurrentHashMap<String, Symbol>(2048); + private static final ConcurrentMap<String, Symbol> _symbols = new ConcurrentHashMap<String, Symbol>(2048); private Symbol(String underlying) { diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java index 6451bc6927..a3b3ec7324 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/StandardEnvironmentFacade.java @@ -24,28 +24,28 @@ import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; - -import com.sleepycat.je.DatabaseEntry; -import com.sleepycat.je.Sequence; -import com.sleepycat.je.SequenceConfig; - -import org.apache.log4j.Logger; -import org.apache.qpid.server.store.StoreFuture; +import java.util.concurrent.ConcurrentMap; import com.sleepycat.je.Database; import com.sleepycat.je.DatabaseConfig; +import com.sleepycat.je.DatabaseEntry; import com.sleepycat.je.DatabaseException; import com.sleepycat.je.Environment; import com.sleepycat.je.EnvironmentConfig; +import com.sleepycat.je.Sequence; +import com.sleepycat.je.SequenceConfig; import com.sleepycat.je.Transaction; +import org.apache.log4j.Logger; + +import org.apache.qpid.server.store.StoreFuture; public class StandardEnvironmentFacade implements EnvironmentFacade { private static final Logger LOGGER = Logger.getLogger(StandardEnvironmentFacade.class); private final String _storePath; - private final ConcurrentHashMap<String, Database> _cachedDatabases = new ConcurrentHashMap<>(); - private final ConcurrentHashMap<DatabaseEntry, Sequence> _cachedSequences = new ConcurrentHashMap<>(); + private final ConcurrentMap<String, Database> _cachedDatabases = new ConcurrentHashMap<>(); + private final ConcurrentMap<DatabaseEntry, Sequence> _cachedSequences = new ConcurrentHashMap<>(); private Environment _environment; private final Committer _committer; diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java index d045ae01fa..4f47e0fa53 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java @@ -170,8 +170,8 @@ public class ReplicatedEnvironmentFacade implements EnvironmentFacade, StateChan private volatile ReplicatedEnvironment.State _lastKnownEnvironmentState; private volatile Durability _messageStoreDurability; - private final ConcurrentHashMap<String, Database> _cachedDatabases = new ConcurrentHashMap<>(); - private final ConcurrentHashMap<DatabaseEntry, Sequence> _cachedSequences = new ConcurrentHashMap<>(); + private final ConcurrentMap<String, Database> _cachedDatabases = new ConcurrentHashMap<>(); + private final ConcurrentMap<DatabaseEntry, Sequence> _cachedSequences = new ConcurrentHashMap<>(); private final Set<String> _permittedNodes = new CopyOnWriteArraySet<String>(); public ReplicatedEnvironmentFacade(ReplicatedEnvironmentConfiguration configuration) diff --git a/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js b/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js index b5e12a664e..d914e16dc9 100644 --- a/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js +++ b/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js @@ -75,7 +75,7 @@ define(["dojo/_base/xhr", if (!success) { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } return success; } diff --git a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java index 67ae9fbce5..3c6cb4270e 100644 --- a/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java +++ b/qpid/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java @@ -26,16 +26,21 @@ import java.io.PrintWriter; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; import javax.tools.Diagnostic; import javax.tools.JavaFileObject; @@ -49,6 +54,9 @@ public class ConfiguredObjectRegistrationGenerator extends AbstractProcessor private Map<String, Set<String>> _managedObjectClasses = new HashMap<>(); + private Map<String, String> _typeMap = new HashMap<>(); + private Map<String, String> _categoryMap = new HashMap<>(); + @Override public SourceVersion getSupportedSourceVersion() { @@ -78,14 +86,31 @@ public class ConfiguredObjectRegistrationGenerator extends AbstractProcessor { PackageElement packageElement = elementUtils.getPackageOf(e); String packageName = packageElement.getQualifiedName().toString(); - + String className = e.getSimpleName().toString(); + for(AnnotationMirror a : e.getAnnotationMirrors()) + { + if(a.getAnnotationType().asElement().equals(annotationElement)) + { + for(Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : a.getElementValues().entrySet()) + { + if(entry.getKey().getSimpleName().toString().equals("type")) + { + _typeMap.put(packageName + "." + className, (String) entry.getValue().getValue()); + processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "looking for " + packageName + "." + className); + _categoryMap.put(packageName + "." + className, getCategory((TypeElement)e)); + break; + } + } + break; + } + } Set<String> classNames = _managedObjectClasses.get(packageName); if (classNames == null) { classNames = new HashSet<>(); _managedObjectClasses.put(packageName, classNames); } - classNames.add(e.getSimpleName().toString()); + classNames.add(className); } } for (Map.Entry<String, Set<String>> entry : _managedObjectClasses.entrySet()) @@ -93,6 +118,8 @@ public class ConfiguredObjectRegistrationGenerator extends AbstractProcessor generateRegistrationFile(entry.getKey(), entry.getValue()); } _managedObjectClasses.clear(); + _typeMap.clear(); + _categoryMap.clear(); } catch (Exception e) { @@ -102,6 +129,63 @@ public class ConfiguredObjectRegistrationGenerator extends AbstractProcessor return false; } + private String getCategory(final TypeElement e) + { + Elements elementUtils = processingEnv.getElementUtils(); + TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_OBJECT_CANONICAL_NAME); + String category = null; + List<? extends AnnotationMirror> annotationMirrors = e.getAnnotationMirrors(); + if(annotationMirrors != null) + { + for (AnnotationMirror a : annotationMirrors) + { + if (a.getAnnotationType().asElement().equals(annotationElement)) + { + category = e.getSimpleName().toString().toLowerCase(); + + for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : a.getElementValues() + .entrySet()) + { + if (entry.getKey().getSimpleName().toString().equals("category")) + { + if (!Boolean.TRUE.equals(entry.getValue().getValue())) + { + category = null; + } + + break; + } + } + break; + } + } + } + + if (category == null) + { + for (TypeMirror interfaceMirror : e.getInterfaces()) + { + category = getCategory((TypeElement) processingEnv.getTypeUtils().asElement(interfaceMirror)); + if (category != null) + { + break; + } + } + } + + if (category == null && e.getSuperclass() != null) + { + TypeElement parent = (TypeElement) processingEnv.getTypeUtils().asElement(e.getSuperclass()); + if(parent != null) + { + category = getCategory(parent); + } + } + + return category; + + } + private void generateRegistrationFile(final String packageName, final Set<String> classNames) { final String className = "ConfiguredObjectRegistrationImpl"; @@ -144,7 +228,21 @@ public class ConfiguredObjectRegistrationGenerator extends AbstractProcessor pw.println(" Set<Class<? extends ConfiguredObject>> implementations = new HashSet<>();"); for(String implementationName : classNames) { - pw.println(" implementations.add("+implementationName+".class);"); + String qualifiedImplementationName = packageName + "." + implementationName; + if(_typeMap.get(qualifiedImplementationName) != null && _categoryMap.get(qualifiedImplementationName) != null) + { + pw.println(" if(!Boolean.getBoolean(\"qpid.type.disabled:" + +_categoryMap.get(qualifiedImplementationName) + +"."+_typeMap.get(qualifiedImplementationName)+"\"))"); + pw.println(" {"); + pw.println(" implementations.add("+implementationName+".class);"); + pw.println(" }"); + + } + else + { + pw.println(" implementations.add(" + implementationName + ".class);"); + } } pw.println(" _implementations = Collections.unmodifiableSet(implementations);"); pw.println(" }"); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java index fc3ec82041..a6fae97aaa 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import org.apache.qpid.server.configuration.BrokerProperties; import org.apache.qpid.server.model.ConfiguredObject; @@ -54,6 +55,7 @@ public class BrokerOptions public static final String DEFAULT_LOG_CONFIG_FILE = "etc/log4j.xml"; public static final String DEFAULT_INITIAL_CONFIG_LOCATION = BrokerOptions.class.getClassLoader().getResource(DEFAULT_INITIAL_CONFIG_NAME).toExternalForm(); + public static final String MANAGEMENT_MODE_USER_NAME = "mm_admin"; private static final int MANAGEMENT_MODE_PASSWORD_LENGTH = 10; @@ -76,6 +78,7 @@ public class BrokerOptions private boolean _skipLoggingConfiguration; private boolean _overwriteConfigurationStore; private Map<String, String> _configProperties = new HashMap<String,String>(); + private String _initialSystemProperties; public Map<String, Object> convertToSystemAttributes() { @@ -304,7 +307,7 @@ public class BrokerOptions */ public Map<String,String> getConfigProperties() { - ConcurrentHashMap<String, String> properties = new ConcurrentHashMap<String,String>(); + ConcurrentMap<String, String> properties = new ConcurrentHashMap<String,String>(); properties.putAll(_configProperties); properties.putIfAbsent(QPID_WORK_DIR, getWorkDir()); @@ -369,4 +372,5 @@ public class BrokerOptions return _configProperties.get(QPID_HOME_DIR); } + } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java index 2a39cfa642..44b76cd5c8 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandler.java @@ -34,6 +34,9 @@ import org.apache.qpid.server.BrokerOptions; import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectAttribute; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; +import org.apache.qpid.server.model.Model; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.State; @@ -44,7 +47,6 @@ import org.apache.qpid.server.store.ConfiguredObjectRecordImpl; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.StoreException; import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler; -import org.apache.qpid.server.util.MapValueConverter; public class ManagementModeStoreHandler implements DurableConfigurationStore { @@ -455,7 +457,13 @@ public class ManagementModeStoreHandler implements DurableConfigurationStore { return null; } - return MapValueConverter.getEnumSetAttribute(Port.PROTOCOLS, attributes, Protocol.class); + Model model = _parent.getModel(); + ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry(); + Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes = + typeRegistry.getAttributeTypes(Port.class); + ConfiguredObjectAttribute protocolsAttribute = attributeTypes.get(Port.PROTOCOLS); + return (Set<Protocol>) protocolsAttribute.convert(object,_parent); + } private ConfiguredObjectRecord createEntryWithState(ConfiguredObjectRecord entry, Object state) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java index e41bb948dc..4472669f4a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -102,7 +103,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> private final CopyOnWriteArrayList<ExchangeImpl.BindingListener> _listeners = new CopyOnWriteArrayList<ExchangeImpl.BindingListener>(); - private final ConcurrentHashMap<BindingIdentifier, BindingImpl> _bindingsMap = new ConcurrentHashMap<BindingIdentifier, BindingImpl>(); + private final ConcurrentMap<BindingIdentifier, BindingImpl> _bindingsMap = new ConcurrentHashMap<BindingIdentifier, BindingImpl>(); private StateChangeListener<BindingImpl, State> _bindingListener; private State _state = State.UNINITIALIZED; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java index 4997095315..66de22ece8 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArraySet; import org.apache.log4j.Logger; @@ -133,7 +134,7 @@ public class DirectExchange extends AbstractExchange<DirectExchange> } } - private final ConcurrentHashMap<String, BindingSet> _bindingsByKey = + private final ConcurrentMap<String, BindingSet> _bindingsByKey = new ConcurrentHashMap<String, BindingSet>(); @ManagedObjectFactoryConstructor diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java index 83c6b9fd00..67bbc26f74 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java @@ -25,6 +25,7 @@ import java.util.LinkedHashSet; import java.util.ListIterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet; @@ -74,7 +75,7 @@ public class HeadersExchange extends AbstractExchange<HeadersExchange> private static final Logger _logger = Logger.getLogger(HeadersExchange.class); - private final ConcurrentHashMap<String, CopyOnWriteArraySet<BindingImpl>> _bindingsByKey = + private final ConcurrentMap<String, CopyOnWriteArraySet<BindingImpl>> _bindingsByKey = new ConcurrentHashMap<String, CopyOnWriteArraySet<BindingImpl>>(); private final CopyOnWriteArrayList<HeadersBinding> _bindingHeaderMatchers = diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/topic/TopicExchangeResult.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/topic/TopicExchangeResult.java index d3a6bd9260..0db3e9b378 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/topic/TopicExchangeResult.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/topic/TopicExchangeResult.java @@ -20,11 +20,6 @@ */ package org.apache.qpid.server.exchange.topic; -import org.apache.qpid.server.binding.BindingImpl; -import org.apache.qpid.server.filter.Filterable; -import org.apache.qpid.server.filter.MessageFilter; -import org.apache.qpid.server.queue.AMQQueue; - import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -32,13 +27,19 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; +import org.apache.qpid.server.binding.BindingImpl; +import org.apache.qpid.server.filter.Filterable; +import org.apache.qpid.server.filter.MessageFilter; +import org.apache.qpid.server.queue.AMQQueue; + public final class TopicExchangeResult implements TopicMatcherResult { private final List<BindingImpl> _bindings = new CopyOnWriteArrayList<BindingImpl>(); private final Map<AMQQueue, Integer> _unfilteredQueues = new ConcurrentHashMap<AMQQueue, Integer>(); - private final ConcurrentHashMap<AMQQueue, Map<MessageFilter,Integer>> _filteredQueues = new ConcurrentHashMap<AMQQueue, Map<MessageFilter, Integer>>(); + private final ConcurrentMap<AMQQueue, Map<MessageFilter,Integer>> _filteredQueues = new ConcurrentHashMap<AMQQueue, Map<MessageFilter, Integer>>(); private volatile ArrayList<AMQQueue> _unfilteredQueueList = new ArrayList<AMQQueue>(0); public void addUnfilteredQueue(AMQQueue queue) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/topic/TopicWordDictionary.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/topic/TopicWordDictionary.java index 24c41ee7da..181f1d32b7 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/topic/TopicWordDictionary.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/topic/TopicWordDictionary.java @@ -21,10 +21,11 @@ package org.apache.qpid.server.exchange.topic; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; public class TopicWordDictionary { - private final ConcurrentHashMap<String,TopicWord> _dictionary = + private final ConcurrentMap<String,TopicWord> _dictionary = new ConcurrentHashMap<String,TopicWord>(); public TopicWordDictionary() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/messages/HighAvailabilityMessages.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/messages/HighAvailabilityMessages.java index b864a8c095..2234ce6b74 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/messages/HighAvailabilityMessages.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/messages/HighAvailabilityMessages.java @@ -144,7 +144,7 @@ public class HighAvailabilityMessages /** * Log a HighAvailability message of the Format: - * <pre>HA-1011 : Minimum group : {0}</pre> + * <pre>HA-1011 : Minimum group size : {0}</pre> * Optional values are contained in [square brackets] and are numbered * sequentially in the method call. * @@ -326,7 +326,7 @@ public class HighAvailabilityMessages /** * Log a HighAvailability message of the Format: - * <pre>HA-1012 : Priority : {0}</pre> + * <pre>HA-1012 : Priority : {0}</pre> * Optional values are contained in [square brackets] and are numbered * sequentially in the method call. * diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/messages/HighAvailability_logmessages.properties b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/messages/HighAvailability_logmessages.properties index 3c5b0d260f..1a6bff5353 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/messages/HighAvailability_logmessages.properties +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/logging/messages/HighAvailability_logmessages.properties @@ -53,10 +53,10 @@ QUORUM_LOST = HA-1009 : Insufficient replicas contactable ROLE_CHANGED = HA-1010 : Role change reported: Node : ''{0}'' ({1}) : from ''{2}'' to ''{3}'' # 0 - new value -QUORUM_OVERRIDE_CHANGED = HA-1011 : Minimum group : {0} +QUORUM_OVERRIDE_CHANGED = HA-1011 : Minimum group size : {0} # 0 - new value -PRIORITY_CHANGED = HA-1012 : Priority : {0} +PRIORITY_CHANGED = HA-1012 : Priority : {0} # 0 - new value DESIGNATED_PRIMARY_CHANGED = HA-1013 : Designated primary : {0} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java index b191db8523..18930d8817 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java @@ -64,6 +64,7 @@ import org.apache.qpid.server.configuration.updater.VoidTask; import org.apache.qpid.server.configuration.updater.VoidTaskWithException; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; +import org.apache.qpid.server.security.encryption.ConfigurationSecretEncrypter; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.util.Action; import org.apache.qpid.server.util.ServerScopedRuntimeException; @@ -89,6 +90,8 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im SECURE_VALUES = Collections.unmodifiableMap(secureValues); } + private ConfigurationSecretEncrypter _encrypter; + private enum DynamicState { UNINIT, OPENED, CLOSED }; private final AtomicReference<DynamicState> _dynamicState = new AtomicReference<>(DynamicState.UNINIT); @@ -201,6 +204,16 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im _automatedFields = model.getTypeRegistry().getAutomatedFields(getClass()); _stateChangeMethods = model.getTypeRegistry().getStateChangeMethods(getClass()); + + for(ConfiguredObject<?> parent : parents.values()) + { + if(parent instanceof AbstractConfiguredObject && ((AbstractConfiguredObject)parent)._encrypter != null) + { + _encrypter = ((AbstractConfiguredObject)parent)._encrypter; + break; + } + } + Object idObj = attributes.get(ID); UUID uuid; @@ -541,6 +554,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im if(skipCheck || _dynamicState.get() != DynamicState.OPENED) { onResolve(); + postResolve(); applyToChildren(new Action<ConfiguredObject<?>>() { @Override @@ -555,6 +569,10 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } } + protected void postResolve() + { + } + protected final void doCreation(final boolean skipCheck) { if(skipCheck || _dynamicState.get() != DynamicState.OPENED) @@ -593,6 +611,11 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im { } + protected void setEncrypter(final ConfigurationSecretEncrypter encrypter) + { + _encrypter = encrypter; + } + protected void onResolve() { Set<ConfiguredObjectAttribute<?,?>> unresolved = new HashSet<>(); @@ -1094,6 +1117,26 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im { value = ((ConfiguredObject)value).getId(); } + if(attr.isSecure() && _encrypter != null && value != null) + { + if(value instanceof Collection || value instanceof Map) + { + ObjectMapper mapper = new ObjectMapper(); + try(StringWriter stringWriter = new StringWriter()) + { + mapper.writeValue(stringWriter, value); + value = _encrypter.encrypt(stringWriter.toString()); + } + catch (IOException e) + { + throw new IllegalConfigurationException("Failure when encrypting a secret value", e); + } + } + else + { + value = _encrypter.encrypt(value.toString()); + } + } attributes.put(attr.getName(), value); } } @@ -1427,6 +1470,27 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im return false; } + @Override + public void decryptSecrets() + { + if(_encrypter != null) + { + for (Map.Entry<String, Object> entry : _attributes.entrySet()) + { + ConfiguredObjectAttribute<X, ?> attr = + (ConfiguredObjectAttribute<X, ?>) _attributeTypes.get(entry.getKey()); + if (attr != null + && attr.isSecure() + && entry.getValue() instanceof String) + { + String decrypt = _encrypter.decrypt((String) entry.getValue()); + entry.setValue(decrypt); + } + + } + } + } + //========================================================================================= static String interpolate(ConfiguredObject<?> object, String value) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java index 1a9390f210..011aaeee23 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java @@ -51,6 +51,7 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL String STORE_VERSION = "storeVersion"; String STORE_PATH = "storePath"; String MODEL_VERSION = "modelVersion"; + String CONFIDENTIAL_CONFIGURATION_ENCRYPTION_PROVIDER = "confidentialConfigurationEncryptionProvider"; String CONNECTION_SESSION_COUNT_LIMIT = "connection.sessionCountLimit"; String CONNECTION_HEART_BEAT_DELAY = "connection.heartBeatDelay"; @@ -139,6 +140,8 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL @ManagedContextDefault(name = MESSAGE_COMPRESSION_THRESHOLD_SIZE) int DEFAULT_MESSAGE_COMPRESSION_THRESHOLD_SIZE = 102400; + @ManagedAttribute + String getConfidentialConfigurationEncryptionProvider(); @DerivedAttribute( persist = true ) String getModelVersion(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java index 2cffea5d73..02c9ccf8e1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java @@ -105,7 +105,7 @@ public final class BrokerModel extends Model addRelationship(Session.class, Publisher.class); _objectFactory = new ConfiguredObjectFactoryImpl(this); - _typeRegistry = new ConfiguredObjectTypeRegistry((new QpidServiceLoader<ConfiguredObjectRegistration>()).instancesOf(ConfiguredObjectRegistration.class), getSupportedCategories()); + _typeRegistry = new ConfiguredObjectTypeRegistry((new QpidServiceLoader()).instancesOf(ConfiguredObjectRegistration.class), getSupportedCategories()); } public final ConfiguredObjectTypeRegistry getTypeRegistry() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java index ac5c75f80f..deda7768f3 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java @@ -253,4 +253,6 @@ public interface ConfiguredObject<X extends ConfiguredObject<X>> Model getModel(); void delete(); + + void decryptSecrets(); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java index 440a790fc8..350e4fcd44 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java @@ -44,8 +44,8 @@ public class ConfiguredObjectFactoryImpl implements ConfiguredObjectFactory public ConfiguredObjectFactoryImpl(Model model) { _model = model; - QpidServiceLoader<ConfiguredObjectTypeFactory> serviceLoader = - new QpidServiceLoader<ConfiguredObjectTypeFactory>(); + QpidServiceLoader serviceLoader = + new QpidServiceLoader(); Iterable<ConfiguredObjectTypeFactory> allFactories = serviceLoader.instancesOf(ConfiguredObjectTypeFactory.class); for (ConfiguredObjectTypeFactory factory : allFactories) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java index af46bae1c4..afa68e23b1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java @@ -47,6 +47,8 @@ import org.apache.qpid.server.logging.messages.BrokerMessages; import org.apache.qpid.server.logging.messages.VirtualHostMessages; import org.apache.qpid.server.model.*; import org.apache.qpid.server.model.port.AbstractPortWithAuthProvider; +import org.apache.qpid.server.plugin.ConfigurationSecretEncrypterFactory; +import org.apache.qpid.server.plugin.PluggableFactoryLoader; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.security.SubjectCreator; import org.apache.qpid.server.security.access.Operation; @@ -94,6 +96,8 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private boolean _statisticsReportingResetEnabled; @ManagedAttributeField private boolean _messageCompressionEnabled; + @ManagedAttributeField + private String _confidentialConfigurationEncryptionProvider; private State _state = State.UNINITIALIZED; @@ -122,6 +126,25 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple _dataReceived = new StatisticsCounter("bytes-received"); } + @Override + protected void postResolve() + { + super.postResolve(); + if(_confidentialConfigurationEncryptionProvider != null) + { + + PluggableFactoryLoader<ConfigurationSecretEncrypterFactory> factoryLoader = + new PluggableFactoryLoader<>(ConfigurationSecretEncrypterFactory.class); + ConfigurationSecretEncrypterFactory factory = factoryLoader.get(_confidentialConfigurationEncryptionProvider); + if(factory == null) + { + throw new IllegalConfigurationException("Unknown Configuration Secret Encryption method " + _confidentialConfigurationEncryptionProvider); + } + setEncrypter(factory.createEncrypter(this)); + } + + } + public void onValidate() { super.onValidate(); @@ -368,6 +391,12 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple } @Override + public String getConfidentialConfigurationEncryptionProvider() + { + return _confidentialConfigurationEncryptionProvider; + } + + @Override public String getModelVersion() { return BrokerModel.MODEL_VERSION; diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java index 6f6d04c335..1fbc0c8bc1 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java @@ -151,8 +151,7 @@ public class AmqpPortImpl extends AbstractPortWithAuthProvider<AmqpPortImpl> imp TransportProvider transportProvider = null; final HashSet<Transport> transportSet = new HashSet<Transport>(transports); - for (TransportProviderFactory tpf : (new QpidServiceLoader<TransportProviderFactory>()).instancesOf( - TransportProviderFactory.class)) + for (TransportProviderFactory tpf : (new QpidServiceLoader()).instancesOf(TransportProviderFactory.class)) { if (tpf.getSupportedTransports().contains(transports)) { @@ -284,7 +283,7 @@ public class AmqpPortImpl extends AbstractPortWithAuthProvider<AmqpPortImpl> imp public static Set<Protocol> getInstalledProtocols() { Set<Protocol> protocols = new HashSet<>(); - for(ProtocolEngineCreator installedEngine : (new QpidServiceLoader<ProtocolEngineCreator>()).instancesOf(ProtocolEngineCreator.class)) + for(ProtocolEngineCreator installedEngine : (new QpidServiceLoader()).instancesOf(ProtocolEngineCreator.class)) { protocols.add(installedEngine.getVersion()); } @@ -343,7 +342,7 @@ public class AmqpPortImpl extends AbstractPortWithAuthProvider<AmqpPortImpl> imp { Set<Set<Transport>> combinations = new HashSet<>(); - for(TransportProviderFactory providerFactory : (new QpidServiceLoader<TransportProviderFactory>()).instancesOf(TransportProviderFactory.class)) + for(TransportProviderFactory providerFactory : (new QpidServiceLoader()).instancesOf(TransportProviderFactory.class)) { combinations.addAll(providerFactory.getSupportedTransports()); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java index 99ec4b79cb..870621f292 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java @@ -24,8 +24,12 @@ import java.util.Map; import java.util.Set; import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectAttribute; import org.apache.qpid.server.model.ConfiguredObjectFactory; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; +import org.apache.qpid.server.model.Model; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Protocol.ProtocolType; @@ -34,7 +38,6 @@ import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory; import org.apache.qpid.server.plugin.PluggableService; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.UnresolvedConfiguredObject; -import org.apache.qpid.server.util.MapValueConverter; @PluggableService public class PortFactory<X extends Port<X>> implements ConfiguredObjectTypeFactory<X> @@ -52,11 +55,14 @@ public class PortFactory<X extends Port<X>> implements ConfiguredObjectTypeFacto { } - private ProtocolType getProtocolType(Map<String, Object> portAttributes) + private ProtocolType getProtocolType(Map<String, Object> portAttributes, Broker<?> broker) { - - Set<Protocol> protocols = MapValueConverter.getEnumSetAttribute(Port.PROTOCOLS, portAttributes, Protocol.class); - + Model model = broker.getModel(); + ConfiguredObjectTypeRegistry typeRegistry = model.getTypeRegistry(); + Map<String, ConfiguredObjectAttribute<?, ?>> attributeTypes = + typeRegistry.getAttributeTypes(Port.class); + ConfiguredObjectAttribute protocolsAttribute = attributeTypes.get(Port.PROTOCOLS); + Set<Protocol> protocols = (Set<Protocol>) protocolsAttribute.convert(portAttributes.get(Port.PROTOCOLS),broker); ProtocolType protocolType = null; if(protocols == null || protocols.isEmpty()) @@ -98,7 +104,7 @@ public class PortFactory<X extends Port<X>> implements ConfiguredObjectTypeFacto final Map<String, Object> attributes, final ConfiguredObject<?>... parents) { - return getPortFactory(factory, attributes).create(factory, attributes,parents); + return getPortFactory(factory, attributes, (Broker<?>)parents[0]).create(factory, attributes,parents); } @Override @@ -106,11 +112,12 @@ public class PortFactory<X extends Port<X>> implements ConfiguredObjectTypeFacto final ConfiguredObjectRecord record, final ConfiguredObject<?>... parents) { - return getPortFactory(factory, record.getAttributes()).recover(factory, record, parents); + return getPortFactory(factory, record.getAttributes(), (Broker<?>)parents[0]).recover(factory, record, parents); } public ConfiguredObjectTypeFactory<X> getPortFactory(final ConfiguredObjectFactory factory, - Map<String, Object> attributes) + Map<String, Object> attributes, + Broker<?> broker) { String type; @@ -120,7 +127,7 @@ public class PortFactory<X extends Port<X>> implements ConfiguredObjectTypeFacto } else { - type = getProtocolType(attributes).name(); + type = getProtocolType(attributes, broker).name(); } return factory.getConfiguredObjectTypeFactory(Port.class.getSimpleName(), type); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationSecretEncrypterFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationSecretEncrypterFactory.java new file mode 100644 index 0000000000..0548e6418a --- /dev/null +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationSecretEncrypterFactory.java @@ -0,0 +1,29 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.plugin; + +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.security.encryption.ConfigurationSecretEncrypter; + +public interface ConfigurationSecretEncrypterFactory extends Pluggable +{ + public ConfigurationSecretEncrypter createEncrypter(ConfiguredObject<?> object); +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java index 14acd59928..6375a03cdf 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java @@ -21,14 +21,9 @@ package org.apache.qpid.server.plugin; import java.sql.SQLException; -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 org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.store.jdbc.ConnectionProvider; public interface JDBCConnectionProviderFactory extends Pluggable @@ -48,7 +43,7 @@ public interface JDBCConnectionProviderFactory extends Pluggable public static JDBCConnectionProviderFactory get(String type) { - QpidServiceLoader<JDBCConnectionProviderFactory> qpidServiceLoader = new QpidServiceLoader<JDBCConnectionProviderFactory>(); + QpidServiceLoader qpidServiceLoader = new QpidServiceLoader(); Iterable<JDBCConnectionProviderFactory> factories = qpidServiceLoader.atLeastOneInstanceOf(JDBCConnectionProviderFactory.class); for(JDBCConnectionProviderFactory factory : factories) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java index 40db520ff1..462f32e636 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java @@ -33,7 +33,7 @@ public class PluggableFactoryLoader<T extends Pluggable> public PluggableFactoryLoader(Class<T> factoryClass) { Map<String, T> fm = new HashMap<String, T>(); - QpidServiceLoader<T> qpidServiceLoader = new QpidServiceLoader<T>(); + QpidServiceLoader qpidServiceLoader = new QpidServiceLoader(); Iterable<T> factories = qpidServiceLoader.atLeastOneInstanceOf(factoryClass); for (T factory : factories) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java index 6920d5a879..9f94e7d09d 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/QpidServiceLoader.java @@ -24,16 +24,17 @@ import java.util.List; import java.util.ServiceLoader; import org.apache.log4j.Logger; + import org.apache.qpid.server.util.ServerScopedRuntimeException; /** * Simple facade over a {@link ServiceLoader} to instantiate all configured implementations of an interface. */ -public class QpidServiceLoader<C extends Pluggable> +public class QpidServiceLoader { private static final Logger _logger = Logger.getLogger(QpidServiceLoader.class); - public Iterable<C> instancesOf(Class<C> clazz) + public <C extends Pluggable> Iterable<C> instancesOf(Class<C> clazz) { return instancesOf(clazz, false); } @@ -41,12 +42,12 @@ public class QpidServiceLoader<C extends Pluggable> /** * @throws RuntimeException if at least one implementation is not found. */ - public Iterable<C> atLeastOneInstanceOf(Class<C> clazz) + public <C extends Pluggable> Iterable<C> atLeastOneInstanceOf(Class<C> clazz) { return instancesOf(clazz, true); } - private Iterable<C> instancesOf(Class<C> clazz, boolean atLeastOne) + private <C extends Pluggable> Iterable<C> instancesOf(Class<C> clazz, boolean atLeastOne) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Iterator<C> serviceLoaderIterator = ServiceLoader.load(clazz, classLoader).iterator(); @@ -55,7 +56,11 @@ public class QpidServiceLoader<C extends Pluggable> List<C> serviceImplementations = new ArrayList<C>(); while(serviceLoaderIterator.hasNext()) { - serviceImplementations.add(serviceLoaderIterator.next()); + C next = serviceLoaderIterator.next(); + if(!isDisabled(clazz, next)) + { + serviceImplementations.add(next); + } } if(atLeastOne && serviceImplementations.isEmpty()) @@ -70,4 +75,16 @@ public class QpidServiceLoader<C extends Pluggable> return serviceImplementations; } + + private <C extends Pluggable> boolean isDisabled(Class<C> clazz, final C next) + { + return Boolean.getBoolean("qpid.plugin.disabled:"+clazz.getSimpleName().toLowerCase()+"."+next.getType()) + || (next instanceof ConfiguredObjectTypeFactory && isDisabledConfiguredType((ConfiguredObjectTypeFactory<?>) next)); + } + + private boolean isDisabledConfiguredType(final ConfiguredObjectTypeFactory<?> typeFactory) + { + return Boolean.getBoolean("qpid.type.disabled:" + typeFactory.getCategoryClass().getSimpleName().toLowerCase() + + "." + typeFactory.getType()); + } } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MessageConverterRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MessageConverterRegistry.java index 81e5af179d..7959c7f6b4 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MessageConverterRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MessageConverterRegistry.java @@ -35,7 +35,7 @@ public class MessageConverterRegistry static { - for(MessageConverter<? extends ServerMessage, ? extends ServerMessage> converter : (new QpidServiceLoader<MessageConverter>()).instancesOf(MessageConverter.class)) + for(MessageConverter<? extends ServerMessage, ? extends ServerMessage> converter : (new QpidServiceLoader()).instancesOf(MessageConverter.class)) { Map<Class<? extends ServerMessage>, MessageConverter> map = _converters.get(converter.getInputClass()); if(map == null) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java index b1c49c6fe5..ac8bdc3fa4 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java @@ -72,7 +72,7 @@ public class MultiVersionProtocolEngineFactory implements ProtocolEngineFactory _supported = supportedVersions; _defaultSupportedReply = defaultSupportedReply; final List<ProtocolEngineCreator> creators = new ArrayList<ProtocolEngineCreator>(); - for(ProtocolEngineCreator c : new QpidServiceLoader<ProtocolEngineCreator>().instancesOf(ProtocolEngineCreator.class)) + for(ProtocolEngineCreator c : new QpidServiceLoader().instancesOf(ProtocolEngineCreator.class)) { creators.add(c); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java index 8220993e03..e1b25e5abb 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AssignedConsumerMessageGroupManager.java @@ -20,11 +20,12 @@ */ package org.apache.qpid.server.queue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AssignedConsumerMessageGroupManager implements MessageGroupManager @@ -33,7 +34,7 @@ public class AssignedConsumerMessageGroupManager implements MessageGroupManager private final String _groupId; - private final ConcurrentHashMap<Integer, QueueConsumer<?>> _groupMap = new ConcurrentHashMap<Integer, QueueConsumer<?>>(); + private final ConcurrentMap<Integer, QueueConsumer<?>> _groupMap = new ConcurrentHashMap<Integer, QueueConsumer<?>>(); private final int _groupMask; public AssignedConsumerMessageGroupManager(final String groupId, final int maxGroups) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueList.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueList.java index 6f1edf12e5..1e250ac2c9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueList.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/LastValueQueueList.java @@ -24,6 +24,7 @@ package org.apache.qpid.server.queue; import java.util.Collections; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicReference; import org.slf4j.Logger; @@ -48,7 +49,7 @@ public class LastValueQueueList extends OrderedQueueEntryList }; private final String _conflationKey; - private final ConcurrentHashMap<Object, AtomicReference<ConflationQueueEntry>> _latestValuesMap = + private final ConcurrentMap<Object, AtomicReference<ConflationQueueEntry>> _latestValuesMap = new ConcurrentHashMap<Object, AtomicReference<ConflationQueueEntry>>(); private final ConflationQueueEntry _deleteInProgress = new ConflationQueueEntry(this); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java index 2f7acba91d..96bd9ee0d6 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/SecurityManager.java @@ -35,6 +35,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.security.auth.Subject; @@ -63,11 +64,11 @@ public class SecurityManager implements ConfigurationChangeListener Collections.emptySet(), Collections.emptySet()); - private final ConcurrentHashMap<String, AccessControl> _plugins = new ConcurrentHashMap<String, AccessControl>(); + private final ConcurrentMap<String, AccessControl> _plugins = new ConcurrentHashMap<String, AccessControl>(); private final boolean _managementMode; private final Broker<?> _broker; - private final ConcurrentHashMap<PublishAccessCheckCacheEntry, PublishAccessCheck> _publishAccessCheckCache = new ConcurrentHashMap<SecurityManager.PublishAccessCheckCacheEntry, SecurityManager.PublishAccessCheck>(); + private final ConcurrentMap<PublishAccessCheckCacheEntry, PublishAccessCheck> _publishAccessCheckCache = new ConcurrentHashMap<SecurityManager.PublishAccessCheckCacheEntry, SecurityManager.PublishAccessCheck>(); public SecurityManager(Broker<?> broker, boolean managementMode) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/AESKeyFileEncrypter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/AESKeyFileEncrypter.java new file mode 100644 index 0000000000..c0c92f0389 --- /dev/null +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/AESKeyFileEncrypter.java @@ -0,0 +1,130 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.security.encryption; + + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; + +import javax.crypto.Cipher; +import javax.crypto.CipherInputStream; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.xml.bind.DatatypeConverter; + +import org.apache.qpid.server.configuration.IllegalConfigurationException; + +class AESKeyFileEncrypter implements ConfigurationSecretEncrypter +{ + private static final String CIPHER_NAME = "AES/CBC/PKCS5Padding"; + private static final int AES_INITIALIZATION_VECTOR_LENGTH = 16; + private final SecretKey _secretKey; + private final SecureRandom _random = new SecureRandom(); + + AESKeyFileEncrypter(SecretKey secretKey) + { + _secretKey = secretKey; + } + + @Override + public String encrypt(final String unencrypted) + { + byte[] unencryptedBytes = unencrypted.getBytes(StandardCharsets.UTF_8); + try + { + byte[] ivbytes = new byte[AES_INITIALIZATION_VECTOR_LENGTH]; + _random.nextBytes(ivbytes); + Cipher cipher = Cipher.getInstance(CIPHER_NAME); + cipher.init(Cipher.ENCRYPT_MODE, _secretKey, new IvParameterSpec(ivbytes)); + byte[] encryptedBytes = readFromCipherStream(unencryptedBytes, cipher); + byte[] output = new byte[AES_INITIALIZATION_VECTOR_LENGTH + encryptedBytes.length]; + System.arraycopy(ivbytes, 0, output, 0, AES_INITIALIZATION_VECTOR_LENGTH); + System.arraycopy(encryptedBytes, 0, output, AES_INITIALIZATION_VECTOR_LENGTH, encryptedBytes.length); + return DatatypeConverter.printBase64Binary(output); + } + catch (IOException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException e) + { + throw new IllegalConfigurationException("Unable to encrypt secret", e); + } + } + + @Override + public String decrypt(final String encrypted) + { + byte[] encryptedBytes = DatatypeConverter.parseBase64Binary(encrypted); + try + { + Cipher cipher = Cipher.getInstance(CIPHER_NAME); + cipher.init(Cipher.DECRYPT_MODE, _secretKey, new IvParameterSpec(encryptedBytes, 0, + AES_INITIALIZATION_VECTOR_LENGTH)); + return new String(readFromCipherStream(encryptedBytes, + AES_INITIALIZATION_VECTOR_LENGTH, + encryptedBytes.length - AES_INITIALIZATION_VECTOR_LENGTH, + cipher), StandardCharsets.UTF_8); + } + catch (IOException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException e) + { + throw new IllegalConfigurationException("Unable to encrypt secret", e); + } + } + + + private byte[] readFromCipherStream(final byte[] unencryptedBytes, final Cipher cipher) throws IOException + { + return readFromCipherStream(unencryptedBytes, 0, unencryptedBytes.length, cipher); + } + + private byte[] readFromCipherStream(final byte[] unencryptedBytes, int offset, int length, final Cipher cipher) + throws IOException + { + final byte[] encryptedBytes; + try (CipherInputStream cipherInputStream = new CipherInputStream(new ByteArrayInputStream(unencryptedBytes, + offset, + length), cipher)) + { + byte[] buf = new byte[1024]; + int pos = 0; + int read; + while ((read = cipherInputStream.read(buf, pos, buf.length - pos)) != -1) + { + pos += read; + if (pos == buf.length - 1) + { + byte[] tmp = buf; + buf = new byte[buf.length + 1024]; + System.arraycopy(tmp, 0, buf, 0, tmp.length); + } + } + encryptedBytes = new byte[pos]; + System.arraycopy(buf, 0, encryptedBytes, 0, pos); + } + return encryptedBytes; + } + + + +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/AESKeyFileEncrypterFactory.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/AESKeyFileEncrypterFactory.java new file mode 100644 index 0000000000..447f19b7ce --- /dev/null +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/AESKeyFileEncrypterFactory.java @@ -0,0 +1,164 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.security.encryption; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; +import java.security.NoSuchAlgorithmException; +import java.util.EnumSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.qpid.server.BrokerOptions; +import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.plugin.ConfigurationSecretEncrypterFactory; +import org.apache.qpid.server.plugin.PluggableService; + +@PluggableService +public class AESKeyFileEncrypterFactory implements ConfigurationSecretEncrypterFactory +{ + private static final String ENCRYPTER_KEY_FILE = "encrypter.key.file"; + + private static final int AES_KEY_SIZE_BITS = 256; + private static final int AES_KEY_SIZE_BYTES = AES_KEY_SIZE_BITS / 8; + private static final String AES_ALGORITHM = "AES"; + + public static String TYPE = "AESKeyFile"; + + @Override + public ConfigurationSecretEncrypter createEncrypter(final ConfiguredObject<?> object) + { + String fileLocation; + if(object.getContextKeys(false).contains(ENCRYPTER_KEY_FILE)) + { + fileLocation = object.getContextValue(String.class, ENCRYPTER_KEY_FILE); + } + else + { + + fileLocation = object.getContextValue(String.class, BrokerOptions.QPID_WORK_DIR) + + File.separator + ".keys" + File.separator + + object.getCategoryClass().getSimpleName() + "_" + + object.getName() + ".key"; + + Map<String, String> context = object.getContext(); + Map<String, String> modifiedContext = new LinkedHashMap<>(context); + modifiedContext.put(ENCRYPTER_KEY_FILE, fileLocation); + + object.setAttribute(ConfiguredObject.CONTEXT, context, modifiedContext); + } + File file = new File(fileLocation); + if(!file.exists()) + { + createAndPopulateKeyFile(file); + } + if(!file.isFile()) + { + throw new IllegalArgumentException("File '"+fileLocation+"' is not a regular file."); + } + try + { + Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(file.toPath()); + + if (permissions.contains(PosixFilePermission.GROUP_READ) + || permissions.contains(PosixFilePermission.OTHERS_READ) + || permissions.contains(PosixFilePermission.GROUP_WRITE) + || permissions.contains(PosixFilePermission.OTHERS_WRITE)) + { + throw new IllegalStateException("Key file '" + + fileLocation + + "' has incorrect permissions. Only the owner " + + "should be able to read or write this file."); + } + if(Files.size(file.toPath()) != AES_KEY_SIZE_BYTES) + { + throw new IllegalConfigurationException("Key file '" + fileLocation + "' contains an incorrect about of data"); + } + + try(FileInputStream inputStream = new FileInputStream(file)) + { + byte[] key = new byte[AES_KEY_SIZE_BYTES]; + int pos = 0; + int read; + while(pos < key.length && -1 != ( read = inputStream.read(key, pos, key.length - pos))) + { + pos += read; + } + if(pos != key.length) + { + throw new IllegalConfigurationException("Key file '" + fileLocation + "' contained an incorrect about of data"); + } + SecretKeySpec keySpec = new SecretKeySpec(key, AES_ALGORITHM); + return new AESKeyFileEncrypter(keySpec); + } + } + catch (IOException e) + { + throw new IllegalConfigurationException("Unable to get file permissions: " + e.getMessage(), e); + } + } + + private void createAndPopulateKeyFile(final File file) + { + try + { + Set<PosixFilePermission> ownerOnly = EnumSet.of(PosixFilePermission.OWNER_READ, + PosixFilePermission.OWNER_WRITE, + PosixFilePermission.OWNER_EXECUTE); + Files.createDirectories(file.getParentFile().toPath(), PosixFilePermissions.asFileAttribute(ownerOnly)); + + Files.createFile(file.toPath(), PosixFilePermissions.asFileAttribute( + EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE))); + + KeyGenerator keyGenerator = KeyGenerator.getInstance(AES_ALGORITHM); + keyGenerator.init(AES_KEY_SIZE_BITS); + SecretKey key = keyGenerator.generateKey(); + try(FileOutputStream os = new FileOutputStream(file)) + { + os.write(key.getEncoded()); + } + + Files.setPosixFilePermissions(file.toPath(), EnumSet.of(PosixFilePermission.OWNER_READ)); + } + catch (NoSuchAlgorithmException | IOException e) + { + throw new IllegalConfigurationException("Cannot create key file: " + e.getMessage(), e); + } + + } + + @Override + public String getType() + { + return TYPE; + } +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/ConfigurationSecretEncrypter.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/ConfigurationSecretEncrypter.java new file mode 100644 index 0000000000..d8c64c789c --- /dev/null +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/encryption/ConfigurationSecretEncrypter.java @@ -0,0 +1,28 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.security.encryption; + +public interface ConfigurationSecretEncrypter +{ + String encrypt(String unencrypted); + + String decrypt(String encrypted); +} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryStore.java index 4d5cb84d04..a9af138a02 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryStore.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler; @@ -34,7 +35,7 @@ public abstract class AbstractMemoryStore implements DurableConfigurationStore, private final Class<? extends ConfiguredObject> _rootClass; - private final ConcurrentHashMap<UUID, ConfiguredObjectRecord> _configuredObjectRecords = new ConcurrentHashMap<UUID, ConfiguredObjectRecord>(); + private final ConcurrentMap<UUID, ConfiguredObjectRecord> _configuredObjectRecords = new ConcurrentHashMap<UUID, ConfiguredObjectRecord>(); protected AbstractMemoryStore(final Class<? extends ConfiguredObject> rootClass) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/GenericRecoverer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/GenericRecoverer.java index 58fa852849..9edc5fd30a 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/GenericRecoverer.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/GenericRecoverer.java @@ -170,6 +170,7 @@ public class GenericRecoverer { updatesMade = true; ConfiguredObject<?> resolved = recovered.resolve(); + resolved.decryptSecrets(); resolvedObjects.put(resolved.getId(), resolved); } else diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java index f3b2cac52e..9c0a5118ff 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong; import org.apache.qpid.server.message.EnqueueableMessage; @@ -41,7 +42,7 @@ public class MemoryMessageStore implements MessageStore private final AtomicLong _messageId = new AtomicLong(1); - private final ConcurrentHashMap<Long, StoredMemoryMessage> _messages = new ConcurrentHashMap<Long, StoredMemoryMessage>(); + private final ConcurrentMap<Long, StoredMemoryMessage> _messages = new ConcurrentHashMap<Long, StoredMemoryMessage>(); private final Object _transactionLock = new Object(); private final Map<UUID, Set<Long>> _messageInstances = new HashMap<UUID, Set<Long>>(); private final Map<Xid, DistributedTransactionRecords> _distributedTransactions = new HashMap<Xid, DistributedTransactionRecords>(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageMetaDataTypeRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageMetaDataTypeRegistry.java index 64f3ab15ee..940abf42f4 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageMetaDataTypeRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/MessageMetaDataTypeRegistry.java @@ -32,7 +32,7 @@ public class MessageMetaDataTypeRegistry int maxOrdinal = -1; Iterable<MessageMetaDataType> messageMetaDataTypes = - new QpidServiceLoader<MessageMetaDataType>().atLeastOneInstanceOf(MessageMetaDataType.class); + new QpidServiceLoader().atLeastOneInstanceOf(MessageMetaDataType.class); for(MessageMetaDataType type : messageMetaDataTypes) { @@ -42,7 +42,7 @@ public class MessageMetaDataTypeRegistry } } values = new MessageMetaDataType[maxOrdinal+1]; - for(MessageMetaDataType type : new QpidServiceLoader<MessageMetaDataType>().instancesOf(MessageMetaDataType.class)) + for(MessageMetaDataType type : new QpidServiceLoader().instancesOf(MessageMetaDataType.class)) { if(values[type.ordinal()] != null) { diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java index b72d44debf..450fc30bf2 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java @@ -272,7 +272,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte private void registerSystemNodes() { - QpidServiceLoader<SystemNodeCreator> qpidServiceLoader = new QpidServiceLoader<SystemNodeCreator>(); + QpidServiceLoader qpidServiceLoader = new QpidServiceLoader(); Iterable<SystemNodeCreator> factories = qpidServiceLoader.instancesOf(SystemNodeCreator.class); for(SystemNodeCreator creator : factories) { diff --git a/qpid/java/broker-core/src/main/resources/system.properties b/qpid/java/broker-core/src/main/resources/system.properties new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/qpid/java/broker-core/src/main/resources/system.properties diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java index 95c53c8428..28d22a5a44 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor; import org.apache.qpid.server.logging.EventLogger; @@ -155,7 +156,7 @@ public class StandardQueueEntryListTest extends QueueEntryListTestBase public void testScavenge() throws Exception { OrderedQueueEntryList sqel = new StandardQueueEntryList(null); - ConcurrentHashMap<Integer,QueueEntry> entriesMap = new ConcurrentHashMap<Integer,QueueEntry>(); + ConcurrentMap<Integer,QueueEntry> entriesMap = new ConcurrentHashMap<Integer,QueueEntry>(); //Add messages to generate QueueEntry's diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ExplicitAcceptDispositionChangeListener.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ExplicitAcceptDispositionChangeListener.java index 94f04bbae3..95dba11ea0 100755 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ExplicitAcceptDispositionChangeListener.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ExplicitAcceptDispositionChangeListener.java @@ -47,7 +47,7 @@ class ExplicitAcceptDispositionChangeListener implements ServerSession.MessageDi } else { - _logger.info("MessageAccept received for message which is not been acquired - message may have expired or been removed"); + _logger.debug("MessageAccept received for message which is not been acquired - message may have expired or been removed"); } } @@ -60,7 +60,7 @@ class ExplicitAcceptDispositionChangeListener implements ServerSession.MessageDi } else { - _logger.warn("MessageRelease received for message which has not been acquired - message may have expired or been removed"); + _logger.debug("MessageRelease received for message which has not been acquired - message may have expired or been removed"); } } @@ -72,7 +72,7 @@ class ExplicitAcceptDispositionChangeListener implements ServerSession.MessageDi } else { - _logger.warn("MessageReject received for message which has not been acquired - message may have expired or been removed"); + _logger.debug("MessageReject received for message which has not been acquired - message may have expired or been removed"); } } diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java index a8fc5387b4..deaa3ef50b 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import org.apache.log4j.Logger; @@ -92,7 +93,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS private final Map<Binary, MessageInstance> _unsettledMap = new HashMap<Binary, MessageInstance>(); - private final ConcurrentHashMap<Binary, UnsettledAction> _unsettledActionMap = + private final ConcurrentMap<Binary, UnsettledAction> _unsettledActionMap = new ConcurrentHashMap<Binary, UnsettledAction>(); private volatile SendingLinkAttachment _linkAttachment; private TerminusDurability _durability; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/PluginClassProviderAction.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/PluginClassProviderAction.java index 1f6e26106f..cd14abc582 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/PluginClassProviderAction.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/PluginClassProviderAction.java @@ -19,12 +19,11 @@ package org.apache.qpid.server.management.plugin.servlet.rest;/* * */ -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; + import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.plugin.Pluggable; import org.apache.qpid.server.plugin.QpidServiceLoader; @@ -43,7 +42,7 @@ public class PluginClassProviderAction implements Action try { String className = (String) request.get("plugin"); - QpidServiceLoader<Pluggable> serviceLoader = new QpidServiceLoader<Pluggable>(); + QpidServiceLoader serviceLoader = new QpidServiceLoader(); final Class<Pluggable> clazz = (Class<Pluggable>) Class.forName("org.apache.qpid.server.plugin."+className); List<String> values = new ArrayList<String>(); for(Pluggable instance : serviceLoader.instancesOf(clazz)) diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java index d96802cc8b..171c0d1e1c 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java @@ -17,6 +17,7 @@ package org.apache.qpid.server.management.plugin.servlet.rest; import java.io.IOException; +import java.io.PrintWriter; import java.io.Writer; import java.security.AccessControlException; import java.util.ArrayList; @@ -564,9 +565,15 @@ public class RestServlet extends AbstractServlet else { LOGGER.warn("Caught exception", e); - - // TODO response.setStatus(HttpServletResponse.SC_CONFLICT); + + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + PrintWriter out = response.getWriter(); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); + mapper.writeValue(out, Collections.singletonMap("errorMessage", e.getMessage())); + } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css b/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css index f49451b5d8..b6e67ddb4e 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css @@ -245,6 +245,21 @@ div .messages { margin: 0px 0px 10px 5px; } +#errorDialog { + overflow: auto; + width: 400px; +} + +.errorDialogErrorPrimary { + font-weight: bold; + margin-bottom: 10px; + max-width: 350px; +} + +.errorDialogErrorSecondary { + font-style: italic; +} + /* Required to keep queue type radio buttons on one line when dialog adds scrollbar */ #addQueue { max-height: 350px; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html index dfbec13320..3c0cb9a5f6 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html @@ -108,17 +108,24 @@ </div> <div class="dijitHidden"> - <div data-dojo-type="dijit.Dialog" data-dojo-props="title: 'Connection Error'" id="errorDialog"> - <div style="width:400px; overflow: auto"> - <div><strong><span id="errorMessage">An error occurred when communicating with the broker.</span></strong></div> - <div><span id="statusMessage"></span></div> - <div style="margin-top: 10px; margin-bottom: 8px"><span id="reloadMessage">Please try to reload.</span></div> - <div id="errorDetails" data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Details', open:false"> - <span id="errorDetailsMessage"></span> + <div data-dojo-type="dijit.Dialog" data-dojo-props="title: 'Error'" id="errorDialog"> + <div> + <div class="errorDialogErrorPrimary"> + <span id="errorDialog.statusCode">000</span> - <span id="errorDialog.errorMessage">error</span> + </div> + + <div class="clear" class="errorDialogErrorSecondary"> + <div id="errorDialog.advice.reconnect"> + Please login again and retry your operation. + </div> + <div id="errorDialog.advice.retry"> + Please correct the problem and retry your operation. + </div> </div> </div> <div class="dijitDialogPaneActionBar"> - <input type="button" value="Close" label="Close" dojoType="dijit.form.Button" onClick="dijit.byId('errorDialog').hide();"/> + <input type="button" id="errorDialog.button.cancel" value="Cancel" label="Cancel" dojoType="dijit.form.Button" onClick="dijit.byId('errorDialog').hide();"/> + <input type="button" id="errorDialog.button.relogin" value="Login" label="Login" dojoType="dijit.form.Button" onClick="dijit.byId('errorDialog').hide(); document.location.href = '/';"/> </div> </div> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js index 9e433bbb34..441d6776e7 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js @@ -25,6 +25,7 @@ define(["dojo/_base/xhr", "dojo/json", "dojo/dom-construct", "dojo/dom-geometry", + "dojo/dom-style", "dojo/window", "dojo/query", "dojo/parser", @@ -47,7 +48,7 @@ define(["dojo/_base/xhr", "dojox/validate/web", "dojo/domReady!" ], - function (xhr, array, event, lang, json, dom, geometry, win, query, parser, Memory, entities, metadata, widgetconfigurer, registry) { + function (xhr, array, event, lang, json, dom, geometry, domStyle, win, query, parser, Memory, entities, metadata, widgetconfigurer, registry) { var util = {}; if (Array.isArray) { util.isArray = function (object) { @@ -140,7 +141,7 @@ define(["dojo/_base/xhr", function(error) {success = false; failureReason = error;}); if(!success ) { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } } } @@ -286,7 +287,8 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); + } return false; } @@ -331,36 +333,63 @@ define(["dojo/_base/xhr", util.xhrErrorHandler = function(error) { + const fallback = "Unexpected error - see server logs"; + var statusCodeNode = dojo.byId("errorDialog.statusCode"); + var errorMessageNode = dojo.byId("errorDialog.errorMessage"); + var userMustReauth = false; + if (error) { if (error.hasOwnProperty("status")) { + var hasMessage = error.hasOwnProperty("message"); + var message; + if (error.status == 401) { - dojo.byId("statusMessage").innerHTML = "401 - Authentication required."; + message = hasMessage ? error.message : "Authentication required"; + userMustReauth = true; } else if (error.status == 403) { - dojo.byId("statusMessage").innerHTML = "403 - Access denied."; + message = hasMessage ? error.message : "Forbidden"; + userMustReauth = true; } else { - dojo.byId("statusMessage").innerHTML = "HTTP status code: " + error.status; + message = hasMessage ? error.message : fallback; + + // Try for a more detail error sent by the Broker as json + if (error.hasOwnProperty("responseText")) + { + try + { + var errorObj = json.parse(error.responseText); + message = errorObj.hasOwnProperty("errorMessage") ? errorObj.errorMessage : errorMessageNode; + } + catch (e) + { + // Ignore + } + } } + + errorMessageNode.innerHTML = entities.encode(message ? message : fallback); + statusCodeNode.innerHTML = entities.encode(String(error.status)); + + dojo.byId("errorDialog.advice.retry").style.display = userMustReauth ? "none" : "block"; + dojo.byId("errorDialog.advice.reconnect").style.display = userMustReauth ? "block" : "none"; + + domStyle.set(registry.byId("errorDialog.button.cancel").domNode, 'display', userMustReauth ? "none" : "block"); + domStyle.set(registry.byId("errorDialog.button.relogin").domNode, 'display', userMustReauth ? "block" : "none"); + } else { - dojo.byId("statusMessage").innerHTML = ""; - } - if (error.hasOwnProperty("message")) - { - dojo.byId("errorDetailsMessage").innerHTML = error.message; - dojo.byId("errorDetails").style.display = "block"; - } - else - { - dojo.byId("errorDetails").style.display = "none"; + statusCodeNode.innerHTML = ""; + errorMessageNode.innerHTML = fallback; } + var dialog = dijit.byId("errorDialog"); if (!dialog.open) { @@ -412,7 +441,7 @@ define(["dojo/_base/xhr", if (syncRequired && !success) { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } return success; } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js index adc066c270..1d4cc1447b 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js @@ -87,7 +87,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js index c3e567e902..34e3516180 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js @@ -112,7 +112,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js index 80116d3141..cfa985f551 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js @@ -288,7 +288,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js index 74f7209d9d..09473524b5 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js @@ -93,7 +93,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js index 9f0ba9c16e..ebec5bc47f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js @@ -153,7 +153,7 @@ define(["dojo/dom", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js index ebcee4afa2..250b85b59f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js @@ -93,7 +93,7 @@ define(["dojo/dom", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js index 48feccbced..d7b028f1a5 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js @@ -103,7 +103,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js index 1fa1d603de..afd05aeda3 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js @@ -182,7 +182,7 @@ define(["dojo/_base/xhr", headers: { "Content-Type": "application/json"}, putData: json.stringify(data), load: function(x) {success = true;}, - error: function(error) {success = false; alert("Preferences Provider Error: " + error);}}); + error: function(error) {success = false; util.xhrErrorHandler(error);}}); } return success; }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js index 59e49f3302..b4ef7b4403 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js @@ -547,7 +547,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js index dfe276cae2..000a487b13 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js @@ -154,7 +154,7 @@ define(["dojo/dom", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js index 30bd4c22d0..c59e86aaa1 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js @@ -194,7 +194,7 @@ define(["dojo/_base/xhr", } else { - alert("Authentication Provider Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; }else{ diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js index ac4937da68..56950c88b0 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js @@ -28,6 +28,7 @@ define(["dojo/_base/connect", "dojo/_base/declare", "dojo/store/Memory", "dijit/form/FilteringSelect", + "qpid/common/util", "dijit/form/NumberSpinner", // required by the form /* dojox/ validate resources */ "dojox/validate/us", "dojox/validate/web", @@ -44,7 +45,7 @@ define(["dojo/_base/connect", "dojox/grid/EnhancedGrid", "dojo/data/ObjectStore", "dojo/domReady!"], - function (connect, xhr, dom, construct, win, registry, parser, array, event, json, lang, declare, Memory, FilteringSelect) { + function (connect, xhr, dom, construct, win, registry, parser, array, event, json, lang, declare, Memory, FilteringSelect, util) { var noLocalValues = new Memory({ data: [ @@ -325,7 +326,7 @@ define(["dojo/_base/connect", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js index 65c9a9f6f6..c7f281b8dc 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js @@ -26,7 +26,8 @@ define(["dojo/_base/xhr", "dojo/parser", "dojo/_base/array", "dojo/_base/event", - 'dojo/_base/json', + "dojo/_base/json", + "qpid/common/util", "dijit/form/NumberSpinner", // required by the form /* dojox/ validate resources */ "dojox/validate/us", "dojox/validate/web", @@ -41,7 +42,7 @@ define(["dojo/_base/xhr", /* basic dojox classes */ "dojox/form/BusyButton", "dojox/form/CheckedMultiSelect", "dojo/domReady!"], - function (xhr, dom, construct, win, registry, parser, array, event, json) { + function (xhr, dom, construct, win, registry, parser, array, event, json, util) { var addExchange = {}; @@ -123,7 +124,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js index 0c8a4660fd..4a635b1c0d 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js @@ -321,7 +321,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js index c66b99ee4c..444ed67d63 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js @@ -178,7 +178,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js index ede0c4bc48..02eb8cd2b6 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js @@ -255,8 +255,7 @@ define(["dojo/_base/xhr", } else { - // What if VHN creation was successful but VH was not - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } } else diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager.js index c5875d59ea..96083843fa 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager.js @@ -146,7 +146,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!that.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } @@ -210,7 +210,7 @@ define(["dojo/_base/xhr", if(that.success === true) { registry.byId("addUser").hide(); } else { - alert("Error:" + that.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; @@ -267,7 +267,7 @@ define(["dojo/_base/xhr", if(that.success === true) { registry.byId("setPassword").hide(); } else { - alert("Error:" + that.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js index a959586655..f25be2d57e 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js @@ -130,7 +130,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } } else diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js index 3c78eaa29c..545be75fff 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js @@ -121,7 +121,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } } else diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js index 485502e81c..8f63a8c935 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js @@ -195,7 +195,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/addGroupMember.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/addGroupMember.js index d965fd35a8..0a8e6a2e11 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/addGroupMember.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/addGroupMember.js @@ -26,7 +26,8 @@ define(["dojo/_base/xhr", "dojo/parser", "dojo/_base/array", "dojo/_base/event", - 'dojo/_base/json', + "dojo/_base/json", + "qpid/common/util", "dijit/form/NumberSpinner", // required by the form /* dojox/ validate resources */ "dojox/validate/us", "dojox/validate/web", @@ -41,7 +42,7 @@ define(["dojo/_base/xhr", /* basic dojox classes */ "dojox/form/BusyButton", "dojox/form/CheckedMultiSelect", "dojo/domReady!"], - function (xhr, dom, construct, win, registry, parser, array, event, json) { + function (xhr, dom, construct, win, registry, parser, array, event, json, util) { var addGroupMember = {}; @@ -83,7 +84,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js index c8f991260c..4ee411633f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js @@ -163,7 +163,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!that.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } @@ -238,7 +238,7 @@ define(["dojo/_base/xhr", if(that.success === true) { registry.byId("addGroup").hide(); } else { - alert("Error:" + that.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java index 61061e6209..ead6ba6865 100644 --- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java +++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java @@ -90,7 +90,7 @@ public class JMXManagementPluginImpl _changeListener = new ChangeListener(); _pluginMBeanProvider = new PluginMBeansProvider(); _mBeanProviders = new HashSet<MBeanProvider>(); - QpidServiceLoader<MBeanProvider> qpidServiceLoader = new QpidServiceLoader<MBeanProvider>(); + QpidServiceLoader qpidServiceLoader = new QpidServiceLoader(); for (MBeanProvider provider : qpidServiceLoader.instancesOf(MBeanProvider.class)) { _mBeanProviders.add(provider); diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java index 72550128b7..43b0f9da67 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java @@ -25,6 +25,9 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.HelpFormatter; @@ -94,6 +97,9 @@ public class Main private static final Option OPTION_MM_PASSWORD = OptionBuilder.withArgName("password").hasArg() .withDescription("Set the password for the management mode user " + BrokerOptions.MANAGEMENT_MODE_USER_NAME).withLongOpt("management-mode-password").create("mmpass"); + private static final Option OPTION_INITIAL_SYSTEM_PROPERTIES = OptionBuilder.withArgName("path").hasArg() + .withDescription("set the location of initial properties file to set otherwise unset system properties").withLongOpt("system-properties-file").create("props"); + private static final Options OPTIONS = new Options(); static @@ -114,6 +120,7 @@ public class Main OPTIONS.addOption(OPTION_MM_HTTP_PORT); OPTIONS.addOption(OPTION_MM_PASSWORD); OPTIONS.addOption(OPTION_CONFIGURATION_PROPERTY); + OPTIONS.addOption(OPTION_INITIAL_SYSTEM_PROPERTIES); } protected CommandLine _commandLine; @@ -168,7 +175,11 @@ public class Main protected void execute() throws Exception { + String initialProperties = _commandLine.getOptionValue(OPTION_INITIAL_SYSTEM_PROPERTIES.getOpt()); + populateSystemPropertiesFromDefaults(initialProperties); + BrokerOptions options = new BrokerOptions(); + String initialConfigLocation = _commandLine.getOptionValue(OPTION_INITIAL_CONFIGURATION_PATH.getOpt()); if (initialConfigLocation != null) { @@ -304,6 +315,28 @@ public class Main } } + private void populateSystemPropertiesFromDefaults(final String initialProperties) throws IOException + { + URL initialPropertiesLocation; + if(initialProperties == null) + { + initialPropertiesLocation = getClass().getClassLoader().getResource("system.properties"); + } + else + { + initialPropertiesLocation = (new File(initialProperties)).toURI().toURL(); + } + + Properties props = new Properties(); + props.load(initialPropertiesLocation.openStream()); + Set<String> propertyNames = new HashSet<>(props.stringPropertyNames()); + propertyNames.removeAll(System.getProperties().stringPropertyNames()); + for(String propName : propertyNames) + { + System.setProperty(propName, props.getProperty(propName)); + } + } + private void copyInitialConfigFile(final BrokerOptions options, final File destinationFile) { String initialConfigLocation = options.getInitialConfigurationLocation(); diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java index 35252204ac..c2659194e2 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; @@ -157,10 +158,10 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic /** Used to indicate that this session has been started at least once. */ private AtomicBoolean _startedAtLeastOnce = new AtomicBoolean(false); - private final ConcurrentHashMap<String, TopicSubscriberAdaptor<C>> _subscriptions = + private final ConcurrentMap<String, TopicSubscriberAdaptor<C>> _subscriptions = new ConcurrentHashMap<String, TopicSubscriberAdaptor<C>>(); - private final ConcurrentHashMap<C, String> _reverseSubscriptionMap = new ConcurrentHashMap<C, String>(); + private final ConcurrentMap<C, String> _reverseSubscriptionMap = new ConcurrentHashMap<C, String>(); private final Lock _subscriberDetails = new ReentrantLock(true); private final Lock _subscriberAccess = new ReentrantLock(true); @@ -200,7 +201,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic private CopyOnWriteArrayList<C> _removedConsumers = new CopyOnWriteArrayList<C>(); /** Provides a count of consumers on destinations, in order to be able to know if a destination has consumers. */ - private ConcurrentHashMap<Destination, AtomicInteger> _destinationConsumerCount = + private ConcurrentMap<Destination, AtomicInteger> _destinationConsumerCount = new ConcurrentHashMap<Destination, AtomicInteger>(); /** @@ -312,7 +313,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic public static final class IdToConsumerMap<C extends BasicMessageConsumer> { private final BasicMessageConsumer[] _fastAccessConsumers = new BasicMessageConsumer[16]; - private final ConcurrentHashMap<Integer, C> _slowAccessConsumers = new ConcurrentHashMap<Integer, C>(); + private final ConcurrentMap<Integer, C> _slowAccessConsumers = new ConcurrentHashMap<Integer, C>(); public C get(int id) { diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java index a06fa2d15b..17735f5c9c 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java @@ -21,15 +21,16 @@ package org.apache.qpid.framing; -import java.util.concurrent.ConcurrentHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A short string is a representation of an AMQ Short String @@ -97,7 +98,7 @@ public final class AMQShortString implements CharSequence, Comparable<AMQShortSt return new AMQShortString(_data, from+_offset, to-from); } - private static final ConcurrentHashMap<AMQShortString, AMQShortString> _globalInternMap = + private static final ConcurrentMap<AMQShortString, AMQShortString> _globalInternMap = new ConcurrentHashMap<AMQShortString, AMQShortString>(); private static final Logger _logger = LoggerFactory.getLogger(AMQShortString.class); diff --git a/qpid/java/pom.xml b/qpid/java/pom.xml index 1be2ce0f95..cf8d553f3f 100644 --- a/qpid/java/pom.xml +++ b/qpid/java/pom.xml @@ -65,7 +65,7 @@ <profile.test.excludes>Excludes JavaExcludes ${profile}.excludes ${profile.specific.excludes}</profile.test.excludes> <profile.specific.excludes>JavaTransientExcludes Java010Excludes</profile.specific.excludes> <profile.broker.version>v0_10</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"]</profile.test.amqp_port_protocols> <profile.broker.persistent>false</profile.broker.persistent> <profile.virtualhostnode.type>Memory</profile.virtualhostnode.type> <profile.broker.clean.between.tests>true</profile.broker.clean.between.tests> @@ -174,7 +174,7 @@ <echo>[profile.specific.excludes] ${profile.specific.excludes}</echo> <echo>[profile.test.excludes] ${profile.test.excludes}</echo> <echo>[profile.broker.version] ${profile.broker.version}</echo> - <echo>[profile.qpid.broker_default_amqp_protocol_excludes] ${profile.qpid.broker_default_amqp_protocol_excludes}</echo> + <echo>[profile.test.amqp_port_protocols] ${profile.test.amqp_port_protocols}</echo> <echo>[profile.broker.persistent] ${profile.broker.persistent}</echo> <echo>[profile.virtualhostnode.type] ${profile.virtualhostnode.type}</echo> <echo>[profile.virtualhostnode.context.blueprint] ${profile.virtualhostnode.context.blueprint}</echo> @@ -241,7 +241,7 @@ <broker.command.windows>${profile.broker.command.windows}</broker.command.windows> <test.excludes>${profile.test.excludes}</test.excludes> <broker.version>${profile.broker.version}</broker.version> - <qpid.broker_default_amqp_protocol_excludes>${profile.qpid.broker_default_amqp_protocol_excludes}</qpid.broker_default_amqp_protocol_excludes> + <test.amqp_port_protocols>${profile.test.amqp_port_protocols}</test.amqp_port_protocols> <broker.persistent>${profile.broker.persistent}</broker.persistent> <virtualhostnode.type>${profile.virtualhostnode.type}</virtualhostnode.type> <virtualhostnode.context.blueprint>${profile.virtualhostnode.context.blueprint}</virtualhostnode.context.blueprint> @@ -400,7 +400,7 @@ <profile>java-mms.0-10</profile> <profile.specific.excludes>JavaTransientExcludes Java010Excludes</profile.specific.excludes> <profile.broker.version>v0_10</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"]</profile.test.amqp_port_protocols> <profile.broker.persistent>false</profile.broker.persistent> <profile.virtualhostnode.type>Memory</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -419,7 +419,7 @@ <profile>java-mms.0-9-1</profile> <profile.specific.excludes>JavaTransientExcludes XAExcludes JavaPre010Excludes</profile.specific.excludes> <profile.broker.version>v0_9_1</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"]</profile.test.amqp_port_protocols> <profile.broker.persistent>false</profile.broker.persistent> <profile.virtualhostnode.type>Memory</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -438,7 +438,7 @@ <profile>java-mms.0-9</profile> <profile.specific.excludes>JavaTransientExcludes XAExcludes JavaPre010Excludes</profile.specific.excludes> <profile.broker.version>v0_9</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10,AMQP_0_9_1</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9"]</profile.test.amqp_port_protocols> <profile.broker.persistent>false</profile.broker.persistent> <profile.virtualhostnode.type>Memory</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -457,7 +457,7 @@ <profile>java-bdb.0-10</profile> <profile.specific.excludes>JavaPersistentExcludes Java010Excludes JavaBDBExcludes</profile.specific.excludes> <profile.broker.version>v0_10</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>BDB</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -476,7 +476,7 @@ <profile>java-bdb.0-9-1</profile> <profile.specific.excludes>JavaPersistentExcludes XAExcludes JavaPre010Excludes JavaBDBExcludes</profile.specific.excludes> <profile.broker.version>v0_9_1</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>BDB</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -495,7 +495,7 @@ <profile>java-bdb.0-9</profile> <profile.specific.excludes>JavaPersistentExcludes XAExcludes JavaPre010Excludes JavaBDBExcludes</profile.specific.excludes> <profile.broker.version>v0_9</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10,AMQP_0_9_1</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>BDB</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -514,7 +514,7 @@ <profile>java-dby-mem.0-10</profile> <profile.specific.excludes>JavaPersistentExcludes JavaDerbyExcludes Java010Excludes</profile.specific.excludes> <profile.broker.version>v0_10</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>DERBY</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -533,7 +533,7 @@ <profile>java-dby-mem.0-9-1</profile> <profile.specific.excludes>JavaPersistentExcludes JavaDerbyExcludes XAExcludes JavaPre010Excludes</profile.specific.excludes> <profile.broker.version>v0_9_1</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>DERBY</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -552,7 +552,7 @@ <profile>java-dby-mem.0-9</profile> <profile.specific.excludes>JavaPersistentExcludes JavaDerbyExcludes XAExcludes JavaPre010Excludes</profile.specific.excludes> <profile.broker.version>v0_9</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10,AMQP_0_9_1</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>DERBY</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -571,7 +571,7 @@ <profile>java-dby.0-10</profile> <profile.specific.excludes>JavaPersistentExcludes JavaDerbyExcludes Java010Excludes</profile.specific.excludes> <profile.broker.version>v0_10</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>DERBY</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -590,7 +590,7 @@ <profile>java-dby.0-9-1</profile> <profile.specific.excludes>JavaPersistentExcludes JavaDerbyExcludes XAExcludes JavaPre010Excludes</profile.specific.excludes> <profile.broker.version>v0_9_1</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>DERBY</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -609,7 +609,7 @@ <profile>java-dby.0-9</profile> <profile.specific.excludes>JavaPersistentExcludes JavaDerbyExcludes XAExcludes JavaPre010Excludes</profile.specific.excludes> <profile.broker.version>v0_9</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10,AMQP_0_9_1</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>DERBY</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"ProvidedStore"}</profile.virtualhostnode.context.blueprint> @@ -633,7 +633,7 @@ <profile>java-json.0-9-1</profile> <profile.specific.excludes>JavaPersistentExcludes JavaJsonExcludes XAExcludes JavaPre010Excludes</profile.specific.excludes> <profile.broker.version>v0_9_1</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0,AMQP_0_10</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>JSON</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"DERBY","storePath":"${dollar.sign}{json:QPID_WORK}${dollar.sign}{json:file.separator}${dollar.sign}{this:name}${dollar.sign}{json:file.separator}derby"}</profile.virtualhostnode.context.blueprint> @@ -652,7 +652,7 @@ <profile>java-json.0-10</profile> <profile.specific.excludes>JavaPersistentExcludes JavaJsonExcludes XAExcludes Java010Excludes</profile.specific.excludes> <profile.broker.version>v0_10</profile.broker.version> - <profile.qpid.broker_default_amqp_protocol_excludes>AMQP_1_0</profile.qpid.broker_default_amqp_protocol_excludes> + <profile.test.amqp_port_protocols>["AMQP_0_8","AMQP_0_9","AMQP_0_9_1","AMQP_0_10"]</profile.test.amqp_port_protocols> <profile.broker.persistent>true</profile.broker.persistent> <profile.virtualhostnode.type>JSON</profile.virtualhostnode.type> <profile.virtualhostnode.context.blueprint>{"type":"DERBY","storePath":"${dollar.sign}{QPID_WORK}/${dollar.sign}{this:name}/derby"}</profile.virtualhostnode.context.blueprint> diff --git a/qpid/java/systests/etc/config-systests.json b/qpid/java/systests/etc/config-systests.json index 4375f258e8..4ec402c292 100644 --- a/qpid/java/systests/etc/config-systests.json +++ b/qpid/java/systests/etc/config-systests.json @@ -41,7 +41,8 @@ "ports" : [ { "name" : "amqp", "authenticationProvider" : "plain", - "port" : "${test.port}" + "port" : "${test.port}", + "protocols" : "${test.amqp_port_protocols}" }, { "name" : "http", "authenticationProvider" : "plain", diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java index 0f558f3abe..0345485167 100755 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java @@ -142,6 +142,8 @@ public class QpidBrokerTestCase extends QpidTestCase public static final int DEFAULT_HTTP_MANAGEMENT_PORT_VALUE = 8080; public static final int DEFAULT_HTTPS_MANAGEMENT_PORT_VALUE = 8443; + public static final String TEST_AMQP_PORT_PROTOCOLS_PROPERTY="test.amqp_port_protocols"; + // values protected static final String JAVA = "java"; protected static final String CPP = "cpp"; @@ -559,6 +561,8 @@ public class QpidBrokerTestCase extends QpidTestCase setSystemProperty("test.port.ssl"); setSystemProperty("test.port.alt"); setSystemProperty("test.port.alt.ssl"); + setSystemProperty("test.amqp_port_protocols"); + setSystemProperty("virtualhostnode.type"); setSystemProperty("virtualhostnode.context.blueprint"); diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java index 42f3854d32..b94827f249 100644 --- a/qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java +++ b/qpid/java/systests/src/test/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java @@ -20,6 +20,15 @@ */ package org.apache.qpid.server; +import java.io.IOException; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.codehaus.jackson.map.ObjectMapper; + import org.apache.qpid.client.AMQConnection; import org.apache.qpid.configuration.ClientProperties; import org.apache.qpid.framing.ProtocolVersion; @@ -43,11 +52,41 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase // No-op, we call super.setUp() from test methods after appropriate config overrides } - private void clearProtocolSupportManipulations() + private void clearProtocolSupportManipulations() throws Exception { //Remove the QBTC provided protocol manipulations, giving only the protocols which default to enabled setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES, null); setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_INCLUDES, null); + setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsAsString(getAllAmqpProtocols())); + } + + private Collection<Protocol> getAllAmqpProtocols() throws Exception + { + Collection<Protocol> protocols = new HashSet<>(); + for(Protocol p : Protocol.values()) + { + if(p.getProtocolType() == Protocol.ProtocolType.AMQP) + { + protocols.add(p); + } + } + + return protocols; + } + + private String getProtocolsWithExclusions(Protocol... excludes) throws Exception + { + Set<Protocol> protocols = new HashSet<>(getAllAmqpProtocols()); + protocols.removeAll(Arrays.asList(excludes)); + return getProtocolsAsString(protocols); + } + + private String getProtocolsAsString(final Collection<Protocol> protocols) throws IOException + { + ObjectMapper mapper = new ObjectMapper(); + StringWriter stringWriter = new StringWriter(); + mapper.writeValue(stringWriter, protocols); + return stringWriter.toString(); } /** @@ -89,11 +128,7 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase public void testDisabling010and10() throws Exception { - clearProtocolSupportManipulations(); - - //disable 0-10 and 1-0 support - setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES, - Protocol.AMQP_1_0 + "," + Protocol.AMQP_0_10); + setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsWithExclusions(Protocol.AMQP_1_0, Protocol.AMQP_0_10)); super.setUp(); @@ -110,8 +145,8 @@ public class SupportedProtocolVersionsTest extends QpidBrokerTestCase clearProtocolSupportManipulations(); //disable 0-10 support, and set the default unsupported protocol initiation reply to 0-9 - setSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES, - Protocol.AMQP_1_0 + "," + Protocol.AMQP_0_10); + setSystemProperty(QpidBrokerTestCase.TEST_AMQP_PORT_PROTOCOLS_PROPERTY, getProtocolsWithExclusions(Protocol.AMQP_1_0, Protocol.AMQP_0_10)); + setSystemProperty(BrokerProperties.PROPERTY_DEFAULT_SUPPORTED_PROTOCOL_REPLY, "v0_9"); super.setUp(); diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java index 319cc1c9da..c81bbd5469 100644 --- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java +++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java @@ -65,6 +65,7 @@ public class BrokerRestHttpsTest extends QpidRestTestCase Asserts.assertAttributesPresent(brokerDetails, BrokerModel.getInstance().getTypeRegistry().getAttributeNames(Broker.class), Broker.PROCESS_PID, + Broker.CONFIDENTIAL_CONFIGURATION_ENCRYPTION_PROVIDER, ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java index bae27b802c..ba95eecc6d 100644 --- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java +++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java @@ -204,6 +204,7 @@ public class BrokerRestTest extends QpidRestTestCase Asserts.assertAttributesPresent(brokerDetails, BrokerModel.getInstance().getTypeRegistry().getAttributeNames( Broker.class), Broker.PROCESS_PID, + Broker.CONFIDENTIAL_CONFIGURATION_ENCRYPTION_PROVIDER, ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, diff --git a/qpid/java/test-profiles/CPPExcludes b/qpid/java/test-profiles/CPPExcludes index 44014c9ec0..b20e85c40a 100755 --- a/qpid/java/test-profiles/CPPExcludes +++ b/qpid/java/test-profiles/CPPExcludes @@ -199,3 +199,6 @@ org.apache.qpid.server.queue.QueueMessageDurabilityTest#* // QPID-4429 : C++ Broker does not enforce max frame size negotiation rules as per the spec org.apache.qpid.transport.MaxFrameSizeTest#* + +// QPID-6000 : Tests Java specific message compression functionality, and uses the REST API to test it +org.apache.qpid.systest.MessageCompressionTest#* |