Author: rgodfrey
Date: Mon Nov 30 15:05:57 2015
New Revision: 1717269

URL: http://svn.apache.org/viewvc?rev=1717269&view=rev
Log:
QPID-6918 : Make auto generated self signed certs work for JDK 8; fix model so 
non available types are not visible in meta data

Added:
    
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ModelRoot.java
   (with props)
Modified:
    
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java
    
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
    
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java
    
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/security/AutoGeneratedSelfSignedKeyStoreImpl.java
    
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
    
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java
    
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java
    
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java?rev=1717269&r1=1717268&r2=1717269&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/BrokerModel.java
 Mon Nov 30 15:05:57 2015
@@ -116,7 +116,8 @@ public final class BrokerModel extends M
         addRelationship(Session.class, Publisher.class);
 
         _objectFactory = new ConfiguredObjectFactoryImpl(this);
-        _typeRegistry = new ConfiguredObjectTypeRegistry((new 
QpidServiceLoader()).instancesOf(ConfiguredObjectRegistration.class), 
getSupportedCategories());
+        _typeRegistry = new ConfiguredObjectTypeRegistry((new 
QpidServiceLoader()).instancesOf(ConfiguredObjectRegistration.class), 
getSupportedCategories(),
+                                                         _objectFactory);
     }
 
     public final ConfiguredObjectTypeRegistry getTypeRegistry()

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java?rev=1717269&r1=1717268&r2=1717269&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
 Mon Nov 30 15:05:57 2015
@@ -49,6 +49,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.server.plugin.ConfiguredObjectRegistration;
+import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory;
 import org.apache.qpid.server.util.Action;
 import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.util.Strings;
@@ -195,12 +196,17 @@ public class ConfiguredObjectTypeRegistr
     private final Map<Class<? extends ConfiguredObject>, Map<String, 
Collection<String>>> _validChildTypes =
             Collections.synchronizedMap(new HashMap<Class<? extends 
ConfiguredObject>, Map<String, Collection<String>>>());
 
-    public ConfiguredObjectTypeRegistry(Iterable<ConfiguredObjectRegistration> 
configuredObjectRegistrations, Collection<Class<? extends ConfiguredObject>> 
categoriesRestriction)
-    {
+    private final ConfiguredObjectFactory _objectFactory;
 
+    public ConfiguredObjectTypeRegistry(Iterable<ConfiguredObjectRegistration> 
configuredObjectRegistrations,
+                                        Collection<Class<? extends 
ConfiguredObject>> categoriesRestriction,
+                                        final ConfiguredObjectFactory 
objectFactory)
+    {
+        _objectFactory = objectFactory;
         Set<Class<? extends ConfiguredObject>> categories = new HashSet<>();
         Set<Class<? extends ConfiguredObject>> types = new HashSet<>();
 
+
         for (ConfiguredObjectRegistration registration : 
configuredObjectRegistrations)
         {
             for (Class<? extends ConfiguredObject> configuredObjectClass : 
registration.getConfiguredObjectClasses())
@@ -249,7 +255,12 @@ public class ConfiguredObjectTypeRegistr
             {
                 if (categoryClass.isAssignableFrom(typeClass))
                 {
-                    _knownTypes.get(categoryClass).add(typeClass);
+                    ManagedObject annotation = 
typeClass.getAnnotation(ManagedObject.class);
+                    String annotationType = annotation.type();
+                    if(ModelRoot.class.isAssignableFrom(categoryClass) || 
factoryExists(categoryClass, annotationType))
+                    {
+                        _knownTypes.get(categoryClass).add(typeClass);
+                    }
                 }
             }
         }
@@ -308,6 +319,14 @@ public class ConfiguredObjectTypeRegistr
         }
     }
 
+    private boolean factoryExists(final Class<? extends ConfiguredObject> 
categoryClass, final String type)
+    {
+        final ConfiguredObjectTypeFactory factory =
+                
_objectFactory.getConfiguredObjectTypeFactory(categoryClass.getSimpleName(), 
type);
+
+        return factory != null && factory.getType().equals(type);
+    }
+
     private static Method getValidChildTypesFunction(final String validValue, 
final Class<? extends ConfiguredObject> clazz)
     {
         if 
(validValue.matches("([\\w][\\w\\d_]+\\.)+[\\w][\\w\\d_\\$]*#[\\w\\d_]+\\s*\\(\\s*\\)"))

Added: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ModelRoot.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ModelRoot.java?rev=1717269&view=auto
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ModelRoot.java
 (added)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ModelRoot.java
 Mon Nov 30 15:05:57 2015
@@ -0,0 +1,25 @@
+/*
+ *
+ * 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;
+
+public interface ModelRoot
+{
+}

Propchange: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/ModelRoot.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java?rev=1717269&r1=1717268&r2=1717269&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/SystemConfig.java
 Mon Nov 30 15:05:57 2015
@@ -25,7 +25,7 @@ import org.apache.qpid.server.logging.Ev
 import org.apache.qpid.server.store.DurableConfigurationStore;
 
 @ManagedObject (creatable = false)
-public interface SystemConfig<X extends SystemConfig<X>> extends 
ConfiguredObject<X>
+public interface SystemConfig<X extends SystemConfig<X>> extends 
ConfiguredObject<X>, ModelRoot
 {
     String MANAGEMENT_MODE = "managementMode";
     

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/security/AutoGeneratedSelfSignedKeyStoreImpl.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/security/AutoGeneratedSelfSignedKeyStoreImpl.java?rev=1717269&r1=1717268&r2=1717269&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/security/AutoGeneratedSelfSignedKeyStoreImpl.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/security/AutoGeneratedSelfSignedKeyStoreImpl.java
 Mon Nov 30 15:05:57 2015
@@ -383,13 +383,23 @@ public class AutoGeneratedSelfSignedKeyS
     {
         try
         {
-            final Class<?> certAndKeyGenClass = 
Class.forName("sun.security.x509.CertAndKeyGen");
+            Class<?> certAndKeyGenClass;
+            try
+            {
+                certAndKeyGenClass = 
Class.forName("sun.security.x509.CertAndKeyGen");
+            }
+            catch (ClassNotFoundException e)
+            {
+                certAndKeyGenClass = 
Class.forName("sun.security.tools.keytool.CertAndKeyGen");
+            }
+
             final Class<?> x500NameClass = 
Class.forName("sun.security.x509.X500Name");
             final Class<?> certificateExtensionsClass = 
Class.forName("sun.security.x509.CertificateExtensions");
             final Class<?> generalNamesClass = 
Class.forName("sun.security.x509.GeneralNames");
             final Class<?> generalNameClass = 
Class.forName("sun.security.x509.GeneralName");
             final Class<?> extensionClass = 
Class.forName("sun.security.x509.SubjectAlternativeNameExtension");
 
+
             CONSTRUCTOR = certAndKeyGenClass.getConstructor(String.class, 
String.class);
             GENERATE_METHOD = certAndKeyGenClass.getMethod("generate", 
Integer.TYPE);
             GET_PRIVATE_KEY_METHOD = 
certAndKeyGenClass.getMethod("getPrivateKey");

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java?rev=1717269&r1=1717268&r2=1717269&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/hierarchy/TestModel.java
 Mon Nov 30 15:05:57 2015
@@ -54,7 +54,7 @@ public class TestModel extends Model
 
         ConfiguredObjectRegistration configuredObjectRegistration = new 
ConfiguredObjectRegistrationImpl();
 
-        _registry = new 
ConfiguredObjectTypeRegistry(Collections.singletonList(configuredObjectRegistration),
 Collections.EMPTY_LIST);
+        _registry = new 
ConfiguredObjectTypeRegistry(Collections.singletonList(configuredObjectRegistration),
 Collections.EMPTY_LIST, _objectFactory);
     }
 
 

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java?rev=1717269&r1=1717268&r2=1717269&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/lifecycle/TestConfiguredObject.java
 Mon Nov 30 15:05:57 2015
@@ -219,7 +219,8 @@ public class TestConfiguredObject extend
                     return TestConfiguredObjectModel.class.getSimpleName();
                 }
             };
-            _configuredObjectTypeRegistry = new 
ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration), 
CATEGORIES);
+            _configuredObjectTypeRegistry = new 
ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration), 
CATEGORIES,
+                                                                             
_configuredObjectFactory);
         }
 
         @Override

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java?rev=1717269&r1=1717268&r2=1717269&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/testmodels/singleton/TestModel.java
 Mon Nov 30 15:05:57 2015
@@ -62,7 +62,7 @@ public class TestModel extends Model
                 return "org.apache.qpid.server.model.testmodels.attribute";
             }
         };
-        _registry = new 
ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration), 
getSupportedCategories());
+        _registry = new 
ConfiguredObjectTypeRegistry(Arrays.asList(configuredObjectRegistration), 
getSupportedCategories(), _objectFactory);
     }
 
 

Modified: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js?rev=1717269&r1=1717268&r2=1717269&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js
 (original)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js
 Mon Nov 30 15:05:57 2015
@@ -126,19 +126,25 @@ define(["dojo/_base/lang",
             {
                 if (this.storeForm.validate())
                 {
-                    var success = false,failureReason=null;
+                    var that = this;
+
+                    function disableButtons(disabled) {
+                        that.addButton.set("disabled", disabled);
+                        that.cancelButton.set("disabled", disabled);
+                    }
+
+                    disableButtons(true);
 
                     var storeData = util.getFormWidgetValues(this.storeForm, 
this.initialData);
-                    var that = this;
 
                     if (this.effectiveData)
                     {
                         // update request
-                        this.management.update(this.modelObj, 
storeData).then(function(x){that.dialog.hide();});
+                        this.management.update(this.modelObj, 
storeData).then(function(x){ disableButtons(false); that.dialog.hide();}, 
function(err) { disableButtons(false); that.management.errorHandler(err); });
                     }
                     else
                     {
-                        this.management.create(this.category, this.modelObj, 
storeData).then(function(x){that.dialog.hide();});
+                        this.management.create(this.category, this.modelObj, 
storeData).then(function(x){ disableButtons(false); that.dialog.hide();}, 
function(err) { disableButtons(false); that.management.errorHandler(err); });
                     }
                 }
                 else



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to