You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/04/30 03:22:16 UTC
svn commit: r1591170 [2/4] - in /qpid/trunk/qpid/java:
broker-codegen/src/main/java/org/apache/qpid/server/model/
broker-codegen/src/main/resources/META-INF/services/
broker-core/src/main/java/org/apache/qpid/server/exchange/
broker-core/src/main/java/...
Added: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java?rev=1591170&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java Wed Apr 30 01:22:13 2014
@@ -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);
+ }
+
+
+
+}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ExternalFileBasedAuthenticationManager.java Wed Apr 30 01:22:13 2014
@@ -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();
}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java Wed Apr 30 01:22:13 2014
@@ -34,4 +34,5 @@ public @interface ManagedAttribute
boolean mandatory() default false;
boolean persist() default true;
String defaultValue() default "";
+ String description() default "";
}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java Wed Apr 30 01:22:13 2014
@@ -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();
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java Wed Apr 30 01:22:13 2014
@@ -29,6 +29,6 @@ public interface FileBasedGroupProvider<
{
String PATH="path";
- @ManagedAttribute( automate = true, mandatory = true)
+ @ManagedAttribute( automate = true, mandatory = true, description = "File location" )
String getPath();
}
Added: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java?rev=1591170&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectRegistration.java Wed Apr 30 01:22:13 2014
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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 org.apache.qpid.server.model.ConfiguredObject;
+
+public interface ConfiguredObjectRegistration extends Pluggable
+{
+ Collection<Class<? extends ConfiguredObject>> getConfiguredObjectClasses();
+}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java Wed Apr 30 01:22:13 2014
@@ -171,7 +171,7 @@ public abstract class AbstractQueue<X ex
@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));
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/FileTrustStoreImpl.java Wed Apr 30 01:22:13 2014
@@ -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
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());
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/access/ObjectProperties.java Wed Apr 30 01:22:13 2014
@@ -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());
}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java Wed Apr 30 01:22:13 2014
@@ -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.a
@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 AnonymousAuthenticationMana
private static final AuthenticationResult ANONYMOUS_AUTHENTICATION = new AuthenticationResult(ANONYMOUS_PRINCIPAL);
+ @ManagedObjectFactoryConstructor
protected AnonymousAuthenticationManager(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java Wed Apr 30 01:22:13 2014
@@ -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 Base64MD5PasswordDatabaseAu
{
- 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);
}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java Wed Apr 30 01:22:13 2014
@@ -27,6 +27,9 @@ import org.apache.qpid.server.model.Mana
@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();
}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerImpl.java Wed Apr 30 01:22:13 2014
@@ -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 ExternalAuthenticationManag
@ManagedAttributeField
private boolean _useFullDN;
+ @ManagedObjectFactoryConstructor
protected ExternalAuthenticationManagerImpl(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/KerberosAuthenticationManager.java Wed Apr 30 01:22:13 2014
@@ -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);
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainPasswordDatabaseAuthenticationManager.java Wed Apr 30 01:22:13 2014
@@ -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);
}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java Wed Apr 30 01:22:13 2014
@@ -45,6 +45,7 @@ import org.apache.qpid.server.configurat
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 ScramSHA1AuthenticationMana
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 ScramSHA1AuthenticationMana
private Map<String, ScramAuthUser> _users = new ConcurrentHashMap<String, ScramAuthUser>();
+ @ManagedObjectFactoryConstructor
protected ScramSHA1AuthenticationManager(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManager.java Wed Apr 30 01:22:13 2014
@@ -28,21 +28,24 @@ import org.apache.qpid.server.model.Trus
@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();
}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerImpl.java Wed Apr 30 01:22:13 2014
@@ -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 SimpleLDAPAuthenticationMan
*/
private Class<? extends SocketFactory> _sslSocketFactoryOverrideClass;
+ @ManagedObjectFactoryConstructor
protected SimpleLDAPAuthenticationManagerImpl(final Map<String, Object> attributes, final Broker broker)
{
super(attributes, broker);
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java Wed Apr 30 01:22:13 2014
@@ -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
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());
}
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/messages/ExchangeMessagesTest.java Wed Apr 30 01:22:13 2014
@@ -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 extend
{
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 extend
{
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);
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/logging/subjects/AbstractTestLogSubject.java Wed Apr 30 01:22:13 2014
@@ -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.Broke
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 AbstractTestLogSub
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]);
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/SecurityManagerTest.java Wed Apr 30 01:22:13 2014
@@ -228,7 +228,7 @@ public class SecurityManagerTest extends
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
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
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();
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java Wed Apr 30 01:22:13 2014
@@ -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 PlainPasswordFileAuthentica
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 PlainPasswordFileAuthentica
//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 PlainPasswordFileAuthentica
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)
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java Wed Apr 30 01:22:13 2014
@@ -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 SimpleLDAPAuthenticationMan
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 SimpleLDAPAuthenticationMan
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 SimpleLDAPAuthenticationMan
{
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)
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Wed Apr 30 01:22:13 2014
@@ -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.Life
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 AbstractDurableCon
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 AbstractDurableCon
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;
}
Modified: qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java Wed Apr 30 01:22:13 2014
@@ -27,6 +27,6 @@ import org.apache.qpid.server.model.Mana
@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();
}
Modified: qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderImpl.java Wed Apr 30 01:22:13 2014
@@ -35,8 +35,8 @@ import org.apache.qpid.server.model.Brok
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 ACLFileAccessControlProvide
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);
Modified: qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java Wed Apr 30 01:22:13 2014
@@ -33,9 +33,7 @@ import org.apache.qpid.server.configurat
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.TestFi
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 ACLFileAccessControlProvide
}
}
+
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 ACLFileAccessControlProvide
{
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");
}
Modified: qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java?rev=1591170&r1=1591169&r2=1591170&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/RuleSetTest.java Wed Apr 30 01:22:13 2014
@@ -192,7 +192,7 @@ public class RuleSetTest extends QpidTes
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)));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org