diff options
author | Robert Godfrey <rgodfrey@apache.org> | 2014-04-30 01:22:13 +0000 |
---|---|---|
committer | Robert Godfrey <rgodfrey@apache.org> | 2014-04-30 01:22:13 +0000 |
commit | 0575ac3eabdd24830af3393f38a49f8dfee3d3c8 (patch) | |
tree | 03d034dc64304d0408b7c48059242f83681b1b8b | |
parent | 606f4d7eaccc8bbcb2cda6efb76f8f371b67aee1 (diff) | |
download | qpid-python-0575ac3eabdd24830af3393f38a49f8dfee3d3c8.tar.gz |
QPID-5578 : [Java Broker] Use annotation to allow registration of all ConfiguredObject types at startup. Use this meta data for REST servlets. Remove unnecessary pluggable factory interfaces
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1591170 13f79535-47bb-0310-9956-ffa450edef68
98 files changed, 1225 insertions, 2047 deletions
diff --git a/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryGenerator.java b/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryGenerator.java index 658b468c3b..8fd5de76e5 100644 --- a/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryGenerator.java +++ b/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryGenerator.java @@ -23,8 +23,7 @@ package org.apache.qpid.server.model; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.util.Arrays; -import java.util.HashSet; +import java.util.Collections; import java.util.Set; import javax.annotation.processing.AbstractProcessor; @@ -54,7 +53,7 @@ public class ConfiguredObjectFactoryGenerator extends AbstractProcessor @Override public Set<String> getSupportedAnnotationTypes() { - return new HashSet<>(Arrays.asList(ManagedObjectFactory.class.getName(), ManagedObjectFactoryConstructor.class.getName())); + return Collections.singleton(ManagedObjectFactoryConstructor.class.getName()); } @Override diff --git a/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java b/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java new file mode 100644 index 0000000000..48e9c960b2 --- /dev/null +++ b/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ConfiguredObjectRegistrationGenerator.java @@ -0,0 +1,180 @@ +/* + * + * 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.model; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +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.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.PackageElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.util.Elements; +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; + +import org.apache.qpid.server.License; + +public class ConfiguredObjectRegistrationGenerator extends AbstractProcessor +{ + + public static final String MANAGED_OBJECT_CANONICAL_NAME = "org.apache.qpid.server.model.ManagedObject"; + + private Map<String, Set<String>> _managedObjectClasses = new HashMap<>(); + + @Override + public SourceVersion getSupportedSourceVersion() + { + return SourceVersion.latest(); + } + + @Override + public Set<String> getSupportedAnnotationTypes() + { + return Collections.singleton(MANAGED_OBJECT_CANONICAL_NAME); + } + + @Override + public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) + { + + Elements elementUtils = processingEnv.getElementUtils(); + TypeElement annotationElement = elementUtils.getTypeElement(MANAGED_OBJECT_CANONICAL_NAME); + + + try + { + + for (Element e : roundEnv.getElementsAnnotatedWith(annotationElement)) + { + if (e.getKind().equals(ElementKind.INTERFACE) || e.getKind().equals(ElementKind.CLASS)) + { + PackageElement packageElement = elementUtils.getPackageOf(e); + String packageName = packageElement.getQualifiedName().toString(); + + Set<String> classNames = _managedObjectClasses.get(packageName); + if (classNames == null) + { + classNames = new HashSet<>(); + _managedObjectClasses.put(packageName, classNames); + } + classNames.add(e.getSimpleName().toString()); + } + processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, e.getSimpleName()); + } + for (Map.Entry<String, Set<String>> entry : _managedObjectClasses.entrySet()) + { + generateRegistrationFile(entry.getKey(), entry.getValue()); + } + _managedObjectClasses.clear(); + } + catch (Exception e) + { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Error: " + e.getLocalizedMessage()); + } + + return false; + } + + private void generateRegistrationFile(final String packageName, final Set<String> classNames) + { + final String className = "ConfiguredObjectRegistrationImpl"; + final String qualifiedClassName = packageName + "." + className; + + try + { + + + JavaFileObject factoryFile = processingEnv.getFiler().createSourceFile(qualifiedClassName); + + PrintWriter pw = new PrintWriter(new OutputStreamWriter(factoryFile.openOutputStream(), "UTF-8")); + pw.println("/*"); + for (String headerLine : License.LICENSE) + { + pw.println(" *" + headerLine); + } + pw.println(" */"); + pw.println(); + pw.print("package "); + pw.print(packageName); + pw.println(";"); + pw.println(); + + pw.println("import java.util.Collections;"); + pw.println("import java.util.HashSet;"); + pw.println("import java.util.Set;"); + pw.println(); + pw.println("import org.apache.qpid.server.model.ConfiguredObject;"); + pw.println("import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;"); + pw.println("import org.apache.qpid.server.plugin.PluggableService;"); + pw.println(); + pw.println("@PluggableService"); + pw.println("public class " + className + " implements ConfiguredObjectRegistration"); + pw.println("{"); + pw.println(" private final Set<Class<? extends ConfiguredObject>> _implementations;"); + pw.println(); + pw.println(" public " + className + "()"); + pw.println(" {"); + pw.println(" Set<Class<? extends ConfiguredObject>> implementations = new HashSet<>();"); + for(String implementationName : classNames) + { + pw.println(" implementations.add("+implementationName+".class);"); + } + pw.println(" _implementations = Collections.unmodifiableSet(implementations);"); + pw.println(" }"); + pw.println(); + pw.println(" public String getType()"); + pw.println(" {"); + pw.println(" return \""+packageName+"\";"); + pw.println(" }"); + pw.println(); + pw.println(" public Set<Class<? extends ConfiguredObject>> getConfiguredObjectClasses()"); + pw.println(" {"); + pw.println(" return _implementations;"); + pw.println(" }"); + pw.println(); + + + pw.println("}"); + + pw.close(); + } + catch (IOException e) + { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, + "Failed to write file: " + + qualifiedClassName + + " - " + + e.getLocalizedMessage() + ); + } + } + +} diff --git a/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor index 3219c441a3..005394d209 100644 --- a/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor +++ b/java/broker-codegen/src/main/resources/META-INF/services/javax.annotation.processing.Processor @@ -18,3 +18,4 @@ # org.apache.qpid.server.model.ConfiguredObjectFactoryGenerator org.apache.qpid.server.plugin.PluggableProcessor +org.apache.qpid.server.model.ConfiguredObjectRegistrationGenerator diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java index 1f0f20ef1b..72f0365240 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java @@ -56,7 +56,6 @@ import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.Publisher; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.State; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.store.StorableMessageMetaData; @@ -168,7 +167,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> super.onOpen(); // Log Exchange creation - getEventLogger().message(ExchangeMessages.CREATED(getExchangeType().getType(), getName(), isDurable())); + getEventLogger().message(ExchangeMessages.CREATED(getType(), getName(), isDurable())); } @Override @@ -188,14 +187,6 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> return _virtualHost.getEventLogger(); } - public abstract ExchangeType<T> getExchangeType(); - - @Override - public String getTypeName() - { - return getExchangeType().getType(); - } - public boolean isAutoDelete() { return getLifetimePolicy() != LifetimePolicy.PERMANENT; @@ -210,7 +201,7 @@ public abstract class AbstractExchange<T extends AbstractExchange<T>> throw new ExchangeIsAlternateException(getName()); } - if(getExchangeType().getDefaultExchangeName().equals( getName() )) + if(isReservedExchangeName(getName())) { throw new RequiredExchangeException(getName()); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java index 026182f7f3..4997095315 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java @@ -32,6 +32,7 @@ import java.util.concurrent.CopyOnWriteArraySet; import org.apache.log4j.Logger; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.filter.AMQInvalidArgumentException; import org.apache.qpid.server.filter.FilterSupport; @@ -41,12 +42,11 @@ import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.virtualhost.VirtualHostImpl; -@ManagedObject( category = false, type = "direct" ) +@ManagedObject( category = false, type = ExchangeDefaults.DIRECT_EXCHANGE_CLASS ) public class DirectExchange extends AbstractExchange<DirectExchange> { @@ -136,8 +136,6 @@ public class DirectExchange extends AbstractExchange<DirectExchange> private final ConcurrentHashMap<String, BindingSet> _bindingsByKey = new ConcurrentHashMap<String, BindingSet>(); - public static final ExchangeType<DirectExchange> TYPE = new DirectExchangeType(); - @ManagedObjectFactoryConstructor public DirectExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) { @@ -145,12 +143,6 @@ public class DirectExchange extends AbstractExchange<DirectExchange> } @Override - public ExchangeType<DirectExchange> getExchangeType() - { - return TYPE; - } - - @Override public List<? extends BaseQueue> doRoute(ServerMessage payload, final String routingKey, final InstanceProperties instanceProperties) diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java deleted file mode 100644 index b26991a50a..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DirectExchangeType.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * 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.exchange; - -import java.util.Map; - -import org.apache.qpid.exchange.ExchangeDefaults; -import org.apache.qpid.server.plugin.ExchangeType; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -@PluggableService -public class DirectExchangeType implements ExchangeType<DirectExchange> -{ - @Override - public String getType() - { - return ExchangeDefaults.DIRECT_EXCHANGE_CLASS; - } - - @Override - public DirectExchange newInstance(final VirtualHostImpl virtualHost, - final Map<String, Object> attributes) - { - return new DirectExchange(attributes, virtualHost); - } - - public String getDefaultExchangeName() - { - return ExchangeDefaults.DIRECT_EXCHANGE_NAME; - } -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java index 38913762d8..bd515f3951 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeImpl.java @@ -27,7 +27,6 @@ import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.message.MessageDestination; import org.apache.qpid.server.model.Exchange; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; public interface ExchangeImpl<T extends ExchangeImpl<T>> extends Exchange<T>, ExchangeReferrer, MessageDestination @@ -37,10 +36,6 @@ public interface ExchangeImpl<T extends ExchangeImpl<T>> extends Exchange<T>, Ex String getName(); - ExchangeType<T> getExchangeType(); - - String getTypeName(); - boolean isDurable(); /** diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java index cba9852d80..a72cbd6396 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.log4j.Logger; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.filter.AMQInvalidArgumentException; import org.apache.qpid.server.filter.FilterSupport; @@ -38,12 +39,11 @@ import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.virtualhost.VirtualHostImpl; -@ManagedObject( category = false, type = "fanout" ) +@ManagedObject( category = false, type = ExchangeDefaults.FANOUT_EXCHANGE_CLASS ) public class FanoutExchange extends AbstractExchange<FanoutExchange> { private static final Logger _logger = Logger.getLogger(FanoutExchange.class); @@ -64,10 +64,6 @@ public class FanoutExchange extends AbstractExchange<FanoutExchange> _filteredBindings.set(emptyMap); } - - - public static final ExchangeType<FanoutExchange> TYPE = new FanoutExchangeType(); - @ManagedObjectFactoryConstructor public FanoutExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) { @@ -75,12 +71,6 @@ public class FanoutExchange extends AbstractExchange<FanoutExchange> } @Override - public ExchangeType<FanoutExchange> getExchangeType() - { - return TYPE; - } - - @Override public ArrayList<BaseQueue> doRoute(ServerMessage payload, final String routingKey, final InstanceProperties instanceProperties) diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java deleted file mode 100644 index 1c90b7925b..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/FanoutExchangeType.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * 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.exchange; - -import java.util.Map; - -import org.apache.qpid.exchange.ExchangeDefaults; -import org.apache.qpid.server.plugin.ExchangeType; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -@PluggableService -public class FanoutExchangeType implements ExchangeType<FanoutExchange> -{ - @Override - public String getType() - { - return ExchangeDefaults.FANOUT_EXCHANGE_CLASS; - } - - @Override - public FanoutExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) - { - return new FanoutExchange(attributes, virtualHost); - } - - public String getDefaultExchangeName() - { - return ExchangeDefaults.FANOUT_EXCHANGE_NAME; - } -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java index e49d9ea632..74c393c10f 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java @@ -30,13 +30,13 @@ import java.util.concurrent.CopyOnWriteArraySet; import org.apache.log4j.Logger; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.filter.Filterable; import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.virtualhost.VirtualHostImpl; @@ -68,7 +68,7 @@ import org.apache.qpid.server.virtualhost.VirtualHostImpl; * amq.match - pub/sub on field content/value * </pre> */ -@ManagedObject( category = false, type = "headers" ) +@ManagedObject( category = false, type = ExchangeDefaults.HEADERS_EXCHANGE_CLASS ) public class HeadersExchange extends AbstractExchange<HeadersExchange> { @@ -80,9 +80,6 @@ public class HeadersExchange extends AbstractExchange<HeadersExchange> private final CopyOnWriteArrayList<HeadersBinding> _bindingHeaderMatchers = new CopyOnWriteArrayList<HeadersBinding>(); - - public static final ExchangeType<HeadersExchange> TYPE = new HeadersExchangeType(); - @ManagedObjectFactoryConstructor public HeadersExchange(final Map<String, Object> attributes, final VirtualHostImpl vhost) { @@ -90,12 +87,6 @@ public class HeadersExchange extends AbstractExchange<HeadersExchange> } @Override - public ExchangeType<HeadersExchange> getExchangeType() - { - return TYPE; - } - - @Override public ArrayList<BaseQueue> doRoute(ServerMessage payload, final String routingKey, final InstanceProperties instanceProperties) diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java deleted file mode 100644 index c9346f6e28..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeType.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * 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.exchange; - -import java.util.Map; - -import org.apache.qpid.exchange.ExchangeDefaults; -import org.apache.qpid.server.plugin.ExchangeType; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -@PluggableService -public class HeadersExchangeType implements ExchangeType<HeadersExchange> -{ - @Override - public String getType() - { - return ExchangeDefaults.HEADERS_EXCHANGE_CLASS; - } - - @Override - public HeadersExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) - { - return new HeadersExchange(attributes, virtualHost); - } - - public String getDefaultExchangeName() - { - - return ExchangeDefaults.HEADERS_EXCHANGE_NAME; - } -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java index edc6fa7796..40a8a8f7ee 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java @@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.log4j.Logger; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.exchange.topic.TopicExchangeResult; import org.apache.qpid.server.exchange.topic.TopicMatcherResult; @@ -42,18 +43,14 @@ import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.BaseQueue; import org.apache.qpid.server.util.ConnectionScopedRuntimeException; import org.apache.qpid.server.virtualhost.VirtualHostImpl; -@ManagedObject( category = false, type = "topic" ) +@ManagedObject( category = false, type = ExchangeDefaults.TOPIC_EXCHANGE_CLASS ) public class TopicExchange extends AbstractExchange<TopicExchange> { - public static final ExchangeType<TopicExchange> TYPE = new TopicExchangeType(); - - private static final Logger _logger = Logger.getLogger(TopicExchange.class); private final TopicParser _parser = new TopicParser(); @@ -70,12 +67,6 @@ public class TopicExchange extends AbstractExchange<TopicExchange> } @Override - public ExchangeType<TopicExchange> getExchangeType() - { - return TYPE; - } - - @Override protected synchronized void onBindingUpdated(final BindingImpl binding, final Map<String, Object> oldArguments) { final String bindingKey = binding.getBindingKey(); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java deleted file mode 100644 index dc2a526278..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchangeType.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * 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.exchange; - -import java.util.Map; - -import org.apache.qpid.exchange.ExchangeDefaults; -import org.apache.qpid.server.plugin.ExchangeType; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -@PluggableService -public class TopicExchangeType implements ExchangeType<TopicExchange> -{ - @Override - public String getType() - { - return ExchangeDefaults.TOPIC_EXCHANGE_CLASS; - } - - @Override - public TopicExchange newInstance(final VirtualHostImpl virtualHost, final Map<String, Object> attributes) - { - return new TopicExchange(attributes, virtualHost); - } - - public String getDefaultExchangeName() - { - return ExchangeDefaults.TOPIC_EXCHANGE_NAME; - } -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java b/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java index 7400eb8221..c5951a1a8b 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java @@ -23,7 +23,6 @@ package org.apache.qpid.server.logging.subjects; import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.BINDING_FORMAT; import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.virtualhost.VirtualHostImpl; @@ -43,10 +42,9 @@ public class BindingLogSubject extends AbstractLogSubject AMQQueue queue) { VirtualHostImpl virtualHost = queue.getVirtualHost(); - ExchangeType exchangeType = exchange.getExchangeType(); setLogStringWithFormat(BINDING_FORMAT, virtualHost.getName(), - exchangeType.getType(), + exchange.getType(), exchange.getName(), queue.getName(), routingKey); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java b/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java index 946b8dada5..1039e24a18 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java @@ -20,11 +20,11 @@ */ package org.apache.qpid.server.logging.subjects; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.EXCHANGE_FORMAT; + import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.virtualhost.VirtualHostImpl; -import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.EXCHANGE_FORMAT; - public class ExchangeLogSubject extends AbstractLogSubject { @@ -32,6 +32,6 @@ public class ExchangeLogSubject extends AbstractLogSubject public ExchangeLogSubject(ExchangeImpl exchange, VirtualHostImpl vhost) { setLogStringWithFormat(EXCHANGE_FORMAT, vhost.getName(), - exchange.getExchangeType().getType(), exchange.getName()); + exchange.getType(), exchange.getName()); } } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java index 8b0e726c54..0199693bda 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java @@ -22,7 +22,6 @@ package org.apache.qpid.server.model; import java.io.IOException; import java.io.StringWriter; -import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -30,11 +29,9 @@ import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; import java.security.AccessControlException; import java.security.PrivilegedAction; -import java.util.AbstractCollection; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -42,8 +39,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -75,19 +70,6 @@ import org.apache.qpid.util.Strings; public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> implements ConfiguredObject<X> { - - private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?,?>>> _allAttributes = - Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?, ?>>>()); - - private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectStatistic<?,?>>> _allStatistics = - Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectStatistic<?, ?>>>()); - - private static final Map<Class<? extends ConfiguredObject>, Map<String, ConfiguredObjectAttribute<?,?>>> _allAttributeTypes = - Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, ConfiguredObjectAttribute<?, ?>>>()); - - private static final Map<Class<? extends ConfiguredObject>, Map<String, AutomatedField>> _allAutomatedFields = - Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, AutomatedField>>()); - private static final Map<Class, Object> SECURE_VALUES; public static final String SECURED_STRING_VALUE = "********"; @@ -106,9 +88,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im SECURE_VALUES = Collections.unmodifiableMap(secureValues); } - private static final Map<String, String> _defaultContext = - Collections.synchronizedMap(new HashMap<String, String>()); - private final AtomicBoolean _open = new AtomicBoolean(); private final Map<String,Object> _attributes = new HashMap<String, Object>(); @@ -162,7 +141,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im private LifetimePolicy _lifetimePolicy; private final Map<String, ConfiguredObjectAttribute<?,?>> _attributeTypes; - private final Map<String, AutomatedField> _automatedFields; + private final Map<String, ConfiguredObjectTypeRegistry.AutomatedField> _automatedFields; @ManagedAttributeField private String _type; @@ -203,10 +182,10 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im _taskExecutor = taskExecutor; _model = model; - _category = Model.getCategory(getClass()); + _category = ConfiguredObjectTypeRegistry.getCategory(getClass()); - _attributeTypes = getAttributeTypes(getClass()); - _automatedFields = getAutomatedFields(getClass()); + _attributeTypes = ConfiguredObjectTypeRegistry.getAttributeTypes(getClass()); + _automatedFields = ConfiguredObjectTypeRegistry.getAutomatedFields(getClass()); Object idObj = attributes.get(ID); @@ -228,7 +207,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im throw new IllegalArgumentException("The name attribute is mandatory for " + getClass().getSimpleName() + " creation."); } - _type = Model.getType(getClass()); + _type = ConfiguredObjectTypeRegistry.getType(getClass()); _bestFitInterface = calculateBestFitInterface(); if(attributes.get(TYPE) != null && !_type.equals(attributes.get(TYPE))) @@ -359,7 +338,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im { value = attribute.getAnnotation().defaultValue(); } - AutomatedField field = _automatedFields.get(name); + ConfiguredObjectTypeRegistry.AutomatedField field = _automatedFields.get(name); if(field.getPreSettingAction() != null) { @@ -834,7 +813,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im public final Collection<String> getAttributeNames() { - return getAttributeNames(getClass()); + return ConfiguredObjectTypeRegistry.getAttributeNames(getClass()); } @Override @@ -988,13 +967,13 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im @Override public final <C extends ConfiguredObject> C getChildById(final Class<C> clazz, final UUID id) { - return (C) _childrenById.get(Model.getCategory(clazz)).get(id); + return (C) _childrenById.get(ConfiguredObjectTypeRegistry.getCategory(clazz)).get(id); } @Override public final <C extends ConfiguredObject> C getChildByName(final Class<C> clazz, final String name) { - Class<? extends ConfiguredObject> categoryClass = Model.getCategory(clazz); + Class<? extends ConfiguredObject> categoryClass = ConfiguredObjectTypeRegistry.getCategory(clazz); if(getModel().getParentTypes(categoryClass).size() != 1) { throw new UnsupportedOperationException("Cannot use getChildByName for objects of category " @@ -1135,7 +1114,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im @Override public Map<String,Number> getStatistics() { - Collection<ConfiguredObjectStatistic> stats = getStatistics(getClass()); + Collection<ConfiguredObjectStatistic> stats = ConfiguredObjectTypeRegistry.getStatistics(getClass()); Map<String,Number> map = new HashMap<String,Number>(); for(ConfiguredObjectStatistic stat : stats) { @@ -1147,7 +1126,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im public <Y extends ConfiguredObject<Y>> Y findConfiguredObject(Class<Y> clazz, String name) { - Collection<Y> reachable = getReachableObjects(this,clazz); + Collection<Y> reachable = getModel().getReachableObjects(this, clazz); for(Y candidate : reachable) { if(candidate.getName().equals(name)) @@ -1181,7 +1160,7 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im new Strings.MapResolver(inheritedContext), Strings.JAVA_SYS_PROPS_RESOLVER, Strings.ENV_VARS_RESOLVER, - new Strings.MapResolver(_defaultContext)); + ConfiguredObjectTypeRegistry.getDefaultContextResolver()); } private static OwnAttributeResolver getOwnAttributeResolver(final ConfiguredObject<?> object) @@ -1210,452 +1189,6 @@ public abstract class AbstractConfiguredObject<X extends ConfiguredObject<X>> im } } - private static class AutomatedField - { - private final Field _field; - private final Method _preSettingAction; - private final Method _postSettingAction; - - private AutomatedField(final Field field, final Method preSettingAction, final Method postSettingAction) - { - _field = field; - _preSettingAction = preSettingAction; - _postSettingAction = postSettingAction; - } - - public Field getField() - { - return _field; - } - - public Method getPreSettingAction() - { - return _preSettingAction; - } - - public Method getPostSettingAction() - { - return _postSettingAction; - } - } - - private static final Comparator<ConfiguredObjectAttributeOrStatistic<?,?>> NAME_COMPARATOR = new Comparator<ConfiguredObjectAttributeOrStatistic<?, ?>>() - { - @Override - public int compare(final ConfiguredObjectAttributeOrStatistic<?, ?> left, - final ConfiguredObjectAttributeOrStatistic<?, ?> right) - { - return left.getName().compareTo(right.getName()); - } - }; - - private static <X extends ConfiguredObject> void processAttributes(final Class<X> clazz) - { - synchronized (_allAttributes) - { - if(_allAttributes.containsKey(clazz)) - { - return; - } - - - for(Class<?> parent : clazz.getInterfaces()) - { - if(ConfiguredObject.class.isAssignableFrom(parent)) - { - processAttributes((Class<? extends ConfiguredObject>)parent); - } - } - final Class<? super X> superclass = clazz.getSuperclass(); - if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass)) - { - processAttributes((Class<? extends ConfiguredObject>) superclass); - } - - final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet = new TreeSet<>(NAME_COMPARATOR); - final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet = new TreeSet<>(NAME_COMPARATOR); - - _allAttributes.put(clazz, attributeSet); - _allStatistics.put(clazz, statisticSet); - - for(Class<?> parent : clazz.getInterfaces()) - { - if(ConfiguredObject.class.isAssignableFrom(parent)) - { - Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(parent); - for(ConfiguredObjectAttribute<?,?> attr : attrs) - { - if(!attributeSet.contains(attr)) - { - attributeSet.add(attr); - } - } - Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(parent); - for(ConfiguredObjectStatistic<?,?> stat : stats) - { - if(!statisticSet.contains(stat)) - { - statisticSet.add(stat); - } - } - } - } - if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass)) - { - Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(superclass); - Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(superclass); - for(ConfiguredObjectAttribute<?,?> attr : attrs) - { - if(!attributeSet.contains(attr)) - { - attributeSet.add(attr); - } - } - for(ConfiguredObjectStatistic<?,?> stat : stats) - { - if(!statisticSet.contains(stat)) - { - statisticSet.add(stat); - } - } - } - - - for(Method m : clazz.getDeclaredMethods()) - { - ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class); - if(annotation != null) - { - if(!(annotation.automate() || annotation.derived() || annotation.state())) - { - throw new ServerScopedRuntimeException("ManagedAttributes must be either automated or derived. " + m.getName() + " on " + clazz.getSimpleName() + " does not meet this criterion."); - } - if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) - { - throw new ServerScopedRuntimeException("Can only define ManagedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); - } - - ConfiguredObjectAttribute attribute = new ConfiguredObjectAttribute(clazz, m, annotation); - if(attributeSet.contains(attribute)) - { - attributeSet.remove(attribute); - } - attributeSet.add(attribute); - } - else - { - ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class); - if(statAnnotation != null) - { - if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) - { - throw new ServerScopedRuntimeException("Can only define ManagedStatistics on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); - } - ConfiguredObjectStatistic statistic = new ConfiguredObjectStatistic(clazz, m); - if(statisticSet.contains(statistic)) - { - statisticSet.remove(statistic); - } - statisticSet.add(statistic); - } - } - } - - Map<String,ConfiguredObjectAttribute<?,?>> attrMap = new HashMap<String, ConfiguredObjectAttribute<?, ?>>(); - Map<String,AutomatedField> fieldMap = new HashMap<String, AutomatedField>(); - - - Collection<ConfiguredObjectAttribute<?, ?>> attrCol = _allAttributes.get(clazz); - for(ConfiguredObjectAttribute<?,?> attr : attrCol) - { - attrMap.put(attr.getName(), attr); - if(attr.getAnnotation().automate()) - { - fieldMap.put(attr.getName(), findField(attr, clazz)); - } - - } - _allAttributeTypes.put(clazz, attrMap); - _allAutomatedFields.put(clazz, fieldMap); - - for(Field field : clazz.getDeclaredFields()) - { - if(Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.isAnnotationPresent(ManagedContextDefault.class)) - { - try - { - String name = field.getAnnotation(ManagedContextDefault.class).name(); - Object value = field.get(null); - if(!_defaultContext.containsKey(name)) - { - _defaultContext.put(name,String.valueOf(value)); - } - else - { - throw new IllegalArgumentException("Multiple definitions of the default context variable ${"+name+"}"); - } - } - catch (IllegalAccessException e) - { - throw new ServerScopedRuntimeException("Unkecpected illegal access exception (only inspecting public static fields)", e); - } - } - } - } - } - - private static AutomatedField findField(final ConfiguredObjectAttribute<?, ?> attr, Class<?> objClass) - { - Class<?> clazz = objClass; - while(clazz != null) - { - for(Field field : clazz.getDeclaredFields()) - { - if(field.isAnnotationPresent(ManagedAttributeField.class) && field.getName().equals("_" + attr.getName().replace('.','_'))) - { - try - { - ManagedAttributeField annotation = field.getAnnotation(ManagedAttributeField.class); - field.setAccessible(true); - Method beforeSet; - if (!"".equals(annotation.beforeSet())) - { - beforeSet = clazz.getDeclaredMethod(annotation.beforeSet()); - beforeSet.setAccessible(true); - } - else - { - beforeSet = null; - } - Method afterSet; - if (!"".equals(annotation.afterSet())) - { - afterSet = clazz.getDeclaredMethod(annotation.afterSet()); - afterSet.setAccessible(true); - } - else - { - afterSet = null; - } - return new AutomatedField(field, beforeSet, afterSet); - } - catch (NoSuchMethodException e) - { - throw new ServerScopedRuntimeException("Cannot find method referenced by annotation for pre/post setting action", e); - } - - } - } - clazz = clazz.getSuperclass(); - } - if(objClass.isInterface() || Modifier.isAbstract(objClass.getModifiers())) - { - return null; - } - throw new ServerScopedRuntimeException("Unable to find field definition for automated field " + attr.getName() + " in class " + objClass.getName()); - } - - public static <X extends ConfiguredObject> Collection<String> getAttributeNames(Class<X> clazz) - { - final Collection<ConfiguredObjectAttribute<? super X, ?>> attrs = getAttributes(clazz); - - return new AbstractCollection<String>() - { - @Override - public Iterator<String> iterator() - { - final Iterator<ConfiguredObjectAttribute<? super X, ?>> underlyingIterator = attrs.iterator(); - return new Iterator<String>() - { - @Override - public boolean hasNext() - { - return underlyingIterator.hasNext(); - } - - @Override - public String next() - { - return underlyingIterator.next().getName(); - } - - @Override - public void remove() - { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public int size() - { - return attrs.size(); - } - }; - - } - - protected static <X extends ConfiguredObject> Collection<ConfiguredObjectAttribute<? super X, ?>> getAttributes(final Class<X> clazz) - { - if(!_allAttributes.containsKey(clazz)) - { - processAttributes(clazz); - } - final Collection<ConfiguredObjectAttribute<? super X, ?>> attributes = (Collection) _allAttributes.get(clazz); - return attributes; - } - - - protected static Collection<ConfiguredObjectStatistic> getStatistics(final Class<? extends ConfiguredObject> clazz) - { - if(!_allStatistics.containsKey(clazz)) - { - processAttributes(clazz); - } - final Collection<ConfiguredObjectStatistic> statistics = (Collection) _allStatistics.get(clazz); - return statistics; - } - - - private static Map<String, ConfiguredObjectAttribute<?, ?>> getAttributeTypes(final Class<? extends ConfiguredObject> clazz) - { - if(!_allAttributeTypes.containsKey(clazz)) - { - processAttributes(clazz); - } - return _allAttributeTypes.get(clazz); - } - - private static Map<String, AutomatedField> getAutomatedFields(Class<? extends ConfiguredObject> clazz) - { - if(!_allAutomatedFields.containsKey(clazz)) - { - processAttributes(clazz); - } - return _allAutomatedFields.get(clazz); - } - - static <X extends ConfiguredObject<X>> Collection<X> getReachableObjects(final ConfiguredObject<?> object, - final Class<X> clazz) - { - Class<? extends ConfiguredObject> category = Model.getCategory(object.getClass()); - Class<? extends ConfiguredObject> ancestorClass = getAncestorClassWithGivenDescendant(object.getModel(),category, clazz); - if(ancestorClass != null) - { - ConfiguredObject ancestor = getAncestor(ancestorClass, category, object); - if(ancestor != null) - { - return getAllDescendants(ancestor, ancestorClass, clazz); - } - } - return null; - } - - private static <X extends ConfiguredObject<X>> Collection<X> getAllDescendants(final ConfiguredObject ancestor, - final Class<? extends ConfiguredObject> ancestorClass, - final Class<X> clazz) - { - Set<X> descendants = new HashSet<X>(); - for(Class<? extends ConfiguredObject> childClass : ancestor.getModel().getChildTypes(ancestorClass)) - { - Collection<? extends ConfiguredObject> children = ancestor.getChildren(childClass); - if(childClass == clazz) - { - - if(children != null) - { - descendants.addAll((Collection<X>)children); - } - } - else - { - if(children != null) - { - for(ConfiguredObject child : children) - { - descendants.addAll(getAllDescendants(child, childClass, clazz)); - } - } - } - } - return descendants; - } - - private static ConfiguredObject getAncestor(final Class<? extends ConfiguredObject> ancestorClass, - final Class<? extends ConfiguredObject> category, - final ConfiguredObject<?> object) - { - if(ancestorClass.isInstance(object)) - { - return object; - } - else - { - for(Class<? extends ConfiguredObject> parentClass : object.getModel().getParentTypes(category)) - { - ConfiguredObject parent = object.getParent(parentClass); - if(parent == null) - { - System.err.println(parentClass.getSimpleName()); - } - ConfiguredObject ancestor = getAncestor(ancestorClass, parentClass, parent); - if(ancestor != null) - { - return ancestor; - } - } - } - return null; - } - - private static Class<? extends ConfiguredObject> getAncestorClassWithGivenDescendant( - final Model model, final Class<? extends ConfiguredObject> category, - final Class<? extends ConfiguredObject> descendantClass) - { - Collection<Class<? extends ConfiguredObject>> candidateClasses = - Collections.<Class<? extends ConfiguredObject>>singleton(category); - while(!candidateClasses.isEmpty()) - { - for(Class<? extends ConfiguredObject> candidate : candidateClasses) - { - if(hasDescendant(model, candidate, descendantClass)) - { - return candidate; - } - } - Set<Class<? extends ConfiguredObject>> previous = new HashSet<Class<? extends ConfiguredObject>>(candidateClasses); - candidateClasses = new HashSet<Class<? extends ConfiguredObject>>(); - for(Class<? extends ConfiguredObject> prev : previous) - { - candidateClasses.addAll(model.getParentTypes(prev)); - } - } - return null; - } - - private static boolean hasDescendant(final Model model, final Class<? extends ConfiguredObject> candidate, - final Class<? extends ConfiguredObject> descendantClass) - { - int oldSize = 0; - - Set<Class<? extends ConfiguredObject>> allDescendants = new HashSet<Class<? extends ConfiguredObject>>(model.getChildTypes( - candidate)); - while(allDescendants.size() > oldSize) - { - oldSize = allDescendants.size(); - Set<Class<? extends ConfiguredObject>> prev = new HashSet<Class<? extends ConfiguredObject>>(allDescendants); - for(Class<? extends ConfiguredObject> clazz : prev) - { - allDescendants.addAll(model.getChildTypes(clazz)); - } - if(allDescendants.contains(descendantClass)) - { - break; - } - } - return allDescendants.contains(descendantClass); - } private static class OwnAttributeResolver implements Strings.Resolver { diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java index ec8b2d94fe..d0bc1c3436 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObjectTypeFactory.java @@ -40,13 +40,13 @@ abstract public class AbstractConfiguredObjectTypeFactory<X extends AbstractConf @Override public final String getType() { - return Model.getType(_clazz); + return ConfiguredObjectTypeRegistry.getType(_clazz); } @Override public final Class<? super X> getCategoryClass() { - return (Class<? super X>) Model.getCategory(_clazz); + return (Class<? super X>) ConfiguredObjectTypeRegistry.getCategory(_clazz); } @Override @@ -65,7 +65,7 @@ abstract public class AbstractConfiguredObjectTypeFactory<X extends AbstractConf { if(!parents[0].getModel().getParentTypes((Class<? extends ConfiguredObject>) getCategoryClass()).contains( - Model.getCategory(parentClass))) + ConfiguredObjectTypeRegistry.getCategory(parentClass))) { throw new IllegalArgumentException(parentClass.getSimpleName() + " is not a parent of " + _clazz.getSimpleName()); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java index 617419d828..b9dc1f4071 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractUnresolvedObject.java @@ -50,7 +50,7 @@ public abstract class AbstractUnresolvedObject<C extends ConfiguredObject<C>> im _parents = parents; Collection<ConfiguredObjectAttribute<? super C, ?>> attributes = - AbstractConfiguredObject.getAttributes(clazz); + ConfiguredObjectTypeRegistry.getAttributes(clazz); for(ConfiguredObjectAttribute<? super C, ?> attribute : attributes) { final Class<?> attributeType = attribute.getType(); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java index 828643273a..d2f90378cf 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java @@ -620,7 +620,7 @@ abstract class AttributeValueConverter<T> } else if(value instanceof UUID) { - Collection<X> reachable = AbstractConfiguredObject.getReachableObjects(object, _klazz); + Collection<X> reachable = object.getModel().getReachableObjects(object, _klazz); for(X candidate : reachable) { if(candidate.getId().equals(value)) @@ -633,7 +633,7 @@ abstract class AttributeValueConverter<T> else if(value instanceof String) { String valueStr = AbstractConfiguredObject.interpolate(object, (String) value); - Collection<X> reachable = AbstractConfiguredObject.getReachableObjects(object, _klazz); + Collection<X> reachable = object.getModel().getReachableObjects(object, _klazz); for(X candidate : reachable) { if(candidate.getName().equals(valueStr)) diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java index 0c8866fff1..2f80d9fecc 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttributeOrStatistic.java @@ -175,4 +175,6 @@ abstract class ConfiguredObjectAttributeOrStatistic<C extends ConfiguredObject, { return _converter; } + + } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java new file mode 100644 index 0000000000..0a99912df1 --- /dev/null +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java @@ -0,0 +1,608 @@ +/* + * + * 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.model; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.AbstractCollection; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.qpid.server.plugin.ConfiguredObjectRegistration; +import org.apache.qpid.server.plugin.QpidServiceLoader; +import org.apache.qpid.server.util.ServerScopedRuntimeException; +import org.apache.qpid.util.Strings; + +public class ConfiguredObjectTypeRegistry +{ + private static final Comparator<ConfiguredObjectAttributeOrStatistic<?,?>> NAME_COMPARATOR = new Comparator<ConfiguredObjectAttributeOrStatistic<?, ?>>() + { + @Override + public int compare(final ConfiguredObjectAttributeOrStatistic<?, ?> left, + final ConfiguredObjectAttributeOrStatistic<?, ?> right) + { + return left.getName().compareTo(right.getName()); + } + }; + + + private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?,?>>> _allAttributes = + Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?, ?>>>()); + + private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectStatistic<?,?>>> _allStatistics = + Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectStatistic<?, ?>>>()); + + private static final Map<Class<? extends ConfiguredObject>, Map<String, ConfiguredObjectAttribute<?,?>>> _allAttributeTypes = + Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, ConfiguredObjectAttribute<?, ?>>>()); + + private static final Map<Class<? extends ConfiguredObject>, Map<String, AutomatedField>> _allAutomatedFields = + Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Map<String, AutomatedField>>()); + + private static final Map<String, String> _defaultContext = + Collections.synchronizedMap(new HashMap<String, String>()); + + private static final Map<Class<? extends ConfiguredObject>,Set<Class<? extends ConfiguredObject>>> _knownTypes = + Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Set<Class<? extends ConfiguredObject>>>()); + + private static final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?,?>>> _typeSpecificAttributes = + Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?, ?>>>()); + + + static + { + QpidServiceLoader<ConfiguredObjectRegistration> loader = new QpidServiceLoader<>(); + + Set<Class<? extends ConfiguredObject>> categories = new HashSet<>(); + Set<Class<? extends ConfiguredObject>> types = new HashSet<>(); + + for (ConfiguredObjectRegistration registration : loader.instancesOf(ConfiguredObjectRegistration.class)) + { + for (Class<? extends ConfiguredObject> configuredObjectClass : registration.getConfiguredObjectClasses()) + { + processAttributes(configuredObjectClass); + ManagedObject annotation = configuredObjectClass.getAnnotation(ManagedObject.class); + if (annotation.category()) + { + categories.add(configuredObjectClass); + } + if (!"".equals(annotation.type())) + { + types.add(configuredObjectClass); + } + } + } + for (Class<? extends ConfiguredObject> categoryClass : categories) + { + _knownTypes.put(categoryClass, new HashSet<Class<? extends ConfiguredObject>>()); + } + + for (Class<? extends ConfiguredObject> typeClass : types) + { + for (Class<? extends ConfiguredObject> categoryClass : categories) + { + if (categoryClass.isAssignableFrom(typeClass)) + { + _knownTypes.get(categoryClass).add(typeClass); + } + } + } + + for (Class<? extends ConfiguredObject> categoryClass : categories) + { + Set<Class<? extends ConfiguredObject>> typesForCategory = _knownTypes.get(categoryClass); + if (typesForCategory.isEmpty()) + { + typesForCategory.add(categoryClass); + _typeSpecificAttributes.put(categoryClass, Collections.<ConfiguredObjectAttribute<?, ?>>emptySet()); + } + else + { + Set<String> commonAttributes = new HashSet<>(); + for(ConfiguredObjectAttribute<?,?> attribute : _allAttributes.get(categoryClass)) + { + commonAttributes.add(attribute.getName()); + } + for(Class<? extends ConfiguredObject> typeClass : typesForCategory) + { + Set<ConfiguredObjectAttribute<?,?>> attributes = new HashSet<>(); + for(ConfiguredObjectAttribute<?,?> attr : _allAttributes.get(typeClass)) + { + if(!commonAttributes.contains(attr.getName())) + { + attributes.add(attr); + } + } + _typeSpecificAttributes.put(typeClass, attributes); + } + + } + } + } + + public static Class<? extends ConfiguredObject> getCategory(final Class<?> clazz) + { + ManagedObject annotation = clazz.getAnnotation(ManagedObject.class); + if(annotation != null && annotation.category()) + { + return (Class<? extends ConfiguredObject>) clazz; + } + for(Class<?> iface : clazz.getInterfaces() ) + { + Class<? extends ConfiguredObject> cat = getCategory(iface); + if(cat != null) + { + return cat; + } + } + if(clazz.getSuperclass() != null) + { + return getCategory(clazz.getSuperclass()); + } + return null; + } + + public static Class<? extends ConfiguredObject> getTypeClass(final Class<? extends ConfiguredObject> clazz) + { + String typeName = getType(clazz); + Class<? extends ConfiguredObject> typeClass = null; + if(typeName != null) + { + Class<? extends ConfiguredObject> category = getCategory(clazz); + Set<Class<? extends ConfiguredObject>> types = _knownTypes.get(category); + for(Class<? extends ConfiguredObject> type : types) + { + ManagedObject annotation = type.getAnnotation(ManagedObject.class); + if(typeName.equals(annotation.type())) + { + typeClass = type; + break; + } + } + if(typeClass == null && typeName.equals(category.getSimpleName())) + { + typeClass = category; + } + } + + return typeClass; + + } + + public static Collection<Class<? extends ConfiguredObject>> getTypeSpecialisations(Class<? extends ConfiguredObject> clazz) + { + Class<? extends ConfiguredObject> categoryClass = getCategory(clazz); + if(categoryClass == null) + { + throw new IllegalArgumentException("Cannot locate ManagedObject information for " + clazz.getName()); + } + return Collections.unmodifiableCollection(_knownTypes.get(categoryClass)); + + } + + public static Collection<ConfiguredObjectAttribute<?,?>> getTypeSpecificAttributes(Class<? extends ConfiguredObject> clazz) + { + Class<? extends ConfiguredObject> typeClass = getTypeClass(clazz); + if(typeClass == null) + { + throw new IllegalArgumentException("Cannot locate ManagedObject information for " + clazz.getName()); + } + return Collections.unmodifiableCollection(_typeSpecificAttributes.get(typeClass)); + } + + public static String getType(final Class<? extends ConfiguredObject> clazz) + { + String type = getActualType(clazz); + + if("".equals(type)) + { + Class<? extends ConfiguredObject> category = getCategory(clazz); + if (category == null) + { + throw new IllegalArgumentException("No category for " + clazz.getSimpleName()); + } + ManagedObject annotation = category.getAnnotation(ManagedObject.class); + if (annotation == null) + { + throw new NullPointerException("No definition found for category " + category.getSimpleName()); + } + if (!"".equals(annotation.defaultType())) + { + type = annotation.defaultType(); + } + else + { + type = category.getSimpleName(); + } + } + return type; + } + + private static String getActualType(final Class<? extends ConfiguredObject> clazz) + { + ManagedObject annotation = clazz.getAnnotation(ManagedObject.class); + if(annotation != null) + { + if(!"".equals(annotation.type())) + { + return annotation.type(); + } + } + + for(Class<?> iface : clazz.getInterfaces() ) + { + if(ConfiguredObject.class.isAssignableFrom(iface)) + { + String type = getActualType((Class<? extends ConfiguredObject>) iface); + if(!"".equals(type)) + { + return type; + } + } + } + + if(clazz.getSuperclass() != null && ConfiguredObject.class.isAssignableFrom(clazz.getSuperclass())) + { + String type = getActualType((Class<? extends ConfiguredObject>) clazz.getSuperclass()); + if(!"".equals(type)) + { + return type; + } + } + + return ""; + } + + public static Strings.Resolver getDefaultContextResolver() + { + return new Strings.MapResolver(_defaultContext); + } + + static class AutomatedField + { + private final Field _field; + private final Method _preSettingAction; + private final Method _postSettingAction; + + private AutomatedField(final Field field, final Method preSettingAction, final Method postSettingAction) + { + _field = field; + _preSettingAction = preSettingAction; + _postSettingAction = postSettingAction; + } + + public Field getField() + { + return _field; + } + + public Method getPreSettingAction() + { + return _preSettingAction; + } + + public Method getPostSettingAction() + { + return _postSettingAction; + } + } + + + + + private static <X extends ConfiguredObject> void processAttributes(final Class<X> clazz) + { + synchronized (_allAttributes) + { + if(_allAttributes.containsKey(clazz)) + { + return; + } + + + for(Class<?> parent : clazz.getInterfaces()) + { + if(ConfiguredObject.class.isAssignableFrom(parent)) + { + processAttributes((Class<? extends ConfiguredObject>)parent); + } + } + final Class<? super X> superclass = clazz.getSuperclass(); + if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass)) + { + processAttributes((Class<? extends ConfiguredObject>) superclass); + } + + final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet = new TreeSet<>(NAME_COMPARATOR); + final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet = new TreeSet<>(NAME_COMPARATOR); + + _allAttributes.put(clazz, attributeSet); + _allStatistics.put(clazz, statisticSet); + + for(Class<?> parent : clazz.getInterfaces()) + { + if(ConfiguredObject.class.isAssignableFrom(parent)) + { + Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(parent); + for(ConfiguredObjectAttribute<?,?> attr : attrs) + { + if(!attributeSet.contains(attr)) + { + attributeSet.add(attr); + } + } + Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(parent); + for(ConfiguredObjectStatistic<?,?> stat : stats) + { + if(!statisticSet.contains(stat)) + { + statisticSet.add(stat); + } + } + } + } + if(superclass != null && ConfiguredObject.class.isAssignableFrom(superclass)) + { + Collection<ConfiguredObjectAttribute<?, ?>> attrs = _allAttributes.get(superclass); + Collection<ConfiguredObjectStatistic<?, ?>> stats = _allStatistics.get(superclass); + for(ConfiguredObjectAttribute<?,?> attr : attrs) + { + if(!attributeSet.contains(attr)) + { + attributeSet.add(attr); + } + } + for(ConfiguredObjectStatistic<?,?> stat : stats) + { + if(!statisticSet.contains(stat)) + { + statisticSet.add(stat); + } + } + } + + + for(Method m : clazz.getDeclaredMethods()) + { + ManagedAttribute annotation = m.getAnnotation(ManagedAttribute.class); + if(annotation != null) + { + if(!(annotation.automate() || annotation.derived() || annotation.state())) + { + throw new ServerScopedRuntimeException("ManagedAttributes must be either automated or derived. " + m.getName() + " on " + clazz.getSimpleName() + " does not meet this criterion."); + } + if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) + { + throw new ServerScopedRuntimeException("Can only define ManagedAttributes on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); + } + + ConfiguredObjectAttribute<?,?> attribute = new ConfiguredObjectAttribute(clazz, m, annotation); + if(attributeSet.contains(attribute)) + { + attributeSet.remove(attribute); + } + attributeSet.add(attribute); + } + else + { + ManagedStatistic statAnnotation = m.getAnnotation(ManagedStatistic.class); + if(statAnnotation != null) + { + if(!clazz.isInterface() || !ConfiguredObject.class.isAssignableFrom(clazz)) + { + throw new ServerScopedRuntimeException("Can only define ManagedStatistics on interfaces which extend " + ConfiguredObject.class.getSimpleName() + ". " + clazz.getSimpleName() + " does not meet these criteria."); + } + ConfiguredObjectStatistic statistic = new ConfiguredObjectStatistic(clazz, m); + if(statisticSet.contains(statistic)) + { + statisticSet.remove(statistic); + } + statisticSet.add(statistic); + } + } + } + + Map<String,ConfiguredObjectAttribute<?,?>> attrMap = new HashMap<String, ConfiguredObjectAttribute<?, ?>>(); + Map<String,AutomatedField> fieldMap = new HashMap<String, AutomatedField>(); + + + Collection<ConfiguredObjectAttribute<?, ?>> attrCol = _allAttributes.get(clazz); + for(ConfiguredObjectAttribute<?,?> attr : attrCol) + { + attrMap.put(attr.getName(), attr); + if(attr.getAnnotation().automate()) + { + fieldMap.put(attr.getName(), findField(attr, clazz)); + } + + } + _allAttributeTypes.put(clazz, attrMap); + _allAutomatedFields.put(clazz, fieldMap); + + for(Field field : clazz.getDeclaredFields()) + { + if(Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.isAnnotationPresent(ManagedContextDefault.class)) + { + try + { + String name = field.getAnnotation(ManagedContextDefault.class).name(); + Object value = field.get(null); + if(!_defaultContext.containsKey(name)) + { + _defaultContext.put(name,String.valueOf(value)); + } + else + { + throw new IllegalArgumentException("Multiple definitions of the default context variable ${"+name+"}"); + } + } + catch (IllegalAccessException e) + { + throw new ServerScopedRuntimeException("Unkecpected illegal access exception (only inspecting public static fields)", e); + } + } + } + } + } + + private static AutomatedField findField(final ConfiguredObjectAttribute<?, ?> attr, Class<?> objClass) + { + Class<?> clazz = objClass; + while(clazz != null) + { + for(Field field : clazz.getDeclaredFields()) + { + if(field.isAnnotationPresent(ManagedAttributeField.class) && field.getName().equals("_" + attr.getName().replace('.','_'))) + { + try + { + ManagedAttributeField annotation = field.getAnnotation(ManagedAttributeField.class); + field.setAccessible(true); + Method beforeSet; + if (!"".equals(annotation.beforeSet())) + { + beforeSet = clazz.getDeclaredMethod(annotation.beforeSet()); + beforeSet.setAccessible(true); + } + else + { + beforeSet = null; + } + Method afterSet; + if (!"".equals(annotation.afterSet())) + { + afterSet = clazz.getDeclaredMethod(annotation.afterSet()); + afterSet.setAccessible(true); + } + else + { + afterSet = null; + } + return new AutomatedField(field, beforeSet, afterSet); + } + catch (NoSuchMethodException e) + { + throw new ServerScopedRuntimeException("Cannot find method referenced by annotation for pre/post setting action", e); + } + + } + } + clazz = clazz.getSuperclass(); + } + if(objClass.isInterface() || Modifier.isAbstract(objClass.getModifiers())) + { + return null; + } + throw new ServerScopedRuntimeException("Unable to find field definition for automated field " + attr.getName() + " in class " + objClass.getName()); + } + + public static <X extends ConfiguredObject> Collection<String> getAttributeNames(Class<X> clazz) + { + final Collection<ConfiguredObjectAttribute<? super X, ?>> attrs = getAttributes(clazz); + + return new AbstractCollection<String>() + { + @Override + public Iterator<String> iterator() + { + final Iterator<ConfiguredObjectAttribute<? super X, ?>> underlyingIterator = attrs.iterator(); + return new Iterator<String>() + { + @Override + public boolean hasNext() + { + return underlyingIterator.hasNext(); + } + + @Override + public String next() + { + return underlyingIterator.next().getName(); + } + + @Override + public void remove() + { + throw new UnsupportedOperationException(); + } + }; + } + + @Override + public int size() + { + return attrs.size(); + } + }; + + } + + protected static <X extends ConfiguredObject> Collection<ConfiguredObjectAttribute<? super X, ?>> getAttributes(final Class<X> clazz) + { + if(!_allAttributes.containsKey(clazz)) + { + processAttributes(clazz); + } + final Collection<ConfiguredObjectAttribute<? super X, ?>> attributes = (Collection) _allAttributes.get(clazz); + return attributes; + } + + + protected static Collection<ConfiguredObjectStatistic> getStatistics(final Class<? extends ConfiguredObject> clazz) + { + if(!_allStatistics.containsKey(clazz)) + { + processAttributes(clazz); + } + final Collection<ConfiguredObjectStatistic> statistics = (Collection) _allStatistics.get(clazz); + return statistics; + } + + + static Map<String, ConfiguredObjectAttribute<?, ?>> getAttributeTypes(final Class<? extends ConfiguredObject> clazz) + { + if(!_allAttributeTypes.containsKey(clazz)) + { + processAttributes(clazz); + } + return _allAttributeTypes.get(clazz); + } + + static Map<String, AutomatedField> getAutomatedFields(Class<? extends ConfiguredObject> clazz) + { + if(!_allAutomatedFields.containsKey(clazz)) + { + processAttributes(clazz); + } + return _allAutomatedFields.get(clazz); + } + + + +} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java index 54d69fe516..57b06817f7 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java @@ -22,6 +22,8 @@ package org.apache.qpid.server.model; public interface ExternalFileBasedAuthenticationManager<X extends ExternalFileBasedAuthenticationManager<X>> extends PasswordCredentialManagingAuthenticationProvider<X> { - @ManagedAttribute( automate = true , mandatory = true ) + String PATH = "path"; + + @ManagedAttribute( automate = true , mandatory = true, description = "File location") public String getPath(); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java index 53f5fbc0d9..bf42335620 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java @@ -34,4 +34,5 @@ public @interface ManagedAttribute boolean mandatory() default false; boolean persist() default true; String defaultValue() default ""; + String description() default ""; } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java index f04ce311b9..790ed74afb 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java @@ -22,93 +22,127 @@ package org.apache.qpid.server.model; import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; public abstract class Model { - public static Class<? extends ConfiguredObject> getCategory(final Class<?> clazz) + <X extends ConfiguredObject<X>> Collection<X> getReachableObjects(final ConfiguredObject<?> object, + final Class<X> clazz) { - ManagedObject annotation = clazz.getAnnotation(ManagedObject.class); - if(annotation != null && annotation.category()) + Class<? extends ConfiguredObject> category = ConfiguredObjectTypeRegistry.getCategory(object.getClass()); + Class<? extends ConfiguredObject> ancestorClass = getAncestorClassWithGivenDescendant(category, clazz); + if(ancestorClass != null) { - return (Class<? extends ConfiguredObject>) clazz; - } - for(Class<?> iface : clazz.getInterfaces() ) - { - Class<? extends ConfiguredObject> cat = getCategory(iface); - if(cat != null) + ConfiguredObject ancestor = getAncestor(ancestorClass, category, object); + if(ancestor != null) { - return cat; + return getAllDescendants(ancestor, ancestorClass, clazz); } } - if(clazz.getSuperclass() != null) - { - return getCategory(clazz.getSuperclass()); - } return null; } - public static String getType(final Class<? extends ConfiguredObject> clazz) + <X extends ConfiguredObject<X>> Collection<X> getAllDescendants(final ConfiguredObject ancestor, + final Class<? extends ConfiguredObject> ancestorClass, + final Class<X> clazz) { - String type = getActualType(clazz); - - if("".equals(type)) + Set<X> descendants = new HashSet<X>(); + for(Class<? extends ConfiguredObject> childClass : getChildTypes(ancestorClass)) { - Class<? extends ConfiguredObject> category = getCategory(clazz); - if (category == null) - { - throw new IllegalArgumentException("No category for " + clazz.getSimpleName()); - } - ManagedObject annotation = category.getAnnotation(ManagedObject.class); - if (annotation == null) + Collection<? extends ConfiguredObject> children = ancestor.getChildren(childClass); + if(childClass == clazz) { - throw new NullPointerException("No definition found for category " + category.getSimpleName()); - } - if (!"".equals(annotation.defaultType())) - { - type = annotation.defaultType(); + + if(children != null) + { + descendants.addAll((Collection<X>)children); + } } else { - type = category.getSimpleName(); + if(children != null) + { + for(ConfiguredObject child : children) + { + descendants.addAll(getAllDescendants(child, childClass, clazz)); + } + } } } - return type; + return descendants; } - private static String getActualType(final Class<? extends ConfiguredObject> clazz) + <C extends ConfiguredObject> C getAncestor(final Class<C> ancestorClass, + final Class<? extends ConfiguredObject> category, + final ConfiguredObject<?> object) { - ManagedObject annotation = clazz.getAnnotation(ManagedObject.class); - if(annotation != null) + if(ancestorClass.isInstance(object)) + { + return (C) object; + } + else { - if(!"".equals(annotation.type())) + for(Class<? extends ConfiguredObject> parentClass : object.getModel().getParentTypes(category)) { - return annotation.type(); + ConfiguredObject<?> parent = object.getParent(parentClass); + ConfiguredObject<?> ancestor = getAncestor(ancestorClass, parentClass, parent); + if(ancestor != null) + { + return (C) ancestor; + } } } + return null; + } - for(Class<?> iface : clazz.getInterfaces() ) + private Class<? extends ConfiguredObject> getAncestorClassWithGivenDescendant( + final Class<? extends ConfiguredObject> category, + final Class<? extends ConfiguredObject> descendantClass) + { + Collection<Class<? extends ConfiguredObject>> candidateClasses = + Collections.<Class<? extends ConfiguredObject>>singleton(category); + while(!candidateClasses.isEmpty()) { - if(ConfiguredObject.class.isAssignableFrom(iface)) + for(Class<? extends ConfiguredObject> candidate : candidateClasses) { - String type = getActualType((Class<? extends ConfiguredObject>) iface); - if(!"".equals(type)) + if(hasDescendant(candidate, descendantClass)) { - return type; + return candidate; } } + Set<Class<? extends ConfiguredObject>> previous = new HashSet<>(candidateClasses); + candidateClasses = new HashSet<>(); + for(Class<? extends ConfiguredObject> prev : previous) + { + candidateClasses.addAll(getParentTypes(prev)); + } } + return null; + } + + private boolean hasDescendant(final Class<? extends ConfiguredObject> candidate, + final Class<? extends ConfiguredObject> descendantClass) + { + int oldSize = 0; - if(clazz.getSuperclass() != null && ConfiguredObject.class.isAssignableFrom(clazz.getSuperclass())) + Set<Class<? extends ConfiguredObject>> allDescendants = new HashSet<>(getChildTypes(candidate)); + while(allDescendants.size() > oldSize) { - String type = getActualType((Class<? extends ConfiguredObject>) clazz.getSuperclass()); - if(!"".equals(type)) + oldSize = allDescendants.size(); + Set<Class<? extends ConfiguredObject>> prev = new HashSet<>(allDescendants); + for(Class<? extends ConfiguredObject> clazz : prev) { - return type; + allDescendants.addAll(getChildTypes(clazz)); + } + if(allDescendants.contains(descendantClass)) + { + break; } } - - return ""; + return allDescendants.contains(descendantClass); } public abstract Collection<Class<? extends ConfiguredObject>> getSupportedCategories(); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java index 047ea4ef97..7ca27f25ea 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java @@ -29,6 +29,6 @@ public interface FileBasedGroupProvider<X extends FileBasedGroupProvider<X>> ext { String PATH="path"; - @ManagedAttribute( automate = true, mandatory = true) + @ManagedAttribute( automate = true, mandatory = true, description = "File location" ) String getPath(); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java deleted file mode 100644 index fd1970f837..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 java.util.Collection; -import java.util.Map; - -import org.apache.qpid.server.logging.EventLogger; -import org.apache.qpid.server.logging.EventLoggerProvider; -import org.apache.qpid.server.model.AccessControlProvider; -import org.apache.qpid.server.security.AccessControl; - -public interface AccessControlProviderFactory<X extends AccessControlProvider<X>> extends ConfiguredObjectTypeFactory<X> -{ - public static final String ATTRIBUTE_TYPE = AccessControlProvider.TYPE; - - /** - * @return returns human readable descriptions for the attributes - */ - Map<String, String> getAttributeDescriptions(); -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java deleted file mode 100644 index 35651b442c..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 java.util.Collection; -import java.util.Map; - -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.security.auth.manager.AbstractAuthenticationManager; - -public interface AuthenticationManagerFactory<X extends AuthenticationProvider<X>> extends ConfiguredObjectTypeFactory<X> -{ - - /** - * Returns the authentication provider type - * @return authentication provider type - */ - String getType(); - - /** - * Get the names of attributes the authentication manager - * authentication manager - * - * @return the collection of attribute names - */ - Collection<String> getAttributeNames(); - - /** - * @return returns human readable descriptions for the attributes - */ - Map<String, String> getAttributeDescriptions(); -} diff --git a/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ManagedObjectFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java index b74e25df7f..7e8ce579eb 100644 --- a/java/broker-codegen/src/main/java/org/apache/qpid/server/model/ManagedObjectFactory.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java @@ -18,13 +18,13 @@ * under the License. * */ -package org.apache.qpid.server.model; +package org.apache.qpid.server.plugin; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +import java.util.Collection; -@Retention(RetentionPolicy.SOURCE) +import org.apache.qpid.server.model.ConfiguredObject; -public @interface ManagedObjectFactory +public interface ConfiguredObjectRegistration extends Pluggable { + Collection<Class<? extends ConfiguredObject>> getConfiguredObjectClasses(); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java deleted file mode 100644 index f82aaff42b..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ExchangeType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * 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 java.util.Map; - -import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.virtualhost.VirtualHostImpl; - -public interface ExchangeType<T extends ExchangeImpl<T>> extends Pluggable -{ - public String getType(); - - public T newInstance(final VirtualHostImpl virtualHost, Map<String, Object> attributes); - - public String getDefaultExchangeName(); -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java deleted file mode 100644 index 3d7a6323eb..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/GroupManagerFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 java.util.Collection; -import java.util.Map; - -import org.apache.qpid.server.model.GroupProvider; -import org.apache.qpid.server.security.group.GroupManager; - -public interface GroupManagerFactory extends Pluggable -{ - public static final String ATTRIBUTE_TYPE = GroupProvider.TYPE; - - GroupManager createInstance(Map<String, Object> attributes); - - /** - * Returns the authentication provider type - * @return authentication provider type - */ - String getType(); - - /** - * Get the names of attributes the group manager which can be passed into {@link #createInstance(Map)} to create the - * group manager - * - * @return the collection of attribute names - */ - Collection<String> getAttributeNames(); - - /** - * @return returns human readable descriptions for the attributes - */ - Map<String, String> getAttributeDescriptions(); -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java deleted file mode 100644 index 9665dfffbb..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 java.util.Map; -import java.util.UUID; - -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.PreferencesProvider; - -public interface PreferencesProviderFactory extends Pluggable -{ - PluggableFactoryLoader<PreferencesProviderFactory> FACTORY_LOADER = new PluggableFactoryLoader<PreferencesProviderFactory>(PreferencesProviderFactory.class); - - PreferencesProvider createInstance(UUID id, Map<String, Object> attributes, AuthenticationProvider<? extends AuthenticationProvider> authenticationProvider); - -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java b/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java index 041db03a09..d36f3df37e 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java @@ -171,7 +171,7 @@ public abstract class AbstractQueue<X extends AbstractQueue<X>> @ManagedAttributeField private ExclusivityPolicy _exclusive; - private Object _exclusiveOwner; // could be connection, session, Principal or a String for the container name + private Object _exclusiveOwner; // could be connection, session, Principal or a String forset the container name private final Set<NotificationCheck> _notificationChecks = Collections.synchronizedSet(EnumSet.noneOf(NotificationCheck.class)); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java index 08fccda4e8..823f24922e 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java @@ -46,7 +46,7 @@ import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.TrustStore; import org.apache.qpid.server.security.access.Operation; -import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationManager; import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager; import org.apache.qpid.transport.network.security.ssl.QpidPeersOnlyTrustManager; import org.apache.qpid.transport.network.security.ssl.SSLUtil; @@ -122,8 +122,8 @@ public class FileTrustStoreImpl extends AbstractConfiguredObject<FileTrustStoreI for (AuthenticationProvider authProvider : authenticationProviders) { Object attributeType = authProvider.getAttribute(AuthenticationProvider.TYPE); - Object attributeValue = authProvider.getAttribute(SimpleLDAPAuthenticationManagerFactory.ATTRIBUTE_TRUST_STORE); - if (SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE.equals(attributeType) + Object attributeValue = authProvider.getAttribute(SimpleLDAPAuthenticationManager.TRUST_STORE); + if (SimpleLDAPAuthenticationManager.PROVIDER_TYPE.equals(attributeType) && storeName.equals(attributeValue)) { throw new IntegrityViolationException("Trust store '" + storeName + "' can't be deleted as it is in use by an authentication manager: " + authProvider.getName()); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java index 6122cef5c1..05b3f0d9d1 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java @@ -196,7 +196,7 @@ public class ObjectProperties put(Property.AUTO_DELETE, exchange.isAutoDelete()); put(Property.TEMPORARY, exchange.getLifetimePolicy() != LifetimePolicy.PERMANENT); put(Property.DURABLE, exchange.isDurable()); - put(Property.TYPE, exchange.getTypeName()); + put(Property.TYPE, exchange.getType()); put(Property.VIRTUALHOST_NAME, exchange.getParent(VirtualHost.class).getName()); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java index 10753bc1f8..49580ff976 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java @@ -29,6 +29,7 @@ import javax.security.sasl.SaslServer; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.security.auth.AuthenticationResult; import org.apache.qpid.server.security.auth.UsernamePrincipal; import org.apache.qpid.server.security.auth.sasl.anonymous.AnonymousSaslServer; @@ -36,6 +37,7 @@ import org.apache.qpid.server.security.auth.sasl.anonymous.AnonymousSaslServer; @ManagedObject( category = false, type= "Anonymous" ) public class AnonymousAuthenticationManager extends AbstractAuthenticationManager<AnonymousAuthenticationManager> { + public static final String PROVIDER_TYPE = "Anonymous"; private static final String ANONYMOUS = "ANONYMOUS"; public static final String ANONYMOUS_USERNAME = "ANONYMOUS"; @@ -50,6 +52,7 @@ public class AnonymousAuthenticationManager extends AbstractAuthenticationManage private static final AuthenticationResult ANONYMOUS_AUTHENTICATION = new AuthenticationResult(ANONYMOUS_PRINCIPAL); + @ManagedObjectFactoryConstructor protected AnonymousAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { super(attributes, broker); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java deleted file mode 100644 index 7f37c4e39f..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.auth.manager; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.plugin.AuthenticationManagerFactory; -import org.apache.qpid.server.plugin.PluggableService; - -@PluggableService -public class AnonymousAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<AnonymousAuthenticationManager> implements AuthenticationManagerFactory<AnonymousAuthenticationManager> -{ - public static final String PROVIDER_TYPE = "Anonymous"; - - public AnonymousAuthenticationManagerFactory() - { - super(AnonymousAuthenticationManager.class); - } - - @Override - public Collection<String> getAttributeNames() - { - return Collections.singletonList(AuthenticationProvider.TYPE); - } - - - @Override - public Map<String, String> getAttributeDescriptions() - { - return Collections.emptyMap(); - } - - public AnonymousAuthenticationManager createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new AnonymousAuthenticationManager(attributes, getParent(Broker.class,parents)); - } - - -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java index 2140df545a..6fe649ff04 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase; import org.apache.qpid.server.security.auth.database.PrincipalDatabase; @@ -33,8 +34,10 @@ public class Base64MD5PasswordDatabaseAuthenticationManager { - protected Base64MD5PasswordDatabaseAuthenticationManager(final Broker broker, - final Map<String, Object> attributes) + public static final String PROVIDER_TYPE = "Base64MD5PasswordFile"; + + @ManagedObjectFactoryConstructor + protected Base64MD5PasswordDatabaseAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { super(attributes, broker); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java deleted file mode 100644 index 2fb9fd4ac3..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * 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.auth.manager; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.ConfiguredObjectFactory; -import org.apache.qpid.server.plugin.AuthenticationManagerFactory; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.store.ConfiguredObjectRecord; -import org.apache.qpid.server.store.ResolvedObject; -import org.apache.qpid.server.store.UnresolvedConfiguredObject; -import org.apache.qpid.server.util.ResourceBundleLoader; - -@PluggableService -public class Base64MD5PasswordFileAuthenticationManagerFactory - extends AbstractConfiguredObjectTypeFactory<Base64MD5PasswordDatabaseAuthenticationManager> - implements AuthenticationManagerFactory<Base64MD5PasswordDatabaseAuthenticationManager> -{ - public static final String PROVIDER_TYPE = "Base64MD5PasswordFile"; - public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.PasswordFileAuthenticationProviderAttributeDescriptions"; - public static final String ATTRIBUTE_PATH = "path"; - - - public static final Collection<String> ATTRIBUTES = Collections.unmodifiableList(Arrays.asList( - AuthenticationProvider.TYPE, - ATTRIBUTE_PATH)); - - public Base64MD5PasswordFileAuthenticationManagerFactory() - { - super(Base64MD5PasswordDatabaseAuthenticationManager.class); - } - - @Override - public Map<String, String> getAttributeDescriptions() - { - return ResourceBundleLoader.getResources(RESOURCE_BUNDLE); - } - - @Override - public Collection<String> getAttributeNames() - { - return ATTRIBUTES; - } - - @Override - public Base64MD5PasswordDatabaseAuthenticationManager createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new Base64MD5PasswordDatabaseAuthenticationManager(getParent(Broker.class, parents), attributes); - } - - @Override - public UnresolvedConfiguredObject<Base64MD5PasswordDatabaseAuthenticationManager> recover(final ConfiguredObjectFactory factory, - final ConfiguredObjectRecord record, - final ConfiguredObject<?>... parents) - { - - Map<String, Object> attributes = new HashMap<String, Object>(record.getAttributes()); - attributes.put(ConfiguredObject.ID, record.getId()); - final Base64MD5PasswordDatabaseAuthenticationManager authenticationManager = - new Base64MD5PasswordDatabaseAuthenticationManager(getParent(Broker.class, parents), - attributes - ); - return ResolvedObject.newInstance(authenticationManager); - } -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java index ceb6424c3d..28293b5814 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java @@ -27,6 +27,9 @@ import org.apache.qpid.server.model.ManagedObject; @ManagedObject( category = false, type = "External" ) public interface ExternalAuthenticationManager<T extends ExternalAuthenticationManager<T>> extends AuthenticationProvider<T> { - @ManagedAttribute( automate = true ) + String PROVIDER_TYPE = "External"; + String ATTRIBUTE_USE_FULL_DN = "useFullDN"; + + @ManagedAttribute( automate = true , description = "Use the full DN as the Username") boolean getUseFullDN(); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java deleted file mode 100644 index 967dbedc36..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.auth.manager; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.plugin.AuthenticationManagerFactory; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.util.ResourceBundleLoader; - -@PluggableService -public class ExternalAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<ExternalAuthenticationManagerImpl> - implements AuthenticationManagerFactory<ExternalAuthenticationManagerImpl> -{ - public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.ExternalAuthenticationProviderAttributeDescriptions"; - public static final String PROVIDER_TYPE = "External"; - public static final String ATTRIBUTE_USE_FULL_DN = "useFullDN"; - - public static final Collection<String> ATTRIBUTES = Collections.<String> unmodifiableList(Arrays.asList( - AuthenticationProvider.TYPE, - ATTRIBUTE_USE_FULL_DN)); - - public ExternalAuthenticationManagerFactory() - { - super(ExternalAuthenticationManagerImpl.class); - } - - @Override - public Collection<String> getAttributeNames() - { - return ATTRIBUTES; - } - - @Override - public Map<String, String> getAttributeDescriptions() - { - return ResourceBundleLoader.getResources(RESOURCE_BUNDLE); - } - - @Override - public ExternalAuthenticationManagerImpl createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new ExternalAuthenticationManagerImpl(attributes, getParent(Broker.class, parents)); - } - -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java index 99175bc13c..182200612e 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java @@ -26,6 +26,7 @@ import javax.security.sasl.SaslServer; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.security.auth.AuthenticationResult; import org.apache.qpid.server.security.auth.UsernamePrincipal; import org.apache.qpid.server.security.auth.sasl.external.ExternalSaslServer; @@ -38,6 +39,7 @@ public class ExternalAuthenticationManagerImpl extends AbstractAuthenticationMan @ManagedAttributeField private boolean _useFullDN; + @ManagedObjectFactoryConstructor protected ExternalAuthenticationManagerImpl(final Map<String, Object> attributes, final Broker broker) { super(attributes, broker); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationProviderAttributeDescriptions.properties b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationProviderAttributeDescriptions.properties deleted file mode 100644 index 263254e9fe..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationProviderAttributeDescriptions.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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. - -useFullDN=Use the full DN as the Username
\ No newline at end of file diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java index b344c4f5b4..28646ea5f4 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java @@ -33,15 +33,18 @@ import javax.security.sasl.SaslServer; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.security.auth.AuthenticationResult; import org.apache.qpid.server.security.auth.UsernamePrincipal; @ManagedObject( category = false, type = "Kerberos" ) public class KerberosAuthenticationManager extends AbstractAuthenticationManager<KerberosAuthenticationManager> { + public static final String PROVIDER_TYPE = "Kerberos"; private static final String GSSAPI_MECHANISM = "GSSAPI"; private final CallbackHandler _callbackHandler = new GssApiCallbackHandler(); + @ManagedObjectFactoryConstructor protected KerberosAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { super(attributes, broker); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java deleted file mode 100644 index 36c389bbdd..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManagerFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.auth.manager; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.plugin.AuthenticationManagerFactory; -import org.apache.qpid.server.plugin.PluggableService; - -@PluggableService -public class KerberosAuthenticationManagerFactory - extends AbstractConfiguredObjectTypeFactory<KerberosAuthenticationManager> - implements AuthenticationManagerFactory<KerberosAuthenticationManager> -{ - public static final String PROVIDER_TYPE = "Kerberos"; - - public KerberosAuthenticationManagerFactory() - { - super(KerberosAuthenticationManager.class); - } - - @Override - public Collection<String> getAttributeNames() - { - return Collections.<String>singletonList(AuthenticationProvider.TYPE); - } - - @Override - public Map<String, String> getAttributeDescriptions() - { - return Collections.emptyMap(); - } - - @Override - public KerberosAuthenticationManager createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new KerberosAuthenticationManager(attributes, getParent(Broker.class, parents)); - } - -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PasswordFileAuthenticationProviderAttributeDescriptions.properties b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PasswordFileAuthenticationProviderAttributeDescriptions.properties deleted file mode 100644 index e847e90f57..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PasswordFileAuthenticationProviderAttributeDescriptions.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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. - -path=File location*
\ No newline at end of file diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java index 8c9ec5a3e9..e6d2fcf44c 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java @@ -24,14 +24,17 @@ import java.util.Map; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase; import org.apache.qpid.server.security.auth.database.PrincipalDatabase; @ManagedObject( category = false, type = "PlainPasswordFile" ) public class PlainPasswordDatabaseAuthenticationManager extends PrincipalDatabaseAuthenticationManager<PlainPasswordDatabaseAuthenticationManager> { - protected PlainPasswordDatabaseAuthenticationManager(final Broker broker, - final Map<String, Object> attributes) + public static final String PROVIDER_TYPE = "PlainPasswordFile"; + + @ManagedObjectFactoryConstructor + protected PlainPasswordDatabaseAuthenticationManager(final Map<String, Object> attributes, final Broker broker) { super(attributes, broker); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java deleted file mode 100644 index 5fa054a363..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactory.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * 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.auth.manager; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.model.ConfiguredObjectFactory; -import org.apache.qpid.server.plugin.AuthenticationManagerFactory; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.store.ConfiguredObjectRecord; -import org.apache.qpid.server.store.ResolvedObject; -import org.apache.qpid.server.store.UnresolvedConfiguredObject; -import org.apache.qpid.server.util.ResourceBundleLoader; - -@PluggableService -public class PlainPasswordFileAuthenticationManagerFactory - extends AbstractConfiguredObjectTypeFactory<PlainPasswordDatabaseAuthenticationManager> - implements AuthenticationManagerFactory<PlainPasswordDatabaseAuthenticationManager> -{ - public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.PasswordFileAuthenticationProviderAttributeDescriptions"; - public static final String ATTRIBUTE_PATH = "path"; - - - public static final Collection<String> ATTRIBUTES = Collections.unmodifiableList(Arrays.asList( - AuthenticationProvider.TYPE, - ATTRIBUTE_PATH)); - - public static final String PROVIDER_TYPE = "PlainPasswordFile"; - - public PlainPasswordFileAuthenticationManagerFactory() - { - super(PlainPasswordDatabaseAuthenticationManager.class); - } - - @Override - public Map<String, String> getAttributeDescriptions() - { - return ResourceBundleLoader.getResources(RESOURCE_BUNDLE); - } - - - @Override - public Collection<String> getAttributeNames() - { - return ATTRIBUTES; - } - - @Override - public PlainPasswordDatabaseAuthenticationManager createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new PlainPasswordDatabaseAuthenticationManager(getParent(Broker.class, parents), attributes); - } - - @Override - public UnresolvedConfiguredObject<PlainPasswordDatabaseAuthenticationManager> recover(final ConfiguredObjectFactory factory, - final ConfiguredObjectRecord record, - final ConfiguredObject<?>... parents) - { - - Map<String, Object> attributes = new HashMap<String, Object>(record.getAttributes()); - attributes.put(ConfiguredObject.ID, record.getId()); - PlainPasswordDatabaseAuthenticationManager authManager = new PlainPasswordDatabaseAuthenticationManager( - getParent(Broker.class, parents), - attributes - ); - - return ResolvedObject.newInstance(authManager); - } -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java index 22e34edab1..43a4932022 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java @@ -45,6 +45,7 @@ import org.apache.qpid.server.configuration.updater.VoidTaskWithException; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.ManagedObject; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.PasswordCredentialManagingAuthenticationProvider; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.User; @@ -60,6 +61,7 @@ public class ScramSHA1AuthenticationManager implements PasswordCredentialManagingAuthenticationProvider<ScramSHA1AuthenticationManager> { public static final String SCRAM_USER_TYPE = "scram"; + public static final String PROVIDER_TYPE = "SCRAM-SHA-1"; static final Charset ASCII = Charset.forName("ASCII"); public static final String HMAC_SHA_1 = "HmacSHA1"; private final SecureRandom _random = new SecureRandom(); @@ -67,6 +69,7 @@ public class ScramSHA1AuthenticationManager private Map<String, ScramAuthUser> _users = new ConcurrentHashMap<String, ScramAuthUser>(); + @ManagedObjectFactoryConstructor protected ScramSHA1AuthenticationManager(final Map<String, Object> attributes, final Broker broker) { super(attributes, broker); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java deleted file mode 100644 index 30c97dfead..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.auth.manager; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.plugin.AuthenticationManagerFactory; -import org.apache.qpid.server.plugin.PluggableService; - -@PluggableService -public class ScramSHA1AuthenticationManagerFactory - extends AbstractConfiguredObjectTypeFactory<ScramSHA1AuthenticationManager> - implements AuthenticationManagerFactory<ScramSHA1AuthenticationManager> -{ - - public static final String PROVIDER_TYPE = "SCRAM-SHA-1"; - - public static final String ATTRIBUTE_NAME = "name"; - - public static final Collection<String> ATTRIBUTES = Collections.<String> unmodifiableList(Arrays.asList( - AuthenticationProvider.TYPE - )); - - public ScramSHA1AuthenticationManagerFactory() - { - super(ScramSHA1AuthenticationManager.class); - } - - @Override - public Collection<String> getAttributeNames() - { - return ATTRIBUTES; - } - - @Override - public Map<String, String> getAttributeDescriptions() - { - return Collections.emptyMap(); - } - - @Override - public ScramSHA1AuthenticationManager createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new ScramSHA1AuthenticationManager(attributes, getParent(Broker.class, parents)); - } - -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java index 2e3568ff57..883dcd025e 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java @@ -28,21 +28,24 @@ import org.apache.qpid.server.model.TrustStore; @ManagedObject( category = false, type = "SimpleLDAP" ) public interface SimpleLDAPAuthenticationManager<X extends SimpleLDAPAuthenticationManager<X>> extends AuthenticationProvider<X> { - @ManagedAttribute( automate = true ) + String PROVIDER_TYPE = "SimpleLDAP"; + String TRUST_STORE = "trustStore"; + + @ManagedAttribute( automate = true, description = "LDAP server URL" ) String getProviderUrl(); - @ManagedAttribute( automate = true ) + @ManagedAttribute( automate = true, description = "LDAP authentication URL") String getProviderAuthUrl(); - @ManagedAttribute( automate = true ) + @ManagedAttribute( automate = true, description = "Search context") String getSearchContext(); - @ManagedAttribute( automate = true ) + @ManagedAttribute( automate = true, description = "Search filter") String getSearchFilter(); - @ManagedAttribute( automate = true ) + @ManagedAttribute( automate = true, description = "LDAP context factory") String getLdapContextFactory(); - @ManagedAttribute( automate = true ) + @ManagedAttribute( automate = true, description = "Trust store name") TrustStore getTrustStore(); } diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java deleted file mode 100644 index cce7864e26..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.auth.manager; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.plugin.AuthenticationManagerFactory; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.util.ResourceBundleLoader; - -@PluggableService -public class SimpleLDAPAuthenticationManagerFactory - extends AbstractConfiguredObjectTypeFactory<SimpleLDAPAuthenticationManagerImpl> - implements AuthenticationManagerFactory<SimpleLDAPAuthenticationManagerImpl> -{ - public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.SimpleLDAPAuthenticationProviderAttributeDescriptions"; - - public static final String PROVIDER_TYPE = "SimpleLDAP"; - - public static final String ATTRIBUTE_NAME = "name"; - public static final String ATTRIBUTE_LDAP_CONTEXT_FACTORY = "ldapContextFactory"; - public static final String ATTRIBUTE_SEARCH_FILTER = "searchFilter"; - public static final String ATTRIBUTE_SEARCH_CONTEXT = "searchContext"; - public static final String ATTRIBUTE_TRUST_STORE = "trustStore"; - public static final String ATTRIBUTE_PROVIDER_AUTH_URL = "providerAuthUrl"; - public static final String ATTRIBUTE_PROVIDER_URL = "providerUrl"; - - public static final Collection<String> ATTRIBUTES = Collections.<String> unmodifiableList(Arrays.asList( - AuthenticationProvider.TYPE, - ATTRIBUTE_PROVIDER_URL, - ATTRIBUTE_SEARCH_CONTEXT, - ATTRIBUTE_SEARCH_FILTER, - ATTRIBUTE_TRUST_STORE, - ATTRIBUTE_PROVIDER_AUTH_URL, - ATTRIBUTE_LDAP_CONTEXT_FACTORY - )); - - public SimpleLDAPAuthenticationManagerFactory() - { - super(SimpleLDAPAuthenticationManagerImpl.class); - } - - @Override - public Collection<String> getAttributeNames() - { - return ATTRIBUTES; - } - - @Override - public Map<String, String> getAttributeDescriptions() - { - return ResourceBundleLoader.getResources(RESOURCE_BUNDLE); - } - - @Override - public SimpleLDAPAuthenticationManagerImpl createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new SimpleLDAPAuthenticationManagerImpl(attributes, getParent(Broker.class, parents)); - } - -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java index 8227590dfe..c06a06c45e 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java @@ -48,6 +48,7 @@ import org.apache.log4j.Logger; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.TrustStore; import org.apache.qpid.server.security.auth.AuthenticationResult; import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus; @@ -94,6 +95,7 @@ public class SimpleLDAPAuthenticationManagerImpl extends AbstractAuthenticationM */ private Class<? extends SocketFactory> _sslSocketFactoryOverrideClass; + @ManagedObjectFactoryConstructor protected SimpleLDAPAuthenticationManagerImpl(final Map<String, Object> attributes, final Broker broker) { super(attributes, broker); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationProviderAttributeDescriptions.properties b/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationProviderAttributeDescriptions.properties deleted file mode 100644 index 18e6fb8a4c..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationProviderAttributeDescriptions.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# 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. - -ldapContextFactory= LDAP context factory -searchFilter=Search filter* -searchContext=Search context* -providerAuthUrl=LDAP authentication URL -providerUrl=LDAP server URL* -trustStore=Truststore name diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupProviderAttributeDescriptions.properties b/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupProviderAttributeDescriptions.properties deleted file mode 100644 index 2c2d2ab9e3..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupProviderAttributeDescriptions.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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. - -path= File location* diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java index 5723a004d9..8d0ff46cff 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java @@ -31,12 +31,12 @@ import java.util.UUID; import junit.framework.TestCase; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.message.AMQMessageHeader; import org.apache.qpid.server.model.Binding; import org.apache.qpid.server.model.BrokerModel; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.virtualhost.VirtualHostImpl; @@ -156,7 +156,7 @@ public class HeadersBindingTest extends TestCase final EventLogger eventLogger = new EventLogger(); when(vhost.getEventLogger()).thenReturn(eventLogger); _exchange = mock(ExchangeImpl.class); - when(_exchange.getExchangeType()).thenReturn(mock(ExchangeType.class)); + when(_exchange.getType()).thenReturn(ExchangeDefaults.HEADERS_EXCHANGE_CLASS); when(_exchange.getEventLogger()).thenReturn(eventLogger); when(_exchange.getModel()).thenReturn(BrokerModel.getInstance()); } diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java index 4789fa8c47..76a80a3570 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java @@ -20,11 +20,11 @@ */ package org.apache.qpid.server.logging.messages; +import java.util.List; + import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.util.BrokerTestHelper; -import java.util.List; - /** * Test EXH Log Messages */ @@ -34,7 +34,7 @@ public class ExchangeMessagesTest extends AbstractTestMessages { ExchangeImpl exchange = BrokerTestHelper.createExchange("test", false, getEventLogger()); - String type = exchange.getTypeName(); + String type = exchange.getType(); String name = exchange.getName(); _logMessage = ExchangeMessages.CREATED(type, name, false); @@ -49,7 +49,7 @@ public class ExchangeMessagesTest extends AbstractTestMessages { ExchangeImpl exchange = BrokerTestHelper.createExchange("test", true, getEventLogger()); - String type = exchange.getTypeName(); + String type = exchange.getType(); String name = exchange.getName(); _logMessage = ExchangeMessages.CREATED(type, name, true); diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java b/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java index f2486ff4d8..024ae22966 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java @@ -21,6 +21,8 @@ package org.apache.qpid.server.logging.subjects; +import java.util.List; + import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogMessage; @@ -31,8 +33,6 @@ import org.apache.qpid.server.util.BrokerTestHelper; import org.apache.qpid.server.virtualhost.VirtualHostImpl; import org.apache.qpid.test.utils.QpidTestCase; -import java.util.List; - /** * Abstract Test for LogSubject testing * Includes common validation code and two common tests. @@ -181,7 +181,7 @@ public abstract class AbstractTestLogSubject extends QpidTestCase exchangeParts.length); assertEquals("Exchange type not correct", - exchange.getExchangeType().getType(), exchangeParts[0]); + exchange.getType(), exchangeParts[0]); assertEquals("Exchange name not correct", exchange.getName(), exchangeParts[1]); diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java index d76734f6b8..c18feb38a7 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java @@ -228,7 +228,7 @@ public class SecurityManagerTest extends QpidTestCase ExchangeImpl<?> exchange = mock(ExchangeImpl.class); when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost); when(exchange.getName()).thenReturn(TEST_EXCHANGE); - when(exchange.getTypeName()).thenReturn(TEST_EXCHANGE_TYPE); + when(exchange.getType()).thenReturn(TEST_EXCHANGE_TYPE); ObjectProperties properties = createExpectedExchangeObjectProperties(); @@ -329,7 +329,7 @@ public class SecurityManagerTest extends QpidTestCase ExchangeImpl<?> exchange = mock(ExchangeImpl.class); when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost); when(exchange.getName()).thenReturn(TEST_EXCHANGE); - when(exchange.getTypeName()).thenReturn(TEST_EXCHANGE_TYPE); + when(exchange.getType()).thenReturn(TEST_EXCHANGE_TYPE); ObjectProperties properties = createExpectedExchangeObjectProperties(); @@ -355,7 +355,7 @@ public class SecurityManagerTest extends QpidTestCase ExchangeImpl<?> exchange = mock(ExchangeImpl.class); when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost); when(exchange.getName()).thenReturn(TEST_EXCHANGE); - when(exchange.getTypeName()).thenReturn(TEST_EXCHANGE_TYPE); + when(exchange.getType()).thenReturn(TEST_EXCHANGE_TYPE); ObjectProperties properties = createExpectedExchangeObjectProperties(); diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java index 7be60d1049..a1b173c790 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java @@ -28,13 +28,15 @@ import junit.framework.TestCase; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.BrokerModel; +import org.apache.qpid.server.model.ConfiguredObjectFactory; import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase; import org.apache.qpid.server.util.BrokerTestHelper; public class PlainPasswordFileAuthenticationManagerFactoryTest extends TestCase { - PlainPasswordFileAuthenticationManagerFactory _factory = new PlainPasswordFileAuthenticationManagerFactory(); + ConfiguredObjectFactory _factory = BrokerModel.getInstance().getObjectFactory(); private Map<String, Object> _configuration = new HashMap<String, Object>(); private File _emptyPasswordFile; private Broker _broker = BrokerTestHelper.createBrokerMock(); @@ -51,10 +53,10 @@ public class PlainPasswordFileAuthenticationManagerFactoryTest extends TestCase public void testPlainInstanceCreated() throws Exception { - _configuration.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); + _configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); _configuration.put("path", _emptyPasswordFile.getAbsolutePath()); - AuthenticationManager manager = _factory.create(null, _configuration, _broker); + AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker); assertNotNull(manager); assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager); assertTrue(((PrincipalDatabaseAuthenticationManager)manager).getPrincipalDatabase() instanceof PlainPasswordFilePrincipalDatabase); @@ -65,11 +67,11 @@ public class PlainPasswordFileAuthenticationManagerFactoryTest extends TestCase //delete the file _emptyPasswordFile.delete(); - _configuration.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); + _configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); _configuration.put("path", _emptyPasswordFile.getAbsolutePath()); - AuthenticationManager manager = _factory.create(null, _configuration, _broker); + AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker); assertNotNull(manager); assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager); @@ -78,11 +80,11 @@ public class PlainPasswordFileAuthenticationManagerFactoryTest extends TestCase public void testThrowsExceptionWhenConfigForPlainPDImplementationNoPasswordFileValueSpecified() throws Exception { - _configuration.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); + _configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); try { - AuthenticationManager manager = _factory.create(null, _configuration, _broker); + AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker); fail("No authentication manager should be created"); } catch (IllegalArgumentException e) diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java index 6fc28ac136..56283b1392 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java @@ -33,17 +33,17 @@ import junit.framework.TestCase; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.SystemContext; +import org.apache.qpid.server.model.BrokerModel; +import org.apache.qpid.server.model.ConfiguredObjectFactory; import org.apache.qpid.server.model.TrustStore; import org.apache.qpid.server.model.UnknownConfiguredObjectException; import org.apache.qpid.server.util.BrokerTestHelper; public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase { - private SimpleLDAPAuthenticationManagerFactory _factory = new SimpleLDAPAuthenticationManagerFactory(); + private ConfiguredObjectFactory _factory = BrokerModel.getInstance().getObjectFactory(); private Map<String, Object> _configuration = new HashMap<String, Object>(); private Broker _broker = BrokerTestHelper.createBrokerMock(); - private SystemContext _systemContext = mock(SystemContext.class); private TrustStore _trustStore = mock(TrustStore.class); @@ -60,22 +60,22 @@ public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase public void testLdapInstanceCreated() throws Exception { - _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE); + _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManager.PROVIDER_TYPE); _configuration.put("providerUrl", "ldap://example.com:389/"); _configuration.put("searchContext", "dc=example"); - AuthenticationManager manager = _factory.create(null, _configuration, _broker); + AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker); assertNotNull(manager); } public void testLdapsInstanceCreated() throws Exception { - _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE); + _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManager.PROVIDER_TYPE); _configuration.put("providerUrl", "ldaps://example.com:636/"); _configuration.put("searchContext", "dc=example"); - AuthenticationManager manager = _factory.create(null, _configuration, _broker); + AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker); assertNotNull(manager); } @@ -85,12 +85,12 @@ public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase when(_broker.getChildren(eq(TrustStore.class))).thenReturn(Collections.singletonList(_trustStore)); - _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE); + _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManager.PROVIDER_TYPE); _configuration.put("providerUrl", "ldaps://example.com:636/"); _configuration.put("searchContext", "dc=example"); _configuration.put("trustStore", "mytruststore"); - AuthenticationManager manager = _factory.create(null, _configuration, _broker); + AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker); assertNotNull(manager); } @@ -98,14 +98,14 @@ public class SimpleLDAPAuthenticationManagerFactoryTest extends TestCase { when(_broker.getChildren(eq(TrustStore.class))).thenReturn(Collections.singletonList(_trustStore)); - _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManagerFactory.PROVIDER_TYPE); + _configuration.put(AuthenticationProvider.TYPE, SimpleLDAPAuthenticationManager.PROVIDER_TYPE); _configuration.put("providerUrl", "ldaps://example.com:636/"); _configuration.put("searchContext", "dc=example"); _configuration.put("trustStore", "notfound"); try { - _factory.create(null, _configuration, _broker); + _factory.create(AuthenticationProvider.class, _configuration, _broker); fail("Exception not thrown"); } catch(UnknownConfiguredObjectException e) diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java index f0838be380..1e10053d90 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java @@ -38,6 +38,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatcher; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; + import org.apache.qpid.common.AMQPFilterTypes; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.exchange.ExchangeImpl; @@ -52,7 +53,6 @@ import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.UUIDGenerator; import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler; @@ -496,7 +496,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest actualAttributes.put("type", getName() + "Type"); actualAttributes.put("lifetimePolicy", LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS); when(exchange.getName()).thenReturn(getName()); - when(exchange.getTypeName()).thenReturn(getName() + "Type"); + when(exchange.getType()).thenReturn(getName() + "Type"); when(exchange.isAutoDelete()).thenReturn(true); when(exchange.getId()).thenReturn(_exchangeId); when(exchange.getCategoryClass()).thenReturn(Exchange.class); @@ -510,7 +510,6 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest when(exchangeRecord.getAttributes()).thenReturn(actualAttributes); when(exchangeRecord.getParents()).thenReturn(Collections.singletonMap(_rootRecord.getType(), _rootRecord)); when(exchange.asObjectRecord()).thenReturn(exchangeRecord); - when(exchange.getExchangeType()).thenReturn(mock(ExchangeType.class)); when(exchange.getEventLogger()).thenReturn(new EventLogger()); return exchange; } diff --git a/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java b/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java index 961eb25236..d54f226a00 100644 --- a/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java +++ b/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java @@ -27,6 +27,6 @@ import org.apache.qpid.server.model.ManagedObject; @ManagedObject( category = false, type="AclFile" ) public interface ACLFileAccessControlProvider<X extends ACLFileAccessControlProvider<X>> extends AccessControlProvider<X> { - @ManagedAttribute( automate = true, mandatory = true ) + @ManagedAttribute( automate = true, mandatory = true, description = "File location" ) String getPath(); } diff --git a/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java b/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java deleted file mode 100644 index 1547adc6e5..0000000000 --- a/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * 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.access.plugins; - -import java.util.Map; - -import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; -import org.apache.qpid.server.plugin.AccessControlProviderFactory; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.util.ResourceBundleLoader; - -@PluggableService -public class ACLFileAccessControlProviderFactory extends AbstractConfiguredObjectTypeFactory<ACLFileAccessControlProviderImpl> implements AccessControlProviderFactory<ACLFileAccessControlProviderImpl> -{ - public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.access.plugins.FileAccessControlProviderAttributeDescriptions"; - - public ACLFileAccessControlProviderFactory() - { - super(ACLFileAccessControlProviderImpl.class); - } - - @Override - public Map<String, String> getAttributeDescriptions() - { - return ResourceBundleLoader.getResources(RESOURCE_BUNDLE); - } - - @Override - public ACLFileAccessControlProviderImpl createInstance(final Map<String, Object> attributes, - final ConfiguredObject<?>... parents) - { - return new ACLFileAccessControlProviderImpl(attributes, getParent(Broker.class,parents)); - } - -} diff --git a/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java b/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java index c3ce92f5b1..554f2f46c5 100644 --- a/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java +++ b/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java @@ -35,8 +35,8 @@ import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.IllegalStateTransitionException; import org.apache.qpid.server.model.ManagedAttributeField; +import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.State; -import org.apache.qpid.server.plugin.AccessControlProviderFactory; import org.apache.qpid.server.security.AccessControl; import org.apache.qpid.server.security.access.Operation; import org.apache.qpid.server.util.MapValueConverter; @@ -50,12 +50,12 @@ public class ACLFileAccessControlProviderImpl protected DefaultAccessControl _accessControl; protected final Broker _broker; - protected Map<String, AccessControlProviderFactory> _factories; private AtomicReference<State> _state; @ManagedAttributeField private String _path; + @ManagedObjectFactoryConstructor public ACLFileAccessControlProviderImpl(Map<String, Object> attributes, Broker broker) { super(parentsMap(broker), attributes); diff --git a/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/FileAccessControlProviderAttributeDescriptions.properties b/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/FileAccessControlProviderAttributeDescriptions.properties deleted file mode 100644 index e847e90f57..0000000000 --- a/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/FileAccessControlProviderAttributeDescriptions.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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. - -path=File location*
\ No newline at end of file diff --git a/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java b/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java index fab6ad1750..01da01eb97 100644 --- a/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java +++ b/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java @@ -33,9 +33,7 @@ import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.model.AccessControlProvider; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.BrokerModel; -import org.apache.qpid.server.model.ConfiguredObjectFactory; import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl; -import org.apache.qpid.server.model.GroupProvider; import org.apache.qpid.server.security.access.FileAccessControlProviderConstants; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.test.utils.TestFileUtils; @@ -43,28 +41,30 @@ import org.apache.qpid.test.utils.TestFileUtils; public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase { private Broker _broker; + private ConfiguredObjectFactoryImpl _objectFactory; @Override public void setUp() throws Exception { super.setUp(); _broker = mock(Broker.class); - ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance()); + _objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance()); - when(_broker.getObjectFactory()).thenReturn(objectFactory); - when(_broker.getModel()).thenReturn(objectFactory.getModel()); + when(_broker.getObjectFactory()).thenReturn(_objectFactory); + when(_broker.getModel()).thenReturn(_objectFactory.getModel()); when(_broker.getCategoryClass()).thenReturn(Broker.class); } public void testCreateInstanceWhenAclFileIsNotPresent() { - ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory(); Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AccessControlProvider.ID, UUID.randomUUID()); attributes.put(AccessControlProvider.NAME, "acl"); + attributes.put(AccessControlProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE); + try { - AccessControlProvider acl = factory.create(null, attributes, _broker); + AccessControlProvider acl = _objectFactory.create(AccessControlProvider.class, attributes, _broker); fail("ACL was created without a configuration file path specified"); } catch(IllegalArgumentException e) @@ -73,16 +73,16 @@ public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase } } + public void testCreateInstanceWhenAclFileIsSpecified() { File aclFile = TestFileUtils.createTempFile(this, ".acl", "ACL ALLOW all all"); - ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory(); Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AccessControlProvider.ID, UUID.randomUUID()); attributes.put(AccessControlProvider.NAME, "acl"); - attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE); + attributes.put(AccessControlProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE); attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath()); - AccessControlProvider acl = factory.create(null, attributes, _broker); + AccessControlProvider acl = _objectFactory.create(AccessControlProvider.class, attributes, _broker); acl.getAccessControl().open(); assertNotNull("ACL was not created from acl file: " + aclFile.getAbsolutePath(), acl); @@ -92,15 +92,14 @@ public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase { File aclFile = new File(TMP_FOLDER, "my-non-existing-acl-" + System.currentTimeMillis()); assertFalse("ACL file " + aclFile.getAbsolutePath() + " actually exists but should not", aclFile.exists()); - ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory(); Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AccessControlProvider.ID, UUID.randomUUID()); attributes.put(AccessControlProvider.NAME, "acl"); - attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE); + attributes.put(AccessControlProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE); attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath()); try { - AccessControlProvider control = factory.create(null, attributes, _broker); + AccessControlProvider control = _objectFactory.create(AccessControlProvider.class, attributes, _broker); control.getAccessControl().open(); fail("It should not be possible to create and initialise ACL with non existing file"); } diff --git a/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java b/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java index 523640adad..0ce2555bcf 100644 --- a/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java +++ b/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java @@ -192,7 +192,7 @@ public class RuleSetTest extends QpidTestCase ExchangeImpl<?> exchange = mock(ExchangeImpl.class); when(exchange.getParent(VirtualHost.class)).thenReturn(_virtualHost); - when(exchange.getTypeName()).thenReturn(_exchangeType); + when(exchange.getType()).thenReturn(_exchangeType); when(_virtualHost.getName()).thenReturn(ALLOWED_VH); assertEquals(Result.ALLOWED, _ruleSet.check(_testSubject, Operation.CREATE, ObjectType.EXCHANGE, new ObjectProperties(exchange))); diff --git a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java index db94249c64..af1bd00ae9 100644 --- a/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java +++ b/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java @@ -32,10 +32,9 @@ import java.util.UUID; import org.apache.log4j.Logger; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.server.consumer.ConsumerImpl; -import org.apache.qpid.server.exchange.DirectExchange; import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.exchange.HeadersExchange; import org.apache.qpid.server.filter.AMQInvalidArgumentException; import org.apache.qpid.server.filter.FilterManager; import org.apache.qpid.server.filter.FilterManagerFactory; @@ -49,7 +48,6 @@ import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.NoFactoryForTypeException; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.UnknownConfiguredObjectException; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueArgumentsConverter; import org.apache.qpid.server.store.DurableConfigurationStore; @@ -694,11 +692,11 @@ public class ServerSessionDelegate extends SessionDelegate if(nameNullOrEmpty(method.getExchange())) { // special case handling to fake the existence of the default exchange for 0-10 - if(!DirectExchange.TYPE.getType().equals(method.getType())) + if(!ExchangeDefaults.DIRECT_EXCHANGE_CLASS.equals(method.getType())) { exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare default exchange " - + " of type " + DirectExchange.TYPE.getType() + + " of type " + ExchangeDefaults.DIRECT_EXCHANGE_CLASS + " to " + method.getType() +"."); } if(!nameNullOrEmpty(method.getAlternateExchange())) @@ -721,11 +719,11 @@ public class ServerSessionDelegate extends SessionDelegate } else { - if (!exchange.getTypeName().equals(method.getType()) + if (!exchange.getType().equals(method.getType()) && (method.getType() != null && method.getType().length() > 0)) { exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare exchange: " - + exchangeName + " of type " + exchange.getTypeName() + " to " + method.getType() + "."); + + exchangeName + " of type " + exchange.getType() + " to " + method.getType() + "."); } } } @@ -762,11 +760,11 @@ public class ServerSessionDelegate extends SessionDelegate catch(ExchangeExistsException e) { ExchangeImpl exchange = e.getExistingExchange(); - if(!exchange.getTypeName().equals(method.getType())) + if(!exchange.getType().equals(method.getType())) { exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare exchange: " + exchangeName - + " of type " + exchange.getTypeName() + + " of type " + exchange.getType() + " to " + method.getType() +"."); } else if(method.hasAlternateExchange() @@ -887,18 +885,6 @@ public class ServerSessionDelegate extends SessionDelegate return false; } - private boolean isStandardExchange(ExchangeImpl exchange, Collection<ExchangeType<? extends ExchangeImpl>> registeredTypes) - { - for(ExchangeType type : registeredTypes) - { - if(type.getDefaultExchangeName().equals( exchange.getName() )) - { - return true; - } - } - return false; - } - @Override public void exchangeQuery(Session session, ExchangeQuery method) { @@ -912,7 +898,7 @@ public class ServerSessionDelegate extends SessionDelegate { // Fake the existence of the "default" exchange for 0-10 result.setDurable(true); - result.setType(DirectExchange.TYPE.getType()); + result.setType(ExchangeDefaults.DIRECT_EXCHANGE_CLASS); result.setNotFound(false); } else @@ -922,7 +908,7 @@ public class ServerSessionDelegate extends SessionDelegate if(exchange != null) { result.setDurable(exchange.isDurable()); - result.setType(exchange.getTypeName()); + result.setType(exchange.getType()); result.setNotFound(false); } else @@ -968,9 +954,9 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, ExecutionErrorCode.NOT_FOUND, "Exchange: '" + exchangeName + "' not found"); } - else if(exchange.getExchangeType().equals(HeadersExchange.TYPE) && (!method.hasArguments() || method.getArguments() == null || !method.getArguments().containsKey("x-match"))) + else if(exchange.getType().equals(ExchangeDefaults.HEADERS_EXCHANGE_CLASS) && (!method.hasArguments() || method.getArguments() == null || !method.getArguments().containsKey("x-match"))) { - exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, "Bindings to an exchange of type " + HeadersExchange.TYPE.getType() + " require an x-match header"); + exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, "Bindings to an exchange of type " + ExchangeDefaults.HEADERS_EXCHANGE_CLASS + " require an x-match header"); } else { diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java index 73b53c5e64..aaf88c81d5 100644 --- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java +++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java @@ -28,12 +28,12 @@ import org.apache.log4j.Logger; import org.apache.qpid.AMQConnectionException; import org.apache.qpid.AMQException; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.ExchangeDeclareBody; import org.apache.qpid.framing.MethodRegistry; import org.apache.qpid.protocol.AMQConstant; -import org.apache.qpid.server.exchange.DirectExchange; import org.apache.qpid.server.exchange.ExchangeImpl; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.NoFactoryForTypeException; @@ -81,11 +81,11 @@ public class ExchangeDeclareHandler implements StateAwareMethodListener<Exchange if(isDefaultExchange(exchangeName)) { - if(!new AMQShortString(DirectExchange.TYPE.getType()).equals(body.getType())) + if(!new AMQShortString(ExchangeDefaults.DIRECT_EXCHANGE_CLASS).equals(body.getType())) { throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare default exchange: " + " of type " - + DirectExchange.TYPE.getType() + + ExchangeDefaults.DIRECT_EXCHANGE_CLASS + " to " + body.getType() +".", body.getClazz(), body.getMethod(), body.getMajor(), body.getMinor(),null); @@ -100,11 +100,11 @@ public class ExchangeDeclareHandler implements StateAwareMethodListener<Exchange { throw body.getChannelException(AMQConstant.NOT_FOUND, "Unknown exchange: " + exchangeName); } - else if (!(body.getType() == null || body.getType().length() ==0) && !exchange.getTypeName().equals(body.getType().asString())) + else if (!(body.getType() == null || body.getType().length() ==0) && !exchange.getType().equals(body.getType().asString())) { throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " + - exchangeName + " of type " + exchange.getTypeName() + exchangeName + " of type " + exchange.getType() + " to " + body.getType() +".",body.getClazz(), body.getMethod(),body.getMajor(),body.getMinor(),null); } @@ -137,11 +137,11 @@ public class ExchangeDeclareHandler implements StateAwareMethodListener<Exchange catch(ExchangeExistsException e) { exchange = e.getExistingExchange(); - if(!new AMQShortString(exchange.getTypeName()).equals(body.getType())) + if(!new AMQShortString(exchange.getType()).equals(body.getType())) { throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " + exchangeName + " of type " - + exchange.getTypeName() + + exchange.getType() + " to " + body.getType() +".", body.getClazz(), body.getMethod(), body.getMajor(), body.getMinor(),null); diff --git a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java index e3f40c3555..0140d2ec7e 100644 --- a/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java +++ b/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java @@ -20,9 +20,13 @@ */ package org.apache.qpid.server.protocol.v0_8.handler; +import java.security.AccessControlException; +import java.util.Map; + import org.apache.log4j.Logger; import org.apache.qpid.AMQException; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.FieldTable; @@ -30,17 +34,13 @@ import org.apache.qpid.framing.MethodRegistry; import org.apache.qpid.framing.QueueBindBody; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.exchange.TopicExchange; import org.apache.qpid.server.protocol.v0_8.AMQChannel; import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; -import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.virtualhost.VirtualHostImpl; -import java.security.AccessControlException; -import java.util.Map; - public class QueueBindHandler implements StateAwareMethodListener<QueueBindBody> { private static final Logger _log = Logger.getLogger(QueueBindHandler.class); @@ -125,7 +125,7 @@ public class QueueBindHandler implements StateAwareMethodListener<QueueBindBody> if (!exch.isBound(bindingKey, arguments, queue)) { - if(!exch.addBinding(bindingKey, queue, arguments) && TopicExchange.TYPE.equals(exch.getExchangeType())) + if(!exch.addBinding(bindingKey, queue, arguments) && ExchangeDefaults.TOPIC_EXCHANGE_CLASS.equals(exch.getType())) { exch.replaceBinding(bindingKey, queue, arguments); } diff --git a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java index f6823824fd..7a844cbc79 100644 --- a/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java +++ b/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java @@ -58,13 +58,12 @@ import org.apache.qpid.amqp_1_0.type.transport.AmqpError; import org.apache.qpid.amqp_1_0.type.transport.Detach; import org.apache.qpid.amqp_1_0.type.transport.Error; import org.apache.qpid.amqp_1_0.type.transport.Transfer; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.filter.SelectorParsingException; import org.apache.qpid.filter.selector.ParseException; import org.apache.qpid.server.binding.BindingImpl; import org.apache.qpid.server.consumer.ConsumerImpl; -import org.apache.qpid.server.exchange.DirectExchange; import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.exchange.TopicExchange; import org.apache.qpid.server.filter.JMSSelectorFilter; import org.apache.qpid.server.filter.SimpleFilterManager; import org.apache.qpid.server.message.MessageInstance; @@ -259,7 +258,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS { if(!hasBindingFilter && entry.getValue() instanceof ExactSubjectFilter - && exchange.getExchangeType() == DirectExchange.TYPE) + && exchange.getType().equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS)) { ExactSubjectFilter filter = (ExactSubjectFilter) filters.values().iterator().next(); source.setFilter(filters); @@ -269,7 +268,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS } else if(!hasBindingFilter && entry.getValue() instanceof MatchingSubjectFilter - && exchange.getExchangeType() == TopicExchange.TYPE) + && exchange.getType().equals(ExchangeDefaults.TOPIC_EXCHANGE_CLASS)) { MatchingSubjectFilter filter = (MatchingSubjectFilter) filters.values().iterator().next(); source.setFilter(filters); diff --git a/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java b/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java index e9fe0b59fa..69479b73d6 100644 --- a/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java +++ b/java/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java @@ -115,7 +115,7 @@ public class MessageConverter_0_10_to_0_8 implements MessageConverter<MessageTra ExchangeImpl exchange = vhost.getExchange(exchangeName); String exchangeClass = exchange == null ? ExchangeDefaults.DIRECT_EXCHANGE_CLASS - : exchange.getTypeName(); + : exchange.getType(); props.setReplyTo(exchangeClass + "://" + exchangeName + "//?routingkey='" + (routingKey == null ? "" : routingKey + "'")); diff --git a/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java b/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java index 0bd1cf27dc..8f43cdf9ef 100644 --- a/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java +++ b/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java @@ -50,9 +50,9 @@ import org.apache.qpid.server.message.MessageSource; import org.apache.qpid.server.message.ServerMessage; import org.apache.qpid.server.message.internal.InternalMessage; import org.apache.qpid.server.message.internal.InternalMessageHeader; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.ConfigurationChangeListener; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.State; import org.apache.qpid.server.plugin.MessageConverter; @@ -235,7 +235,7 @@ class ManagementNode implements MessageSource, MessageDestination } } managedEntityType = new ManagedEntityType(clazz.getName(), parentSet.toArray(new ManagedEntityType[parentSet.size()]), - (String[])(AbstractConfiguredObject.getAttributeNames( + (String[])(ConfiguredObjectTypeRegistry.getAttributeNames( clazz).toArray(new String[0])), opsList.toArray(new String[opsList.size()])); _entityTypes.put(clazz.getName(),managedEntityType); diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java index 0ed97ac3a0..1937ee8744 100644 --- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementUtil.java @@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.codec.binary.Base64; + import org.apache.qpid.server.management.plugin.servlet.ServletConnectionPrincipal; import org.apache.qpid.server.management.plugin.session.LoginLogoutReporter; import org.apache.qpid.server.model.AuthenticationProvider; @@ -44,7 +45,7 @@ import org.apache.qpid.server.security.auth.AuthenticatedPrincipal; import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus; import org.apache.qpid.server.security.auth.SubjectAuthenticationResult; import org.apache.qpid.server.security.auth.UsernamePrincipal; -import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManager; import org.apache.qpid.transport.network.security.ssl.SSLUtil; public class HttpManagementUtil @@ -162,7 +163,7 @@ public class HttpManagementUtil { principal = certificates[0].getSubjectX500Principal(); - if(!Boolean.valueOf(String.valueOf(authenticationProvider.getAttribute(ExternalAuthenticationManagerFactory.ATTRIBUTE_USE_FULL_DN)))) + if(!Boolean.valueOf(String.valueOf(authenticationProvider.getAttribute(ExternalAuthenticationManager.ATTRIBUTE_USE_FULL_DN)))) { String username; String dn = ((X500Principal) principal).getName(X500Principal.RFC2253); diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/AbstractSpecialisedAttributeLister.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/AbstractSpecialisedAttributeLister.java new file mode 100644 index 0000000000..173e4fce66 --- /dev/null +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/AbstractSpecialisedAttributeLister.java @@ -0,0 +1,77 @@ +/* + * + * 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.management.plugin.servlet.rest.action; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.apache.qpid.server.management.plugin.servlet.rest.Action; +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; + +abstract class AbstractSpecialisedAttributeLister<T extends ConfiguredObject> implements Action +{ + + + private static final String ATTRIBUTES = "attributes"; + private static final String DESCRIPTIONS = "descriptions"; + + @Override + final public Object perform(Map<String, Object> request, Broker broker) + { + Collection<Class<? extends ConfiguredObject>> groupProviderTypes = + ConfiguredObjectTypeRegistry.getTypeSpecialisations(getCategoryClass()); + + Map<String, Object> attributes = new TreeMap<String, Object>(); + + for (Class<? extends ConfiguredObject> groupProviderType : groupProviderTypes) + { + Collection<ConfiguredObjectAttribute<?, ?>> typeSpecificAttributes = + ConfiguredObjectTypeRegistry.getTypeSpecificAttributes(groupProviderType); + + Map<String, Object> data = new HashMap<String, Object>(); + + Collection<String> attributeNames = new TreeSet<>(); + Map<String,String> descriptions = new HashMap<>(); + for(ConfiguredObjectAttribute<?, ?> attr : typeSpecificAttributes) + { + attributeNames.add(attr.getName()); + if(!"".equals(attr.getAnnotation().description())) + { + descriptions.put(attr.getName(), attr.getAnnotation().description()); + } + } + data.put(ATTRIBUTES, attributeNames); + data.put(DESCRIPTIONS, descriptions); + + attributes.put(ConfiguredObjectTypeRegistry.getType(groupProviderType), data); + } + return attributes; + } + + abstract Class<T> getCategoryClass(); + +} diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java index 84d05997b5..1eb3f9a9ac 100644 --- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAccessControlProviderAttributes.java @@ -20,32 +20,10 @@ */ package org.apache.qpid.server.management.plugin.servlet.rest.action; -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; +import org.apache.qpid.server.model.AccessControlProvider; -import org.apache.qpid.server.management.plugin.servlet.rest.Action; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.plugin.AccessControlProviderFactory; -import org.apache.qpid.server.plugin.QpidServiceLoader; - -public class ListAccessControlProviderAttributes implements Action +public class ListAccessControlProviderAttributes extends AbstractSpecialisedAttributeLister<AccessControlProvider> { - private static final String ATTRIBUTES = "attributes"; - private static final String DESCRIPTIONS = "descriptions"; - private Map<String, AccessControlProviderFactory> _factories; - - public ListAccessControlProviderAttributes() - { - _factories = new TreeMap<String, AccessControlProviderFactory>(); - Iterable<AccessControlProviderFactory> factories = new QpidServiceLoader<AccessControlProviderFactory>() - .instancesOf(AccessControlProviderFactory.class); - for (AccessControlProviderFactory factory : factories) - { - _factories.put(factory.getType(), factory); - } - } - @Override public String getName() { @@ -53,25 +31,8 @@ public class ListAccessControlProviderAttributes implements Action } @Override - public Object perform(Map<String, Object> request, Broker broker) + Class<AccessControlProvider> getCategoryClass() { - Map<String, Object> attributes = new TreeMap<String, Object>(); - for (String providerType : _factories.keySet()) - { - AccessControlProviderFactory<?> factory = _factories.get(providerType); - - Map<String, Object> data = new HashMap<String, Object>(); - // TODO RG - fix - // data.put(ATTRIBUTES, factory.getAttributeNames()); - Map<String, String> resources = factory.getAttributeDescriptions(); - if (resources != null) - { - data.put(DESCRIPTIONS, resources); - } - - attributes.put(factory.getType(), data); - } - return attributes; + return AccessControlProvider.class; } - } diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java index 5c629587e0..3e006a705a 100644 --- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java @@ -20,32 +20,10 @@ */ package org.apache.qpid.server.management.plugin.servlet.rest.action; -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; +import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.management.plugin.servlet.rest.Action; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.plugin.AuthenticationManagerFactory; -import org.apache.qpid.server.plugin.QpidServiceLoader; - -public class ListAuthenticationProviderAttributes implements Action +public class ListAuthenticationProviderAttributes extends AbstractSpecialisedAttributeLister<AuthenticationProvider> { - private static final String ATTRIBUTES = "attributes"; - private static final String DESCRIPTIONS = "descriptions"; - private Map<String, AuthenticationManagerFactory> _factories; - - public ListAuthenticationProviderAttributes() - { - _factories = new TreeMap<String, AuthenticationManagerFactory>(); - Iterable<AuthenticationManagerFactory> factories = new QpidServiceLoader<AuthenticationManagerFactory>() - .instancesOf(AuthenticationManagerFactory.class); - for (AuthenticationManagerFactory factory : factories) - { - _factories.put(factory.getType(), factory); - } - } - @Override public String getName() { @@ -53,24 +31,8 @@ public class ListAuthenticationProviderAttributes implements Action } @Override - public Object perform(Map<String, Object> request, Broker broker) + Class<AuthenticationProvider> getCategoryClass() { - Map<String, Object> attributes = new TreeMap<String, Object>(); - for (String providerType : _factories.keySet()) - { - AuthenticationManagerFactory factory = _factories.get(providerType); - - Map<String, Object> data = new HashMap<String, Object>(); - data.put(ATTRIBUTES, factory.getAttributeNames()); - Map<String, String> resources = factory.getAttributeDescriptions(); - if (resources != null) - { - data.put(DESCRIPTIONS, resources); - } - - attributes.put(factory.getType(), data); - } - return attributes; + return AuthenticationProvider.class; } - } diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java index d1414faa71..ecb4320f1f 100644 --- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListGroupProviderAttributes.java @@ -20,32 +20,10 @@ */ package org.apache.qpid.server.management.plugin.servlet.rest.action; -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; +import org.apache.qpid.server.model.GroupProvider; -import org.apache.qpid.server.management.plugin.servlet.rest.Action; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.plugin.GroupManagerFactory; -import org.apache.qpid.server.plugin.QpidServiceLoader; - -public class ListGroupProviderAttributes implements Action +public class ListGroupProviderAttributes extends AbstractSpecialisedAttributeLister<GroupProvider> { - private static final String ATTRIBUTES = "attributes"; - private static final String DESCRIPTIONS = "descriptions"; - private Map<String, GroupManagerFactory> _factories; - - public ListGroupProviderAttributes() - { - _factories = new TreeMap<String, GroupManagerFactory>(); - Iterable<GroupManagerFactory> factories = new QpidServiceLoader<GroupManagerFactory>() - .instancesOf(GroupManagerFactory.class); - for (GroupManagerFactory factory : factories) - { - _factories.put(factory.getType(), factory); - } - } - @Override public String getName() { @@ -53,24 +31,8 @@ public class ListGroupProviderAttributes implements Action } @Override - public Object perform(Map<String, Object> request, Broker broker) + Class<GroupProvider> getCategoryClass() { - Map<String, Object> attributes = new TreeMap<String, Object>(); - for (String providerType : _factories.keySet()) - { - GroupManagerFactory factory = _factories.get(providerType); - - Map<String, Object> data = new HashMap<String, Object>(); - data.put(ATTRIBUTES, factory.getAttributeNames()); - Map<String, String> resources = factory.getAttributeDescriptions(); - if (resources != null) - { - data.put(DESCRIPTIONS, resources); - } - - attributes.put(factory.getType(), data); - } - return attributes; + return GroupProvider.class; } - } diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java index 31888167af..1faacbb079 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java @@ -34,7 +34,7 @@ import org.apache.qpid.server.management.plugin.HttpManagement; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Plugin; import org.apache.qpid.server.model.Port; -import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager; import org.apache.qpid.systest.rest.RestTestHelper; import org.apache.qpid.test.utils.TestBrokerConfiguration; @@ -159,7 +159,7 @@ public class AlertingTest extends AbstractTestLogging config.removeObjectConfiguration(Port.class, TestBrokerConfiguration.ENTRY_NAME_RMI_PORT); Map<String, Object> anonymousProviderAttributes = new HashMap<String, Object>(); - anonymousProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + anonymousProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); anonymousProviderAttributes.put(AuthenticationProvider.NAME, "testAnonymous"); config.addObjectConfiguration(AuthenticationProvider.class, anonymousProviderAttributes); diff --git a/java/systests/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationTest.java b/java/systests/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationTest.java index e58fa0c45d..0d0c1257a2 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationTest.java @@ -284,7 +284,7 @@ public class ExternalAuthenticationTest extends QpidBrokerTestCase JMXTestUtils jmxUtils = new JMXTestUtils(this); setCommonBrokerSSLProperties(true); - getBrokerConfiguration().setObjectAttribute(AuthenticationProvider.class, TestBrokerConfiguration.ENTRY_NAME_EXTERNAL_PROVIDER, ExternalAuthenticationManagerFactory.ATTRIBUTE_USE_FULL_DN, "true"); + getBrokerConfiguration().setObjectAttribute(AuthenticationProvider.class, TestBrokerConfiguration.ENTRY_NAME_EXTERNAL_PROVIDER, ExternalAuthenticationManager.ATTRIBUTE_USE_FULL_DN, "true"); getBrokerConfiguration().addJmxManagementConfiguration(); super.setUp(); @@ -348,7 +348,7 @@ public class ExternalAuthenticationTest extends QpidBrokerTestCase Map<String, Object> externalAuthProviderAttributes = new HashMap<String, Object>(); externalAuthProviderAttributes.put(AuthenticationProvider.NAME, TestBrokerConfiguration.ENTRY_NAME_EXTERNAL_PROVIDER); - externalAuthProviderAttributes.put(AuthenticationProvider.TYPE, ExternalAuthenticationManagerFactory.PROVIDER_TYPE); + externalAuthProviderAttributes.put(AuthenticationProvider.TYPE, ExternalAuthenticationManager.PROVIDER_TYPE); config.addObjectConfiguration(AuthenticationProvider.class, externalAuthProviderAttributes); config.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_SSL_PORT, Port.AUTHENTICATION_PROVIDER, TestBrokerConfiguration.ENTRY_NAME_EXTERNAL_PROVIDER); diff --git a/java/systests/src/main/java/org/apache/qpid/server/security/auth/manager/MultipleAuthenticationManagersTest.java b/java/systests/src/main/java/org/apache/qpid/server/security/auth/manager/MultipleAuthenticationManagersTest.java index ae5785ba89..1c32a3f671 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/security/auth/manager/MultipleAuthenticationManagersTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/security/auth/manager/MultipleAuthenticationManagersTest.java @@ -48,7 +48,7 @@ public class MultipleAuthenticationManagersTest extends QpidBrokerTestCase TestBrokerConfiguration config = getBrokerConfiguration(); Map<String, Object> externalAuthProviderAttributes = new HashMap<String, Object>(); - externalAuthProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + externalAuthProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); externalAuthProviderAttributes.put(AuthenticationProvider.NAME, TestBrokerConfiguration.ENTRY_NAME_ANONYMOUS_PROVIDER); config.addObjectConfiguration(AuthenticationProvider.class, externalAuthProviderAttributes); diff --git a/java/systests/src/main/java/org/apache/qpid/server/store/VirtualHostMessageStoreTest.java b/java/systests/src/main/java/org/apache/qpid/server/store/VirtualHostMessageStoreTest.java index 06f03faa37..32f936983f 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/store/VirtualHostMessageStoreTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/store/VirtualHostMessageStoreTest.java @@ -20,7 +20,6 @@ */ package org.apache.qpid.server.store; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.File; @@ -31,6 +30,7 @@ import java.util.Map; import java.util.UUID; import org.apache.qpid.common.AMQPFilterTypes; +import org.apache.qpid.exchange.ExchangeDefaults; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.BasicContentHeaderProperties; import org.apache.qpid.framing.ContentHeaderBody; @@ -39,9 +39,7 @@ import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.framing.amqp_8_0.BasicConsumeBodyImpl; import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.configuration.updater.TaskExecutorImpl; -import org.apache.qpid.server.exchange.DirectExchange; import org.apache.qpid.server.exchange.ExchangeImpl; -import org.apache.qpid.server.exchange.TopicExchange; import org.apache.qpid.server.message.InstanceProperties; import org.apache.qpid.server.message.MessageSource; import org.apache.qpid.server.model.Binding; @@ -54,7 +52,6 @@ import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.UUIDGenerator; import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.protocol.v0_8.AMQMessage; import org.apache.qpid.server.protocol.v0_8.MessageMetaData; import org.apache.qpid.server.queue.AMQQueue; @@ -176,15 +173,15 @@ public class VirtualHostMessageStoreTest extends QpidTestCase createAllTopicQueues(); //Register Non-Durable DirectExchange - ExchangeImpl<?> nonDurableExchange = createExchange(DirectExchange.TYPE, nonDurableExchangeName, false); + ExchangeImpl<?> nonDurableExchange = createExchange(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, nonDurableExchangeName, false); bindAllQueuesToExchange(nonDurableExchange, directRouting); //Register DirectExchange - ExchangeImpl<?> directExchange = createExchange(DirectExchange.TYPE, directExchangeName, true); + ExchangeImpl<?> directExchange = createExchange(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, directExchangeName, true); bindAllQueuesToExchange(directExchange, directRouting); //Register TopicExchange - ExchangeImpl<?> topicExchange = createExchange(TopicExchange.TYPE, topicExchangeName, true); + ExchangeImpl<?> topicExchange = createExchange(ExchangeDefaults.TOPIC_EXCHANGE_CLASS, topicExchangeName, true); bindAllTopicQueuesToExchange(topicExchange, topicRouting); //Send Message To NonDurable direct Exchange = persistent @@ -344,7 +341,7 @@ public class VirtualHostMessageStoreTest extends QpidTestCase { int origExchangeCount = _virtualHost.getExchanges().size(); - createExchange(DirectExchange.TYPE, directExchangeName, true); + createExchange(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, directExchangeName, true); assertEquals("Incorrect number of exchanges registered before recovery", origExchangeCount + 1, _virtualHost.getExchanges().size()); @@ -408,7 +405,7 @@ public class VirtualHostMessageStoreTest extends QpidTestCase public void testDurableBindingRemoval() throws Exception { //create durable queue and exchange, bind them - ExchangeImpl<?> exch = createExchange(DirectExchange.TYPE, directExchangeName, true); + ExchangeImpl<?> exch = createExchange(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, directExchangeName, true); createQueue(durableQueueName, false, true, false, false); bindQueueToExchange(exch, directRouting, _virtualHost.getQueue(durableQueueName), false); @@ -670,23 +667,23 @@ public class VirtualHostMessageStoreTest extends QpidTestCase Map<String, ExchangeImpl<?>> exchanges = new HashMap<String, ExchangeImpl<?>>(); //Register non-durable DirectExchange - exchanges.put(nonDurableExchangeName, createExchange(DirectExchange.TYPE, nonDurableExchangeName, false)); + exchanges.put(nonDurableExchangeName, createExchange(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, nonDurableExchangeName, false)); //Register durable DirectExchange and TopicExchange - exchanges.put(directExchangeName ,createExchange(DirectExchange.TYPE, directExchangeName, true)); - exchanges.put(topicExchangeName,createExchange(TopicExchange.TYPE, topicExchangeName, true)); + exchanges.put(directExchangeName ,createExchange(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, directExchangeName, true)); + exchanges.put(topicExchangeName,createExchange(ExchangeDefaults.TOPIC_EXCHANGE_CLASS, topicExchangeName, true)); return exchanges; } - private ExchangeImpl<?> createExchange(ExchangeType<?> type, String name, boolean durable) throws Exception + private ExchangeImpl<?> createExchange(String type, String name, boolean durable) throws Exception { ExchangeImpl<?> exchange = null; Map<String,Object> attributes = new HashMap<String, Object>(); attributes.put(org.apache.qpid.server.model.Exchange.NAME, name); - attributes.put(org.apache.qpid.server.model.Exchange.TYPE, type.getType()); + attributes.put(org.apache.qpid.server.model.Exchange.TYPE, type); attributes.put(org.apache.qpid.server.model.Exchange.DURABLE, durable); attributes.put(org.apache.qpid.server.model.Exchange.LIFETIME_POLICY, durable ? LifetimePolicy.DELETE_ON_NO_LINKS : LifetimePolicy.PERMANENT); diff --git a/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementTest.java b/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementTest.java index 922fb69845..25b09f04c3 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementTest.java @@ -31,7 +31,7 @@ import javax.jms.JMSException; import org.apache.qpid.management.common.mbeans.UserManagement; import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.security.auth.manager.PlainPasswordFileAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.PlainPasswordDatabaseAuthenticationManager; import org.apache.qpid.test.utils.JMXTestUtils; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.apache.qpid.test.utils.TestBrokerConfiguration; @@ -175,7 +175,7 @@ public class UserManagementTest extends QpidBrokerTestCase protected String getAuthenticationManagerType() { - return PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE; + return PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE; } private File createTemporaryPasswordFileWithJmxAdminUser() throws Exception diff --git a/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementWithBase64MD5PasswordsTest.java b/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementWithBase64MD5PasswordsTest.java index 1423bc557e..ff441169b3 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementWithBase64MD5PasswordsTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementWithBase64MD5PasswordsTest.java @@ -18,7 +18,7 @@ */ package org.apache.qpid.systest.management.jmx; -import org.apache.qpid.server.security.auth.manager.Base64MD5PasswordFileAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.Base64MD5PasswordDatabaseAuthenticationManager; import org.apache.qpid.tools.security.Passwd; public class UserManagementWithBase64MD5PasswordsTest extends UserManagementTest @@ -32,6 +32,6 @@ public class UserManagementWithBase64MD5PasswordsTest extends UserManagementTest @Override protected String getAuthenticationManagerType() { - return Base64MD5PasswordFileAuthenticationManagerFactory.PROVIDER_TYPE; + return Base64MD5PasswordDatabaseAuthenticationManager.PROVIDER_TYPE; } } diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java index 79406cc81e..adbd8d6821 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/AnonymousAccessRestTest.java @@ -29,7 +29,7 @@ import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.Plugin; import org.apache.qpid.server.model.Port; -import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager; import org.apache.qpid.test.utils.TestBrokerConfiguration; public class AnonymousAccessRestTest extends QpidRestTestCase @@ -52,7 +52,7 @@ public class AnonymousAccessRestTest extends QpidRestTestCase TestBrokerConfiguration config = getBrokerConfiguration(); Map<String, Object> anonymousAuthProviderAttributes = new HashMap<String, Object>(); - anonymousAuthProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + anonymousAuthProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); anonymousAuthProviderAttributes.put(AuthenticationProvider.NAME, TestBrokerConfiguration.ENTRY_NAME_ANONYMOUS_PROVIDER); config.addObjectConfiguration(AuthenticationProvider.class, anonymousAuthProviderAttributes); diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java index ac3c9251f7..cccf94c739 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java @@ -31,10 +31,10 @@ import java.util.Map; import javax.jms.JMSException; import org.apache.qpid.client.AMQConnection; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.Binding; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; import org.apache.qpid.server.model.Connection; import org.apache.qpid.server.model.Exchange; import org.apache.qpid.server.model.ExclusivityPolicy; @@ -56,7 +56,7 @@ public class Asserts { assertNotNull("Virtualhost " + virtualHostName + " data are not found", virtualHost); assertAttributesPresent(virtualHost, - AbstractConfiguredObject.getAttributeNames(VirtualHost.class), + ConfiguredObjectTypeRegistry.getAttributeNames(VirtualHost.class), ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, @@ -105,7 +105,7 @@ public class Asserts { assertNotNull("Queue " + queueName + " is not found!", queueData); Asserts.assertAttributesPresent(queueData, - AbstractConfiguredObject.getAttributeNames(Queue.class), + ConfiguredObjectTypeRegistry.getAttributeNames(Queue.class), Queue.CREATED_BY, Queue.CREATED_TIME, Queue.LAST_UPDATED_BY, @@ -211,7 +211,7 @@ public class Asserts { assertNotNull("Unexpected connection data", connectionData); assertAttributesPresent(connectionData, - AbstractConfiguredObject.getAttributeNames(Connection.class), + ConfiguredObjectTypeRegistry.getAttributeNames(Connection.class), Connection.STATE, Connection.DURABLE, Connection.LIFETIME_POLICY, @@ -271,7 +271,7 @@ public class Asserts if ("AMQP".equals(port.get(ConfiguredObject.TYPE))) { assertAttributesPresent(port, - AbstractConfiguredObject.getAttributeNames(Port.class), + ConfiguredObjectTypeRegistry.getAttributeNames(Port.class), ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, @@ -288,7 +288,7 @@ public class Asserts else { assertAttributesPresent(port, - AbstractConfiguredObject.getAttributeNames(Port.class), + ConfiguredObjectTypeRegistry.getAttributeNames(Port.class), ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, @@ -325,7 +325,7 @@ public class Asserts public static void assertExchange(String exchangeName, String type, Map<String, Object> exchangeData) { assertNotNull("Exchange " + exchangeName + " is not found!", exchangeData); - assertAttributesPresent(exchangeData, AbstractConfiguredObject.getAttributeNames(Exchange.class), + assertAttributesPresent(exchangeData, ConfiguredObjectTypeRegistry.getAttributeNames(Exchange.class), Exchange.ALTERNATE_EXCHANGE, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, @@ -360,7 +360,7 @@ public class Asserts { assertNotNull("Binding map should not be null", binding); assertAttributesPresent(binding, - AbstractConfiguredObject.getAttributeNames(Binding.class), + ConfiguredObjectTypeRegistry.getAttributeNames(Binding.class), Binding.STATE, ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java index 8d9f1997f0..6f4b553530 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java @@ -27,15 +27,16 @@ import java.util.Map; import java.util.UUID; import org.apache.qpid.server.BrokerOptions; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; +import org.apache.qpid.server.model.ExternalFileBasedAuthenticationManager; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.User; -import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory; -import org.apache.qpid.server.security.auth.manager.PlainPasswordFileAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager; +import org.apache.qpid.server.security.auth.manager.PlainPasswordDatabaseAuthenticationManager; import org.apache.qpid.test.utils.TestBrokerConfiguration; public class AuthenticationProviderRestTest extends QpidRestTestCase @@ -49,10 +50,10 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase for (Map<String, Object> provider : providerDetails) { boolean managesPrincipals = true; - String type = PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE; + String type = PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE; if (ANONYMOUS_AUTHENTICATION_PROVIDER.equals(provider.get(AuthenticationProvider.NAME))) { - type = AnonymousAuthenticationManagerFactory.PROVIDER_TYPE; + type = AnonymousAuthenticationManager.PROVIDER_TYPE; managesPrincipals = false; } assertProvider(managesPrincipals, type , provider); @@ -70,8 +71,8 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase String providerName = "test-provider"; Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); - attributes.put(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH, principalDatabase.getAbsolutePath()); + attributes.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); + attributes.put(ExternalFileBasedAuthenticationManager.PATH, principalDatabase.getAbsolutePath()); int responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("failed to create authentication provider", 201, responseCode); @@ -82,7 +83,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase String providerName = "test-provider"; Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); int responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("Unexpected response code", 201, responseCode); @@ -91,7 +92,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase assertNotNull("Providers details cannot be null", providerDetails); assertEquals("Unexpected number of providers", 1, providerDetails.size()); Map<String, Object> provider = providerDetails.get(0); - assertProvider(false, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE, provider); + assertProvider(false, AnonymousAuthenticationManager.PROVIDER_TYPE, provider); } public void testUpdateAuthenticationProviderIdFails() throws Exception @@ -99,7 +100,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase String providerName = "test-provider"; Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); int responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("Unexpected response code", 201, responseCode); @@ -116,7 +117,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase String providerName = "test-provider"; Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); int responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("Unexpected response code for provider creation", 201, responseCode); @@ -137,7 +138,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase List<Map<String, Object>> providerDetails = getRestTestHelper().getJsonAsList("/rest/authenticationprovider/" + providerName); assertNotNull("Providers details cannot be null", providerDetails); assertEquals("Unexpected number of providers", 1, providerDetails.size()); - assertProvider(false, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE, providerDetails.get(0)); + assertProvider(false, AnonymousAuthenticationManager.PROVIDER_TYPE, providerDetails.get(0)); } public void testDeleteOfUnusedAuthenticationProvider() throws Exception @@ -146,7 +147,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase String providerName = "test-provider"; Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); int responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("Unexpected response code for provider creation", 201, responseCode); @@ -174,9 +175,9 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase String providerName = getTestName(); Map<String, Object> attributes = new HashMap<String, Object>(); - attributes.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); + attributes.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH, file.getAbsoluteFile()); + attributes.put(ExternalFileBasedAuthenticationManager.PATH, file.getAbsoluteFile()); UUID id = config.addObjectConfiguration(AuthenticationProvider.class, attributes); config.setSaved(false); @@ -187,7 +188,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase Map<String, Object> provider = getRestTestHelper().getJsonAsSingletonList("/rest/authenticationprovider/" + providerName); assertEquals("Unexpected id", id.toString(), provider.get(AuthenticationProvider.ID)); assertEquals("Unexpected name", providerName, provider.get(AuthenticationProvider.NAME)); - assertEquals("Unexpected path", file.getAbsolutePath() , provider.get(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH)); + assertEquals("Unexpected path", file.getAbsolutePath() , provider.get(ExternalFileBasedAuthenticationManager.PATH)); assertEquals("Unexpected state", State.ERRORED.name() , provider.get(AuthenticationProvider.STATE)); int status = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "DELETE", null); @@ -212,9 +213,9 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase String providerName = getTestName(); Map<String, Object> attributes = new HashMap<String, Object>(); - attributes.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); + attributes.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH, file.getAbsoluteFile()); + attributes.put(ExternalFileBasedAuthenticationManager.PATH, file.getAbsoluteFile()); UUID id = config.addObjectConfiguration(AuthenticationProvider.class, attributes); config.setSaved(false); @@ -225,7 +226,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase Map<String, Object> provider = getRestTestHelper().getJsonAsSingletonList("/rest/authenticationprovider/" + providerName); assertEquals("Unexpected id", id.toString(), provider.get(AuthenticationProvider.ID)); assertEquals("Unexpected name", providerName, provider.get(AuthenticationProvider.NAME)); - assertEquals("Unexpected path", file.getAbsolutePath() , provider.get(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH)); + assertEquals("Unexpected path", file.getAbsolutePath() , provider.get(ExternalFileBasedAuthenticationManager.PATH)); assertEquals("Unexpected state", State.ERRORED.name() , provider.get(AuthenticationProvider.STATE)); File principalDatabase = null; @@ -235,8 +236,8 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); attributes.put(AuthenticationProvider.ID, id); - attributes.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); - attributes.put(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH, principalDatabase.getAbsolutePath()); + attributes.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); + attributes.put(ExternalFileBasedAuthenticationManager.PATH, principalDatabase.getAbsolutePath()); int status = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("ACL was not deleted", 200, status); @@ -244,7 +245,8 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase provider = getRestTestHelper().getJsonAsSingletonList("/rest/authenticationprovider/" + providerName); assertEquals("Unexpected id", id.toString(), provider.get(AuthenticationProvider.ID)); assertEquals("Unexpected name", providerName, provider.get(AuthenticationProvider.NAME)); - assertEquals("Unexpected path", principalDatabase.getAbsolutePath() , provider.get(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH)); + assertEquals("Unexpected path", principalDatabase.getAbsolutePath() , provider.get( + ExternalFileBasedAuthenticationManager.PATH)); assertEquals("Unexpected state", State.ACTIVE.name() , provider.get(AuthenticationProvider.STATE)); } finally @@ -277,8 +279,8 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase String providerName = "test-provider"; Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); - attributes.put(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH, file.getAbsolutePath()); + attributes.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); + attributes.put(ExternalFileBasedAuthenticationManager.PATH, file.getAbsolutePath()); int responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("Password provider was not created", 201, responseCode); @@ -287,8 +289,9 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase Map<String, Object> providerDetails = getRestTestHelper().getJsonAsSingletonList("/rest/authenticationprovider/" + providerName); assertNotNull("Providers details cannot be null", providerDetails); assertEquals("Unexpected name", providerName, providerDetails.get(AuthenticationProvider.NAME)); - assertEquals("Unexpected type", PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE, providerDetails.get(AuthenticationProvider.TYPE)); - assertEquals("Unexpected path", file.getAbsolutePath(), providerDetails.get(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH)); + assertEquals("Unexpected type", PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE, providerDetails.get(AuthenticationProvider.TYPE)); + assertEquals("Unexpected path", file.getAbsolutePath(), providerDetails.get( + ExternalFileBasedAuthenticationManager.PATH)); assertTrue("User file should be created", file.exists()); @@ -304,8 +307,8 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase private void assertProvider(boolean managesPrincipals, String type, Map<String, Object> provider) { - Asserts.assertAttributesPresent(provider, AbstractConfiguredObject.getAttributeNames( - AuthenticationProvider.class), + Asserts.assertAttributesPresent(provider, ConfiguredObjectTypeRegistry.getAttributeNames( + AuthenticationProvider.class), AuthenticationProvider.DESCRIPTION, ConfiguredObject.CONTEXT, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, ConfiguredObject.LAST_UPDATED_TIME); assertEquals("Unexpected value of provider attribute " + AuthenticationProvider.STATE, State.ACTIVE.name(), diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsClientCertAuthTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsClientCertAuthTest.java index 6d6223048a..e3e74c8670 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsClientCertAuthTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsClientCertAuthTest.java @@ -34,7 +34,7 @@ import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Transport; -import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManager; import org.apache.qpid.test.utils.TestBrokerConfiguration; public class BrokerRestHttpsClientCertAuthTest extends QpidRestTestCase @@ -66,7 +66,7 @@ public class BrokerRestHttpsClientCertAuthTest extends QpidRestTestCase Map<String, Object> externalProviderAttributes = new HashMap<String, Object>(); - externalProviderAttributes.put(AuthenticationProvider.TYPE, ExternalAuthenticationManagerFactory.PROVIDER_TYPE); + externalProviderAttributes.put(AuthenticationProvider.TYPE, ExternalAuthenticationManager.PROVIDER_TYPE); externalProviderAttributes.put(AuthenticationProvider.NAME, EXTERNAL_AUTHENTICATION_PROVIDER); getBrokerConfiguration().addObjectConfiguration(AuthenticationProvider.class, externalProviderAttributes); diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java index fd7dbf0831..6baf9d1109 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java @@ -28,9 +28,9 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.Transport; @@ -63,7 +63,7 @@ public class BrokerRestHttpsTest extends QpidRestTestCase { Map<String, Object> brokerDetails = getRestTestHelper().getJsonAsSingletonList("/rest/broker"); - Asserts.assertAttributesPresent(brokerDetails, AbstractConfiguredObject.getAttributeNames(Broker.class), + Asserts.assertAttributesPresent(brokerDetails, ConfiguredObjectTypeRegistry.getAttributeNames(Broker.class), Broker.PROCESS_PID, Broker.SUPPORTED_VIRTUALHOST_STORE_TYPES, ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java index b68c53739c..afd647a969 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java @@ -33,13 +33,12 @@ import javax.jms.Session; import javax.jms.TextMessage; import org.apache.qpid.common.QpidProperties; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.State; -import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.model.VirtualHostNode; import org.apache.qpid.server.plugin.MessageStoreFactory; import org.apache.qpid.test.client.UnroutableMessageTestExceptionListener; @@ -203,7 +202,7 @@ public class BrokerRestTest extends QpidRestTestCase protected void assertBrokerAttributes(Map<String, Object> brokerDetails) { - Asserts.assertAttributesPresent(brokerDetails, AbstractConfiguredObject.getAttributeNames(Broker.class), + Asserts.assertAttributesPresent(brokerDetails, ConfiguredObjectTypeRegistry.getAttributeNames(Broker.class), Broker.PROCESS_PID, ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/ConnectionRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/ConnectionRestTest.java index bf11ff9ae0..9013db7469 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/ConnectionRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/ConnectionRestTest.java @@ -34,9 +34,9 @@ import javax.jms.MessageProducer; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQSession; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; import org.apache.qpid.server.model.Connection; import org.apache.qpid.server.model.Session; -import org.apache.qpid.server.model.AbstractConfiguredObject; public class ConnectionRestTest extends QpidRestTestCase { @@ -174,7 +174,7 @@ public class ConnectionRestTest extends QpidRestTestCase private void assertSession(Map<String, Object> sessionData, AMQSession<?, ?> session) { assertNotNull("Session map cannot be null", sessionData); - Asserts.assertAttributesPresent(sessionData, AbstractConfiguredObject.getAttributeNames(Session.class), + Asserts.assertAttributesPresent(sessionData, ConfiguredObjectTypeRegistry.getAttributeNames(Session.class), ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/GroupProviderRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/GroupProviderRestTest.java index 9246877528..884d3d321a 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/GroupProviderRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/GroupProviderRestTest.java @@ -29,8 +29,8 @@ import java.util.Properties; import java.util.UUID; import org.apache.qpid.server.BrokerOptions; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; import org.apache.qpid.server.model.Group; import org.apache.qpid.server.model.GroupProvider; import org.apache.qpid.server.model.LifetimePolicy; @@ -322,7 +322,7 @@ public class GroupProviderRestTest extends QpidRestTestCase private void assertProvider(String name, String type, Map<String, Object> provider) { - Asserts.assertAttributesPresent(provider, AbstractConfiguredObject.getAttributeNames(GroupProvider.class), + Asserts.assertAttributesPresent(provider, ConfiguredObjectTypeRegistry.getAttributeNames(GroupProvider.class), ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/PortRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/PortRestTest.java index e80c1df41a..40ffc680a7 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/PortRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/PortRestTest.java @@ -35,7 +35,7 @@ import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.Protocol; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.Transport; -import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager; import org.apache.qpid.test.utils.TestBrokerConfiguration; public class PortRestTest extends QpidRestTestCase @@ -152,7 +152,7 @@ public class PortRestTest extends QpidRestTestCase Asserts.assertPortAttributes(port); Map<String, Object> authProviderAttributes = new HashMap<String, Object>(); - authProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + authProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); authProviderAttributes.put(AuthenticationProvider.NAME, TestBrokerConfiguration.ENTRY_NAME_ANONYMOUS_PROVIDER); responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + TestBrokerConfiguration.ENTRY_NAME_ANONYMOUS_PROVIDER, "PUT", authProviderAttributes); diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/PreferencesProviderRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/PreferencesProviderRestTest.java index 6ef3dd500a..a5b96fa6cd 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/PreferencesProviderRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/PreferencesProviderRestTest.java @@ -27,14 +27,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; +import org.apache.qpid.server.model.ExternalFileBasedAuthenticationManager; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.PreferencesProvider; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.adapter.FileSystemPreferencesProvider; -import org.apache.qpid.server.security.auth.manager.PlainPasswordFileAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.PlainPasswordDatabaseAuthenticationManager; import org.apache.qpid.test.utils.TestBrokerConfiguration; import org.apache.qpid.test.utils.TestFileUtils; @@ -74,9 +75,9 @@ public class PreferencesProviderRestTest extends QpidRestTestCase { super.customizeConfiguration(); Map<String, Object> anonymousAuthProviderAttributes = new HashMap<String, Object>(); - anonymousAuthProviderAttributes.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); + anonymousAuthProviderAttributes.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); anonymousAuthProviderAttributes.put(AuthenticationProvider.NAME, TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER + "-2"); - anonymousAuthProviderAttributes.put(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH, _authenticationProviderFile.getAbsolutePath()); + anonymousAuthProviderAttributes.put(ExternalFileBasedAuthenticationManager.PATH, _authenticationProviderFile.getAbsolutePath()); getBrokerConfiguration().addObjectConfiguration(AuthenticationProvider.class,anonymousAuthProviderAttributes); } @@ -162,7 +163,7 @@ public class PreferencesProviderRestTest extends QpidRestTestCase public void assertProviderCommonAttributes(Map<String, Object> provider) { Asserts.assertAttributesPresent(provider, - AbstractConfiguredObject.getAttributeNames(PreferencesProvider.class), + ConfiguredObjectTypeRegistry.getAttributeNames(PreferencesProvider.class), ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, ConfiguredObject.LAST_UPDATED_BY, diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java index 1a8fe9d930..9322f79984 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/QpidRestTestCase.java @@ -28,9 +28,8 @@ import org.apache.qpid.server.management.plugin.HttpManagement; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Plugin; import org.apache.qpid.server.model.Port; -import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager; import org.apache.qpid.test.utils.QpidBrokerTestCase; import org.apache.qpid.test.utils.TestBrokerConfiguration; @@ -89,7 +88,7 @@ public class QpidRestTestCase extends QpidBrokerTestCase config.removeObjectConfiguration(Port.class, TestBrokerConfiguration.ENTRY_NAME_RMI_PORT); Map<String, Object> anonymousProviderAttributes = new HashMap<String, Object>(); - anonymousProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + anonymousProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); anonymousProviderAttributes.put(AuthenticationProvider.NAME, ANONYMOUS_AUTHENTICATION_PROVIDER); config.addObjectConfiguration(AuthenticationProvider.class, anonymousProviderAttributes); diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/QueueRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/QueueRestTest.java index 70cc6414cd..7780022251 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/QueueRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/QueueRestTest.java @@ -36,10 +36,10 @@ import javax.jms.Session; import org.apache.qpid.server.model.Binding; import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.ConfiguredObjectTypeRegistry; import org.apache.qpid.server.model.Consumer; import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; -import org.apache.qpid.server.model.AbstractConfiguredObject; public class QueueRestTest extends QpidRestTestCase { @@ -212,7 +212,7 @@ public class QueueRestTest extends QpidRestTestCase { assertNotNull("Consumer map should not be null", consumer); Asserts.assertAttributesPresent(consumer, - AbstractConfiguredObject.getAttributeNames(Consumer.class), Consumer.STATE, + ConfiguredObjectTypeRegistry.getAttributeNames(Consumer.class), Consumer.STATE, Consumer.SETTLEMENT_MODE, Consumer.EXCLUSIVE, Consumer.SELECTOR, Consumer.NO_LOCAL, ConfiguredObject.TYPE, diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/SaslRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/SaslRestTest.java index 6a910df04d..d1f9053221 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/SaslRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/SaslRestTest.java @@ -39,7 +39,7 @@ import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.apache.qpid.server.model.AuthenticationProvider; -import org.apache.qpid.server.security.auth.manager.Base64MD5PasswordFileAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.Base64MD5PasswordDatabaseAuthenticationManager; import org.apache.qpid.test.utils.TestBrokerConfiguration; import org.apache.qpid.tools.security.Passwd; @@ -378,7 +378,7 @@ public class SaslRestTest extends QpidRestTestCase // configure broker to use Base64MD5PasswordFilePrincipalDatabase Map<String, Object> newAttributes = new HashMap<String, Object>(); newAttributes.put("path", passwordFile.getAbsolutePath()); - newAttributes.put(AuthenticationProvider.TYPE, Base64MD5PasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); + newAttributes.put(AuthenticationProvider.TYPE, Base64MD5PasswordDatabaseAuthenticationManager.PROVIDER_TYPE); getBrokerConfiguration().setObjectAttributes(AuthenticationProvider.class,TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER, newAttributes); } } diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java index 2575fb7e43..9168d5c81a 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java @@ -33,6 +33,7 @@ import org.apache.qpid.server.management.plugin.HttpManagement; import org.apache.qpid.server.model.AccessControlProvider; import org.apache.qpid.server.model.AuthenticationProvider; import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ExternalFileBasedAuthenticationManager; import org.apache.qpid.server.model.GroupProvider; import org.apache.qpid.server.model.KeyStore; import org.apache.qpid.server.model.Plugin; @@ -46,8 +47,8 @@ import org.apache.qpid.server.security.FileTrustStore; import org.apache.qpid.server.model.VirtualHostNode; import org.apache.qpid.server.security.access.FileAccessControlProviderConstants; import org.apache.qpid.server.security.acl.AbstractACLTestCase; -import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManagerFactory; -import org.apache.qpid.server.security.auth.manager.PlainPasswordFileAuthenticationManagerFactory; +import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager; +import org.apache.qpid.server.security.auth.manager.PlainPasswordDatabaseAuthenticationManager; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.systest.rest.QpidRestTestCase; import org.apache.qpid.test.utils.TestBrokerConfiguration; @@ -155,8 +156,8 @@ public class BrokerACLTest extends QpidRestTestCase Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE); - attributes.put(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH, file.getAbsolutePath()); + attributes.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE); + attributes.put(ExternalFileBasedAuthenticationManager.PATH, file.getAbsolutePath()); int responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("Setting of provider attribites should be allowed", 200, responseCode); @@ -178,16 +179,16 @@ public class BrokerACLTest extends QpidRestTestCase Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, providerName); - attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); - attributes.put(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH, file.getAbsolutePath()); + attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); + attributes.put(ExternalFileBasedAuthenticationManager.PATH, file.getAbsolutePath()); int responseCode = getRestTestHelper().submitRequest("/rest/authenticationprovider/" + providerName, "PUT", attributes); assertEquals("Setting of provider attribites should be allowed", 403, responseCode); Map<String, Object> provider = getRestTestHelper().getJsonAsSingletonList("/rest/authenticationprovider/" + providerName); assertEquals("Unexpected PATH attribute value", - providerData.get(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH), - provider.get(PlainPasswordFileAuthenticationManagerFactory.ATTRIBUTE_PATH)); + providerData.get(ExternalFileBasedAuthenticationManager.PATH), + provider.get(ExternalFileBasedAuthenticationManager.PATH)); } /* === VirtualHostNode === */ @@ -1012,7 +1013,7 @@ public class BrokerACLTest extends QpidRestTestCase { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(AuthenticationProvider.NAME, authenticationProviderName); - attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManagerFactory.PROVIDER_TYPE); + attributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE); return getRestTestHelper().submitRequest("/rest/authenticationprovider/" + authenticationProviderName, "PUT", attributes); } |