QPID-7612 : [Java Broker] Where there is only one possibly type for a configured object, do not require it to be provided
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactory.java b/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactory.java
index f07f53d..7ca3266 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactory.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactory.java
@@ -38,11 +38,6 @@
 
     <X extends ConfiguredObject<X>> ListenableFuture<X> createAsync(Class<X> clazz, Map<String, Object> attributes, ConfiguredObject<?> parent);
 
-
-
-    <X extends ConfiguredObject<X>> ConfiguredObjectTypeFactory<X> getConfiguredObjectTypeFactory(Class<X> categoryClass,
-                                                                                                  Map<String, Object> attributes);
-
     <X extends ConfiguredObject<X>> ConfiguredObjectTypeFactory<X> getConfiguredObjectTypeFactory(String category,
                                                                                                   String type);
 
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java b/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java
index 069277e..3800690 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFactoryImpl.java
@@ -94,6 +94,11 @@
 
         String type = (String) record.getAttributes().get(ConfiguredObject.TYPE);
 
+        if(type == null || "".equals(type))
+        {
+            type = getOnlyValidChildTypeIfKnown(parent, category);
+        }
+
         ConfiguredObjectTypeFactory<X> factory = getConfiguredObjectTypeFactory(category, type);
 
         if(factory == null)
@@ -104,12 +109,24 @@
         return factory.recover(this, record, parent);
     }
 
+    private String getOnlyValidChildTypeIfKnown(final ConfiguredObject<?> parent, final String category)
+    {
+        String foo = null;
+        final Collection<String> validChildTypes =
+                _model.getTypeRegistry().getValidChildTypes(parent.getTypeClass(), category);
+        if (validChildTypes != null && validChildTypes.size() == 1)
+        {
+            foo = validChildTypes.iterator().next();
+        }
+        return foo;
+    }
+
     @Override
     public <X extends ConfiguredObject<X>> X create(Class<X> clazz,
                                                     final Map<String, Object> attributes,
                                                     final ConfiguredObject<?> parent)
     {
-        ConfiguredObjectTypeFactory<X> factory = getConfiguredObjectTypeFactory(clazz, attributes);
+        ConfiguredObjectTypeFactory<X> factory = getConfiguredObjectTypeFactory(clazz, attributes, parent);
 
         return factory.create(this, attributes, parent);
     }
@@ -120,15 +137,14 @@
                                                     final Map<String, Object> attributes,
                                                     final ConfiguredObject<?> parent)
     {
-        ConfiguredObjectTypeFactory<X> factory = getConfiguredObjectTypeFactory(clazz, attributes);
+        ConfiguredObjectTypeFactory<X> factory = getConfiguredObjectTypeFactory(clazz, attributes, parent);
 
         return factory.createAsync(this, attributes, parent);
     }
 
-
-    @Override
-    public <X extends ConfiguredObject<X>> ConfiguredObjectTypeFactory<X> getConfiguredObjectTypeFactory(final Class<X> categoryClass,
-                                                                                                         Map<String, Object> attributes)
+    private <X extends ConfiguredObject<X>> ConfiguredObjectTypeFactory<X> getConfiguredObjectTypeFactory(final Class<X> categoryClass,
+                                                                                                          Map<String, Object> attributes,
+                                                                                                          ConfiguredObject<?> parent)
     {
         final String category = categoryClass.getSimpleName();
         Map<String, ConfiguredObjectTypeFactory> categoryFactories = _allFactories.get(category);
@@ -150,7 +166,7 @@
         }
         else
         {
-            factory = getConfiguredObjectTypeFactory(category, null);
+            factory = getConfiguredObjectTypeFactory(category, getOnlyValidChildTypeIfKnown(parent, category));
         }
         return factory;
     }
diff --git a/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java b/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
index 4ebca27..e39e1f6 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
@@ -1290,11 +1290,17 @@
     public Collection<String> getValidChildTypes(Class<? extends ConfiguredObject> type,
                                                  Class<? extends ConfiguredObject> childType)
     {
+        return getValidChildTypes(type, getCategory(childType).getSimpleName());
+    }
+
+    public Collection<String> getValidChildTypes(Class<? extends ConfiguredObject> type,
+                                                 String childCategory)
+    {
         final Map<String, Collection<String>> allValidChildTypes = _validChildTypes.get(getTypeClass(type));
         if (allValidChildTypes != null)
         {
             final Collection<String> validTypesForSpecificChild =
-                    allValidChildTypes.get(getCategory(childType).getSimpleName());
+                    allValidChildTypes.get(childCategory);
             return validTypesForSpecificChild == null
                     ? null
                     : Collections.unmodifiableCollection(validTypesForSpecificChild);
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ConfigModelPasswordManagingAuthenticationProvider.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ConfigModelPasswordManagingAuthenticationProvider.java
index f06276d..b39f624 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ConfigModelPasswordManagingAuthenticationProvider.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ConfigModelPasswordManagingAuthenticationProvider.java
@@ -22,6 +22,7 @@
 
 import java.io.IOException;
 import java.nio.charset.Charset;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -241,4 +242,10 @@
     }
 
     abstract void validateUser(final ManagedUser managedUser);
+
+    @SuppressWarnings("unused")
+    public static Map<String, Collection<String>> getSupportedUserTypes()
+    {
+        return Collections.<String, Collection<String>>singletonMap(User.class.getSimpleName(), Collections.singleton(ManagedUser.MANAGED_USER_TYPE));
+    }
 }
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationProvider.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationProvider.java
index 2de8b98..396c13c 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationProvider.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/MD5AuthenticationProvider.java
@@ -44,7 +44,7 @@
 import org.apache.qpid.server.security.auth.sasl.plain.PlainNegotiator;
 import org.apache.qpid.server.util.ServerScopedRuntimeException;
 
-@ManagedObject(category = false, type = "MD5")
+@ManagedObject(category = false, type = "MD5", validChildTypes = "org.apache.qpid.server.security.auth.manager.ConfigModelPasswordManagingAuthenticationProvider#getSupportedUserTypes()")
 public class MD5AuthenticationProvider
         extends ConfigModelPasswordManagingAuthenticationProvider<MD5AuthenticationProvider>
 {
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainAuthenticationProvider.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainAuthenticationProvider.java
index 6fc18ea..2d1e5bf 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainAuthenticationProvider.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PlainAuthenticationProvider.java
@@ -38,7 +38,7 @@
 import org.apache.qpid.server.security.auth.sasl.scram.ScramNegotiator;
 import org.apache.qpid.server.security.auth.sasl.scram.ScramSaslServerSourceAdapter;
 
-@ManagedObject(category = false, type = "Plain")
+@ManagedObject(category = false, type = "Plain", validChildTypes = "org.apache.qpid.server.security.auth.manager.ConfigModelPasswordManagingAuthenticationProvider#getSupportedUserTypes()")
 public class PlainAuthenticationProvider
         extends ConfigModelPasswordManagingAuthenticationProvider<PlainAuthenticationProvider>
 {
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java
index 73d6e11..f5a2cd3 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManager.java
@@ -26,7 +26,7 @@
 import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
 
-@ManagedObject( category = false, type = "SCRAM-SHA-1" )
+@ManagedObject( category = false, type = "SCRAM-SHA-1" , validChildTypes = "org.apache.qpid.server.security.auth.manager.ConfigModelPasswordManagingAuthenticationProvider#getSupportedUserTypes()")
 public class ScramSHA1AuthenticationManager
         extends AbstractScramAuthenticationManager<ScramSHA1AuthenticationManager>
 {
diff --git a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA256AuthenticationManager.java b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA256AuthenticationManager.java
index ee7bd05..1bbbd29 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA256AuthenticationManager.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ScramSHA256AuthenticationManager.java
@@ -26,7 +26,7 @@
 import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
 
-@ManagedObject( category = false, type = "SCRAM-SHA-256" )
+@ManagedObject( category = false, type = "SCRAM-SHA-256" , validChildTypes = "org.apache.qpid.server.security.auth.manager.ConfigModelPasswordManagingAuthenticationProvider#getSupportedUserTypes()")
 public class ScramSHA256AuthenticationManager
         extends AbstractScramAuthenticationManager<ScramSHA256AuthenticationManager>
 {