Author: orudyy
Date: Thu Nov 26 14:37:13 2015
New Revision: 1716699

URL: http://svn.apache.org/viewvc?rev=1716699&view=rev
Log:
QPID-6906 : Address review comments by [~k-wall], add ability to upload 
certificates
------------------------------------------------------------------------
Merged from trunk with command:
svn merge -c r1716609 https://svn.apache.org/repos/asf/qpid/java/trunk

Modified:
    qpid/java/branches/6.0.x/   (props changed)
    
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
    
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/managedcertificatestore/show.js
    
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/store/managedcertificatestore/show.html

Propchange: qpid/java/branches/6.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 14:37:13 2015
@@ -9,5 +9,5 @@
 /qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716608
+/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716609
 /qpid/trunk/qpid:796646-796653

Modified: 
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
URL: 
http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java?rev=1716699&r1=1716698&r2=1716699&view=diff
==============================================================================
--- 
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
 (original)
+++ 
qpid/java/branches/6.0.x/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
 Thu Nov 26 14:37:13 2015
@@ -118,7 +118,16 @@ abstract class AttributeValueConverter<T
             }
             else if(value instanceof String)
             {
-                return 
DatatypeConverter.parseBase64Binary(AbstractConfiguredObject.interpolate(object,
 (String) value));
+                String interpolated = 
AbstractConfiguredObject.interpolate(object,
+                                                                          
(String) value);
+                try
+                {
+                    return DatatypeConverter.parseBase64Binary(interpolated);
+                }
+                catch(ArrayIndexOutOfBoundsException e)
+                {
+                    throw new IllegalArgumentException("Cannot convert string 
'"+ interpolated+ "'to a byte[] - it does not appear to be base64 data");
+                }
             }
             else
             {

Modified: 
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/managedcertificatestore/show.js
URL: 
http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/managedcertificatestore/show.js?rev=1716699&r1=1716698&r2=1716699&view=diff
==============================================================================
--- 
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/managedcertificatestore/show.js
 (original)
+++ 
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/js/qpid/management/store/managedcertificatestore/show.js
 Thu Nov 26 14:37:13 2015
@@ -86,19 +86,58 @@ define(["dojo/query",
                             return 
that.management.userPreferences.formatDateTime(val, {addOffset: true, 
appendTimeZone: true});
                         }
                     }
-                ], function(obj) {
-                    obj.grid.on("rowDblClick",
-                        function(evt){
-                            var idx = evt.rowIndex;
-                            var theItem = this.getItem(idx);
-                            that.download(theItem);
-                        });
-                }, gridProperties, EnhancedGrid);
+                ], null, gridProperties, EnhancedGrid);
         });
 
         this.removeButton = registry.byNode(query(".removeCertificates", 
containerNode)[0]);
         this.removeButton.on("click", function(e) {that.removeCertificates()} 
);
 
+        this.addButton = registry.byNode(query(".addCertificate", 
containerNode)[0]);
+        var addButton = this.addButton;
+        var that = this;
+
+        function uploadCertificate(cert) {
+            var parentModelObj = that.modelObj;
+            var modelObj = {type: parentModelObj.type, name: "addCertificate", 
parent: parentModelObj};
+            var url = that.management.buildObjectURL(modelObj);
+
+            that.management.post({url: url}, {certificate: 
cert}).then(uploadComplete, uploadError);
+        }
+
+        function uploadComplete() { addButton.set("disabled", false); }
+
+        function uploadError(error) { that.management.errorHandler(error) ; 
addButton.set("disabled", false);  }
+
+        function onFileSelected() {
+            if(addButton.domNode.children[0].files) {
+                addButton.set("disabled", true);
+                var file = addButton.domNode.children[0].files[0];
+                var fileReader = new FileReader();
+                fileReader.onload = function (evt) {
+                    var result = fileReader.result;
+                    if(result.indexOf("-----BEGIN CERTIFICATE-----") != -1) {
+                        uploadCertificate(result);
+
+                    } else {
+                        fileReader.onload = function (evt) {
+                            var binresult = fileReader.result;
+                            binresult = 
binresult.substring(binresult.indexOf(",")+1);
+                            uploadCertificate(binresult);
+                        };
+                        fileReader.readAsDataURL(file);
+                    }
+                };
+                fileReader.readAsText(file);
+            }
+        }
+
+        if( window.FileReader ) {
+            this.addButton.on("change", onFileSelected);
+        } else {
+            this.addButton.set("disabled", true);
+            this.addButton.domNode.style.display = "none";
+        }
+
     }
 
       ManagedCertificateStore.prototype.removeCertificates = function ()

Modified: 
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/store/managedcertificatestore/show.html
URL: 
http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/store/managedcertificatestore/show.html?rev=1716699&r1=1716698&r2=1716699&view=diff
==============================================================================
--- 
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/store/managedcertificatestore/show.html
 (original)
+++ 
qpid/java/branches/6.0.x/broker-plugins/management-http/src/main/java/resources/store/managedcertificatestore/show.html
 Thu Nov 26 14:37:13 2015
@@ -23,6 +23,12 @@
         <div class="managedCertificatesGrid hidden"></div>
         <div class="clear">
             <button data-dojo-type="dijit.form.Button" 
class="removeCertificates">Remove Certificates</button>
+            <span data-dojo-attach-point="blah"></span>
+            <input name="addCertificate" type="file" id="uploader" 
class="addCertificate"
+                   data-dojo-attach-point="uploader"
+                   data-dojo-type="dojox/form/Uploader"
+                   data-dojo-props="label: 'Add Certificate'"/>
+
         </div>
     </div>
     <div class="clear"></div>



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

Reply via email to