From 8e3c214a4650eb427d91ccde5ff2b28d242b1029 Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Fri, 28 Nov 2014 18:25:57 +0000 Subject: QPID-6246: [Java Broker] Refactor authentication provider UIs to use dedicated dialogues git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1642340 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugin/servlet/rest/HelperServlet.java | 2 - .../ListAuthenticationProviderAttributes.java | 38 --- .../java/resources/addAuthenticationProvider.html | 70 ++-- .../java/resources/addPreferencesProvider.html | 21 +- .../authenticationprovider/external/add.html | 26 ++ .../authenticationprovider/passwordfile/add.html | 31 ++ .../preferences/filesystempreferences/add.html | 29 -- .../authenticationprovider/simpleldap/add.html | 129 ++++++++ .../main/java/resources/js/qpid/common/metadata.js | 4 + .../src/main/java/resources/js/qpid/common/util.js | 8 +- .../qpid/management/PreferencesProviderFields.js | 192 ----------- .../qpid/management/addAuthenticationProvider.js | 352 +++++++-------------- .../js/qpid/management/addPreferencesProvider.js | 113 ++++--- .../authenticationprovider/anonymous/add.js | 21 ++ .../base64md5passwordfile/add.js | 37 +++ .../authenticationprovider/external/add.js | 37 +++ .../authenticationprovider/kerberos/add.js | 22 ++ .../management/authenticationprovider/md5/add.js | 21 ++ .../management/authenticationprovider/plain/add.js | 21 ++ .../plainpasswordfile/add.js | 37 +++ .../preferences/filesystempreferences/add.js | 66 ---- .../authenticationprovider/scram-sha-1/add.js | 21 ++ .../authenticationprovider/scram-sha-256/add.js | 21 ++ .../authenticationprovider/simpleldap/add.js | 77 +++++ .../preferencesprovider/PreferencesProviderForm.js | 190 +++++++++++ .../filesystempreferences/add.js | 35 ++ .../filesystempreferences/add.html | 37 +++ .../preferencesProviderForm.html | 62 ++++ .../resources/showPreferencesProviderFields.html | 41 --- 29 files changed, 1062 insertions(+), 699 deletions(-) delete mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/external/add.html create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/passwordfile/add.html delete mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/preferences/filesystempreferences/add.html create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/simpleldap/add.html delete mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/anonymous/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/base64md5passwordfile/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/external/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/kerberos/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/md5/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/plain/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/plainpasswordfile/add.js delete mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/preferences/filesystempreferences/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/scram-sha-1/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/scram-sha-256/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/simpleldap/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/filesystempreferences/add.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/filesystempreferences/add.html create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/preferencesProviderForm.html delete mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferencesProviderFields.html (limited to 'qpid/java/broker-plugins/management-http') diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java index cb41fd9203..1e795480fc 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java @@ -34,7 +34,6 @@ import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; import org.apache.qpid.server.management.plugin.servlet.rest.action.ListAccessControlProviderAttributes; -import org.apache.qpid.server.management.plugin.servlet.rest.action.ListAuthenticationProviderAttributes; import org.apache.qpid.server.management.plugin.servlet.rest.action.ListBrokerAttribute; import org.apache.qpid.server.management.plugin.servlet.rest.action.ListGroupProviderAttributes; import org.apache.qpid.server.management.plugin.servlet.rest.action.ListTimeZones; @@ -55,7 +54,6 @@ public class HelperServlet extends AbstractServlet _mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); Action[] supportedActions = { - new ListAuthenticationProviderAttributes(), new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOSTNODE_TYPES, "ListVirtualHostNodeTypes"), new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_TYPES, "ListVirtualHostTypes"), new ListBrokerAttribute(Broker.SUPPORTED_PREFERENCES_PROVIDER_TYPES, "ListPreferencesProvidersTypes"), diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java deleted file mode 100644 index 3e006a705a..0000000000 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListAuthenticationProviderAttributes.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - * - */ -package org.apache.qpid.server.management.plugin.servlet.rest.action; - -import org.apache.qpid.server.model.AuthenticationProvider; - -public class ListAuthenticationProviderAttributes extends AbstractSpecialisedAttributeLister -{ - @Override - public String getName() - { - return ListAuthenticationProviderAttributes.class.getSimpleName(); - } - - @Override - Class getCategoryClass() - { - return AuthenticationProvider.class; - } -} diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addAuthenticationProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addAuthenticationProvider.html index e90262f17b..ee9286e2f7 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addAuthenticationProvider.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addAuthenticationProvider.html @@ -15,32 +15,50 @@ ~ limitations under the License. -->
-
-
-
- - - - - - - - - -
Type*:
Name*:
- -
-
-
-
+
+
+ +
+
+ Authentication Provider +
+
Name*:
+
+ +
+
+
+
Type*:
+
+ +
+
+
+
+
-
-
- - -
- + + +
+
+
+ + +
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addPreferencesProvider.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addPreferencesProvider.html index bca2320888..e850f5ac7f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addPreferencesProvider.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addPreferencesProvider.html @@ -15,17 +15,14 @@ ~ limitations under the License. -->
-
-
- -
-
-
-
- - - -
-
+
+ +
+ +
+ + + +
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/external/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/external/add.html new file mode 100644 index 0000000000..8c50252058 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/external/add.html @@ -0,0 +1,26 @@ + +
+
Use full DN:
+
+ +
+
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/passwordfile/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/passwordfile/add.html new file mode 100644 index 0000000000..53eb786722 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/passwordfile/add.html @@ -0,0 +1,31 @@ + +
+
Path*:
+
+ +
+
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/preferences/filesystempreferences/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/preferences/filesystempreferences/add.html deleted file mode 100644 index 48e9c19748..0000000000 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/preferences/filesystempreferences/add.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - -
Path*: -
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/simpleldap/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/simpleldap/add.html new file mode 100644 index 0000000000..16463565e3 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/authenticationprovider/simpleldap/add.html @@ -0,0 +1,129 @@ + +
+
+
LDAP server URL*:
+
+ +
+
+
+
Search context*:
+
+ +
+
+
+
Search filter*:
+
+ +
+
+
+
Search username:
+
+ +
+
+
+
Search password:
+
+ +
+
+
+
Trust Store:
+
+ +
+
+
+
Bind without search:
+
+ +
+
+
+
LDAP Context Factory:
+
+ +
+
+
+
LDAP authentication URL
+
+ +
+
+
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js index 901172f80e..749b9b89cb 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js @@ -65,6 +65,10 @@ define(["dojo/_base/xhr", } } return values; + }, + implementsManagedInterface: function (category, type, managedInterfaceName) + { + return this.getMetaData(category, type).managedInterfaces.indexOf(managedInterfaceName) >= 0; } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js index 771d29601e..53340edc85 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js @@ -152,8 +152,12 @@ define(["dojo/_base/xhr", util.isProviderManagingUsers = function(type) { - return (type === "PlainPasswordFile" || type === "Base64MD5PasswordFile" || type === "SCRAM-SHA-1" - || type === "SCRAM-SHA-256" || type === "Plain" || type === "MD5" ); + return metadata.implementsManagedInterface("AuthenticationProvider", type, "PasswordCredentialManagingAuthenticationProvider"); + }; + + util.supportsPreferencesProvider = function(type) + { + return metadata.implementsManagedInterface("AuthenticationProvider", type, "PreferencesSupportingAuthenticationProvider"); }; util.showSetAttributesDialog = function(attributeWidgetFactories, data, putURL, dialogTitle, category, type, appendNameToUrl) diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js deleted file mode 100644 index afd05aeda3..0000000000 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js +++ /dev/null @@ -1,192 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -define(["dojo/_base/xhr", - "dojo/dom", - "dojo/query", - "dojo/parser", - "dojo/string", - "dojo/json", - "dojo/store/Memory", - "dijit/registry", - "dijit/form/FilteringSelect", - "dijit/form/ValidationTextBox", - "dojox/html/entities", - "dojo/text!../../showPreferencesProviderFields.html", - "dojo/text!service/helper?action=ListPreferencesProvidersTypes", - "qpid/common/util", - "dojox/validate/us", - "dojox/validate/web", - "dojo/domReady!"], function (xhr, dom, query, parser, string, json, Memory, registry, FilteringSelect, ValidationTextBox, entities, template, preferencesProvidersTypes, util) { - - var PreferencesProviderFields = {}; - - var types = [{id: "", name: "None"}]; - var typesArray = json.parse(preferencesProvidersTypes); - for (var i =0 ; i < typesArray.length; i++) - { - types.push({id: typesArray[i], name: typesArray[i]}); - } - - var selectPreferencesProviderType = function(type) - { - if(type && string.trim(type) != "") - { - var disableOnEditing = PreferencesProviderFields.data? true: false; - PreferencesProviderFields.name.set("disabled", disableOnEditing); - PreferencesProviderFields.type.set("disabled", disableOnEditing); - if (PreferencesProviderFields.currentType != type) - { - require(["qpid/management/authenticationprovider/preferences/" + type.toLowerCase() + "/add"], - function(typeFields) - { - PreferencesProviderFields.currentType = null; - if (PreferencesProviderFields.details ) - { - PreferencesProviderFields.details.destroy(); - } - PreferencesProviderFields.details = typeFields; - typeFields.show(PreferencesProviderFields.fieldsContainer, PreferencesProviderFields.data); - PreferencesProviderFields.currentType = type; - }); - } - else - { - PreferencesProviderFields.details.disable(false); - } - } - else - { - PreferencesProviderFields.disable(true); - } - }; - - PreferencesProviderFields.init = function(data) - { - this.data = data; - this.id.value = data.id; - this.name.set("value", data.name); - this.type.set("value", data.type); - selectPreferencesProviderType(data.type); - }; - - PreferencesProviderFields.show = function(node, provider, authenticationProviderName) - { - this.currentType = null; - this.data = null; - node.innerHTML = template; - try - { - parser.parse(node); - } - catch(e) - { - console.error(e); - return; - } - - if (this.container) - { - this.container.destroyRecursive(); - } - if (this.details ) - { - this.details.destroy(); - delete this["details"]; - } - this.container = registry.byNode(query(".preferencesProviderContainer", node)[0]); - this.fieldsContainer = query(".preferencesProviderFieldsContainer", node)[0]; - this.type = registry.byNode(query(".preferencesProviderType", node)[0]); - this.name = registry.byNode(query(".preferencesProviderName", node)[0]); - this.name.set("regExpGen", util.nameOrContextVarRegexp); - this.id = query("input[name='preferencesProviderId']", node)[0]; - this.id.value = null; - this.type.set("store", new Memory({ data: types, idProperty: "id"})); - this.type.on("change", selectPreferencesProviderType ); - this.type.startup(); - - if (provider) - { - if (typeof provider == "object") - { - this.init(provider); - } - else if (typeof provider == "string") - { - var that = this; - xhr.get({ - url: "api/latest/preferencesprovider/" +encodeURIComponent(authenticationProviderName) + "/" + encodeURIComponent(provider), - sync: true, - content: { actuals: true }, - handleAs: "json" - }).then(function(data){if (data && data[0]) { that.init(data[0]);}}); - } - } - else - { - this.disable(true); - } - }; - - PreferencesProviderFields.disable = function(val) - { - this.name.set("disabled", val); - if (this.details) - { - this.details.disable(val); - } - }; - - PreferencesProviderFields.getValues = function() - { - var values = {}; - if (this.details) - { - values = this.details.getValues() || {}; - } - values.name = this.name.get("value"); - if (this.id.value) - { - values.id = this.id.value; - } - values.type = this.type.get("value"); - return values; - }; - - PreferencesProviderFields.save = function(authenticationProviderName) - { - var success = true; - if (this.type.value) - { - var data = this.getValues(); - xhr.put({url: "api/latest/preferencesprovider/" +encodeURIComponent(authenticationProviderName) + "/" + encodeURIComponent(data.name), - sync: true, - handleAs: "json", - headers: { "Content-Type": "application/json"}, - putData: json.stringify(data), - load: function(x) {success = true;}, - error: function(error) {success = false; util.xhrErrorHandler(error);}}); - } - return success; - }; - - return PreferencesProviderFields; - -}); \ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js index c59e86aaa1..51f2acb685 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js @@ -26,13 +26,15 @@ define(["dojo/_base/xhr", "dojo/parser", "dojo/_base/array", "dojo/_base/event", - 'dojo/_base/json', + 'dojo/json', "dojo/store/Memory", "dijit/form/FilteringSelect", "dojo/_base/connect", "dojo/dom-style", - "qpid/management/PreferencesProviderFields", "qpid/common/util", + "qpid/common/metadata", + "dojo/text!addAuthenticationProvider.html", + "qpid/management/preferencesprovider/PreferencesProviderForm", /* dojox/ validate resources */ "dojox/validate/us", "dojox/validate/web", /* basic dijit classes */ @@ -46,252 +48,136 @@ define(["dojo/_base/xhr", "dojox/form/BusyButton", "dojox/form/CheckedMultiSelect", "dojox/layout/TableContainer", "dojo/domReady!"], - function (xhr, dom, construct, win, registry, parser, array, event, json, Memory, FilteringSelect, connect, domStyle, PreferencesProviderFields, util) { - - var addAuthenticationProvider = {}; - - var node = construct.create("div", null, win.body(), "last"); - - var convertToAuthenticationProvider = function convertToAuthenticationProvider(formValues) + function (xhr, dom, construct, win, registry, parser, array, event, json, Memory, FilteringSelect, connect, domStyle, util, metadata, template) + { + var addAuthenticationProvider = { - var newProvider = {}; + init:function() + { + var that=this; + this.containerNode = construct.create("div", {innerHTML: template}); + parser.parse(this.containerNode); + + var authenticationProviderName = registry.byId("addAuthenticationProvider.name"); + authenticationProviderName.set("regExpGen", util.nameOrContextVarRegexp); + + this.dialog = registry.byId("addAuthenticationProvider"); + this.addButton = registry.byId("addAuthenticationProvider.addButton"); + this.cancelButton = registry.byId("addAuthenticationProvider.cancelButton"); + this.cancelButton.on("click", function(e){that._cancel(e);}); + this.addButton.on("click", function(e){that._add(e);}); + + this.authenticationProviderTypeFieldsContainer = dom.byId("addAuthenticationProvider.typeFields"); + this.authenticationProviderForm = registry.byId("addAuthenticationProvider.form"); + this.authenticationProviderType = registry.byId("addAuthenticationProvider.type"); + this.supportedAuthenticationProviderTypes = metadata.getTypesForCategory("AuthenticationProvider"); + this.supportedAuthenticationProviderTypes.sort(); + var authenticationProviderTypeStore = util.makeTypeStore(this.supportedAuthenticationProviderTypes); + this.authenticationProviderType.set("store", authenticationProviderTypeStore); + this.authenticationProviderType.on("change", function(type){that._authenticationProviderTypeChanged(type);}); + + this.preferencesProviderForm = new qpid.preferencesprovider.PreferencesProviderForm({disabled: true}); + this.preferencesProviderForm.placeAt(dom.byId("addPreferencesProvider.form")); + }, + show:function(providerName) + { + this.authenticationProviderForm.reset(); + this.preferencesProviderForm.reset(); - newProvider.name = dijit.byId("formAddAuthenticationProvider.name").value; - newProvider.type = dijit.byId("authenticationProviderType").value; - var id = dojo.byId("formAddAuthenticationProvider.id").value; - if (id) + this.dialog.show(); + if (!this.resizeEventRegistered) + { + this.resizeEventRegistered = true; + util.resizeContentAreaAndRepositionDialog(dom.byId("addAuthenticationProvider.contentPane"), this.dialog); + } + }, + _cancel: function(e) { - newProvider.id = id; - } - for(var propName in formValues) + event.stop(e); + this.dialog.hide(); + }, + _add: function(e) + { + event.stop(e); + this._submit(); + }, + _submit: function() { - if(formValues.hasOwnProperty(propName)) + if(this.authenticationProviderForm.validate() && this.preferencesProviderForm.validate()) { - if (propName.indexOf("preferencesProvider") == 0) + var success = false,failureReason=null; + + var authenticationProviderData = util.getFormWidgetValues(this.authenticationProviderForm); // TODO initialValues + + var encodedAuthenticationProviderName = encodeURIComponent(authenticationProviderData.name); + xhr.put({ + url: "api/latest/authenticationprovider/" + encodedAuthenticationProviderName, + sync: true, + handleAs: "json", + headers: { "Content-Type": "application/json"}, + putData: json.stringify(authenticationProviderData), + load: function(x) {success = true; }, + error: function(error) {success = false; failureReason = error;} + }); + + if(success === true) { - continue; - } - if(formValues[ propName ] !== "") { - newProvider[ propName ] = formValues[propName]; + var preferencesProviderResult = this.preferencesProviderForm.submit(encodedAuthenticationProviderName); + success = preferencesProviderResult.success; + failureReason = preferencesProviderResult.failureReason; } + if (success == true) + { + this.dialog.hide(); + } + else + { + util.xhrErrorHandler(failureReason); + } } - } - return newProvider; - } - - var showFieldSets = function showFieldSets(providerType, fieldSets) - { - for(var key in fieldSets) - { - var layout = fieldSets[key]; - var disabled = key != providerType; - var displayValue = key == providerType ? "block" : "none"; - var widgets = layout.getDescendants(); - array.forEach(widgets, function(widget) + else { - widget.set("disabled", disabled); - }); - - domStyle.set(fieldSets[key].domNode, "display", displayValue); - } - if (fieldSets[providerType]) + alert('Form contains invalid data. Please correct first'); + } + }, + _authenticationProviderTypeChanged: function(type) + { + this._typeChanged(type, this.authenticationProviderTypeFieldsContainer, "qpid/management/authenticationprovider/", "AuthenticationProvider" ); + }, + _typeChanged: function(type, typeFieldsContainer, baseUrl, category ) { - fieldSets[providerType].getParent().resize(); + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function(item) { item.destroyRecursive();}); + this.preferencesProviderForm.set("disabled", !type || !util.supportsPreferencesProvider(type)); + if (type) + { + var that = this; + require([ baseUrl + type.toLowerCase() + "/add"], function(typeUI) + { + try + { + typeUI.show({containerNode:typeFieldsContainer, parent: that}); + util.applyMetadataToWidgets(typeFieldsContainer, category, type); + } + catch(e) + { + console.warn(e); + } + }); + } } - } - - var getAuthenticationProviderWidgetId = function getAuthenticationProviderWidgetId(providerType, attribute) - { - return "ap_" + providerType + "Field" + attribute; - } + }; - var showPreferencesProviderFields = function showPreferencesProviderFields(provider) + try { - var preferencesProviderDiv = dojo.byId("addAuthenticationProvider.preferencesProvider"); - var preferencesProviderPanel = dijit.byId("addAuthenticationProvider.preferencesProviderPanel"); - if (provider && provider.type == "Anonymous") - { - preferencesProviderPanel.domNode.style.display = 'none'; - } - else - { - preferencesProviderPanel.domNode.style.display = 'block'; - PreferencesProviderFields.show(preferencesProviderDiv, provider && provider.preferencesproviders ? provider.preferencesproviders[0] : null); - } + addAuthenticationProvider.init(); } - - var loadProviderAndDisplayForm = function loadProviderAndDisplayForm(providerName, dialog) + catch(e) { - if (providerName) - { - xhr.get({ - url: "api/latest/authenticationprovider/" + encodeURIComponent(providerName), - content: { actuals: true }, - handleAs: "json" - }).then( - function(data) { - var provider = data[0]; - var providerType = provider.type; - var nameField = dijit.byId("formAddAuthenticationProvider.name"); - nameField.set("value", provider.name); - nameField.set("disabled", true); - nameField.set("regExpGen", util.nameOrContextVarRegexp); - dialog.providerChooser.set("value", providerType); - dialog.providerChooser.set("disabled", true); - dojo.byId("formAddAuthenticationProvider.id").value=provider.id; - for(var attribute in provider) - { - if (provider.hasOwnProperty(attribute)) - { - var widject = dijit.byId(getAuthenticationProviderWidgetId(providerType, attribute)); - if (widject) - { - widject.set("value", provider[attribute]); - } - } - } - showPreferencesProviderFields(provider); - registry.byId("addAuthenticationProvider").show(); - }); - } - else - { - showPreferencesProviderFields(); - registry.byId("addAuthenticationProvider").show(); - } - } - - xhr.get({url: "addAuthenticationProvider.html", - sync: true, - load: function(data) { - var theForm; - node.innerHTML = data; - addAuthenticationProvider.dialogNode = dom.byId("addAuthenticationProvider"); - parser.instantiate([addAuthenticationProvider.dialogNode]); - theForm = registry.byId("formAddAuthenticationProvider"); - theForm.on("submit", function(e) { - - event.stop(e); - if(theForm.validate()){ - - var newAuthenticationManager = convertToAuthenticationProvider(theForm.getValues()); - var that = this; - - xhr.put({url: "api/latest/authenticationprovider/" + encodeURIComponent(newAuthenticationManager.name), - sync: true, handleAs: "json", - headers: { "Content-Type": "application/json"}, - putData: json.toJson(newAuthenticationManager), - load: function(x) {that.success = true; }, - error: function(error) {that.success = false; that.failureReason = error;}}); - - if(this.success === true) - { - if (PreferencesProviderFields.save(newAuthenticationManager.name)) - { - registry.byId("addAuthenticationProvider").hide(); - } - } - else - { - util.xhrErrorHandler(this.failureReason); - } - return false; - }else{ - alert('Form contains invalid data. Please correct first'); - return false; - } - }); - }}); - - addAuthenticationProvider.show = function(providerName) { - var that = this; - registry.byId("formAddAuthenticationProvider").reset(); - dojo.byId("formAddAuthenticationProvider.id").value=""; - registry.byId("formAddAuthenticationProvider.name").set("disabled", false); - if (this.providerChooser) - { - this.providerChooser.set("disabled", false); - } - - if (!that.hasOwnProperty("providerFieldSets")) - { - xhr.get({ - url: "service/helper?action=ListAuthenticationProviderAttributes", - handleAs: "json" - }).then( - function(data) { - var providers = []; - var providerIndex = 0; - that.providerFieldSetsContainer = dom.byId("addAuthenticationProvider.fieldSets"); - that.providerFieldSets = []; - - for (var providerType in data) { - if (data.hasOwnProperty(providerType)) { - providers[providerIndex++] = {id: providerType, name: providerType}; - - var attributes = data[providerType].attributes; - var resources = data[providerType].descriptions; - var layout = new dojox.layout.TableContainer( { - id: providerType + "FieldSet", - cols: 1, - "labelWidth": "200", - showLabels: true, - orientation: "horiz" - }); - for(var i=0; i < attributes.length; i++) { - if ("type" == attributes[i]) - { - continue; - } - var labelValue = attributes[i]; - if (resources && resources[attributes[i]]) - { - labelValue = resources[attributes[i]]; - } - var text = new dijit.form.TextBox({ - label: labelValue + ":", - id: getAuthenticationProviderWidgetId(providerType, attributes[i]), - name: attributes[i] - }); - layout.addChild(text); - } - layout.placeAt("addAuthenticationProvider.fieldSets"); - that.providerFieldSets[providerType]=layout; - layout.startup(); - } - } - - var providersStore = new Memory({ data: providers }); - if(that.providerChooser) { - that.providerChooser.destroy( false ); - } - - var providersDiv = dom.byId("addAuthenticationProvider.selectAuthenticationProviderDiv"); - var input = construct.create("input", {id: "addAuthenticationProviderType"}, providersDiv); - - that.providerChooser = new FilteringSelect({ id: "authenticationProviderType", - name: "type", - store: providersStore, - searchAttr: "name"}, input); - that.providerChooser.on("change", - function(value) - { - dijit.byId("addAuthenticationProvider.preferencesProviderPanel").domNode.style.display = (value == "Anonymous" ? "none" : "block"); - showFieldSets(that.providerChooser.value, that.providerFieldSets); - } - ); - var providerType = providers[0].name; - that.providerChooser.set("value", providerType); - showFieldSets(providerType, that.providerFieldSets); - loadProviderAndDisplayForm(providerName, that) - }); - } - else - { - loadProviderAndDisplayForm(providerName, that); - } + console.warn(e); } - return addAuthenticationProvider; - }); \ No newline at end of file + } + +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPreferencesProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPreferencesProvider.js index 40f8f83fbb..072b202b23 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPreferencesProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPreferencesProvider.js @@ -18,77 +18,74 @@ * under the License. * */ -define(["dojo/_base/xhr", - "dojo/dom", +define([ + "dojo/_base/event", "dojo/dom-construct", - "dojo/query", - "dojo/_base/window", - "dijit/registry", "dojo/parser", - "dojo/_base/array", - "dojo/_base/event", - 'dojo/_base/json', - "dojo/store/Memory", - "dijit/form/FilteringSelect", - "dojo/_base/connect", - "dojo/dom-style", - "dojo/string", + "dijit/registry", + "qpid/management/preferencesprovider/PreferencesProviderForm", + "qpid/common/util", + "dojo/text!addPreferencesProvider.html", "dojox/html/entities", - "qpid/management/PreferencesProviderFields", "dojox/validate/us", "dojox/validate/web", "dijit/Dialog", - "dijit/form/CheckBox", - "dijit/form/Textarea", - "dijit/form/TextBox", - "dijit/form/ValidationTextBox", "dijit/form/Button", - "dijit/form/Form", - "dojox/form/BusyButton", - "dojox/form/CheckedMultiSelect", - "dojox/layout/TableContainer", "dojo/domReady!"], - function (xhr, dom, construct, query, win, registry, parser, array, event, json, Memory, FilteringSelect, connect, domStyle, string, entities, PreferencesProviderFields) { - - var addPreferencesProvider = {}; + function ( event, construct, parser, registry, PreferencesProviderForm, util, template, entities) { - var node = construct.create("div", null, win.body(), "last"); + var addPreferencesProvider = + { + init: function() + { + var that=this; + this.containerNode = construct.create("div", {innerHTML: template}); + parser.parse(this.containerNode); - xhr.get({url: "addPreferencesProvider.html", - sync: true, - load: function(data) { - node.innerHTML = data; - addPreferencesProvider.dialogNode = dom.byId("addPreferencesProvider"); - parser.instantiate([addPreferencesProvider.dialogNode]); + this.preferencesProviderForm = registry.byId("addPreferencesProvider.preferencesProvider"); + this.dialog = registry.byId("addPreferencesProvider"); - var cancelButton = registry.byId("addPreferencesProvider.cancelButton"); - cancelButton.on("click", function(){ - registry.byId("addPreferencesProvider").hide(); - }); - var theForm = registry.byId("formAddPreferencesProvider"); - theForm.on("submit", function(e) { + var cancelButton = registry.byId("addPreferencesProvider.cancelButton"); + cancelButton.on("click", function() { that.dialog.hide(); }); - event.stop(e); - if(theForm.validate()){ - if(PreferencesProviderFields.save(addPreferencesProvider.authenticationProviderName)) - { - registry.byId("addPreferencesProvider").hide(); - } - return false; - }else{ - alert('Form contains invalid data. Please correct first'); - return false; - } - }); - }}); + var saveButton = registry.byId("addPreferencesProvider.saveButton"); + saveButton.on("click", function() + { + var result = that.preferencesProviderForm.submit(encodeURIComponent(addPreferencesProvider.authenticationProviderName)); + if (result.success) + { + that.dialog.hide(); + } + else + { + util.xhrErrorHandler(result.failureReason); + } + }); + }, + show: function(authenticationProviderName, providerName) + { + this.authenticationProviderName = authenticationProviderName; + this.dialog.set("title", (providerName ? "Edit preferences provider '" + entities.encode(String(providerName)) + "' " : "Add preferences provider ") + " for '" + entities.encode(String(authenticationProviderName)) + "' "); + if (providerName) + { + this.preferencesProviderForm.load(authenticationProviderName, providerName); + } + else + { + this.preferencesProviderForm.reset(); + } + this.dialog.show(); + } + }; - addPreferencesProvider.show = function(authenticationProviderName, providerName) { - this.authenticationProviderName = authenticationProviderName; - PreferencesProviderFields.show(dom.byId("addPreferencesProvider.preferencesProvider"), providerName, authenticationProviderName) - var dialog = registry.byId("addPreferencesProvider"); - dialog.set("title", (providerName ? "Edit preferences provider '" + entities.encode(String(providerName)) + "' " : "Add preferences provider ") + " for '" + entities.encode(String(authenticationProviderName)) + "' ") - dialog.show(); + try + { + addPreferencesProvider.init(); + } + catch(e) + { + console.warn("Initialisation of add preferences dialog failed", e); } return addPreferencesProvider; - }); \ No newline at end of file + }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/anonymous/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/anonymous/add.js new file mode 100644 index 0000000000..73022a0855 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/anonymous/add.js @@ -0,0 +1,21 @@ +/* + * + * 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. + * + */ +define([], function () { return { show: function(data){} }; }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/base64md5passwordfile/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/base64md5passwordfile/add.js new file mode 100644 index 0000000000..b1beadb489 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/base64md5passwordfile/add.js @@ -0,0 +1,37 @@ +/* + * + * 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. + * + */ +define(["dojo/query","dijit/registry","qpid/common/util"], + function (query, registry, util) + { + return { + show: function(data) + { + util.parseHtmlIntoDiv(data.containerNode, "authenticationprovider/passwordfile/add.html"); + if (data.data) + { + var path = registry.byNode(query(".path", data.containerNode)[0]); + path.set("value", data.data.useFullDN); + } + } + }; + } +); + diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/external/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/external/add.js new file mode 100644 index 0000000000..6147bf5249 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/external/add.js @@ -0,0 +1,37 @@ +/* + * + * 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. + * + */ +define(["dojo/query","dijit/registry","qpid/common/util"], + function (query, registry, util) + { + return { + show: function(data) + { + util.parseHtmlIntoDiv(data.containerNode, "authenticationprovider/external/add.html"); + if (data.data) + { + var useFullDN = registry.byNode(query(".useFullDN", data.containerNode)[0]); + useFullDN.set("value", data.data.useFullDN); + } + } + }; + } +); + diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/kerberos/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/kerberos/add.js new file mode 100644 index 0000000000..f76c75f05e --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/kerberos/add.js @@ -0,0 +1,22 @@ +/* + * + * 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. + * + */ +define([], function () { return { show: function(data){} }; }); + diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/md5/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/md5/add.js new file mode 100644 index 0000000000..73022a0855 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/md5/add.js @@ -0,0 +1,21 @@ +/* + * + * 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. + * + */ +define([], function () { return { show: function(data){} }; }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/plain/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/plain/add.js new file mode 100644 index 0000000000..73022a0855 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/plain/add.js @@ -0,0 +1,21 @@ +/* + * + * 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. + * + */ +define([], function () { return { show: function(data){} }; }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/plainpasswordfile/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/plainpasswordfile/add.js new file mode 100644 index 0000000000..b1beadb489 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/plainpasswordfile/add.js @@ -0,0 +1,37 @@ +/* + * + * 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. + * + */ +define(["dojo/query","dijit/registry","qpid/common/util"], + function (query, registry, util) + { + return { + show: function(data) + { + util.parseHtmlIntoDiv(data.containerNode, "authenticationprovider/passwordfile/add.html"); + if (data.data) + { + var path = registry.byNode(query(".path", data.containerNode)[0]); + path.set("value", data.data.useFullDN); + } + } + }; + } +); + diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/preferences/filesystempreferences/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/preferences/filesystempreferences/add.js deleted file mode 100644 index 06dd9dd0e3..0000000000 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/preferences/filesystempreferences/add.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -define(["dojo/_base/xhr", - "dojo/dom", - "dojo/dom-construct", - "dojo/_base/window", - "dijit/registry", - "dojo/parser", - "dojo/_base/array", - "dojo/_base/event", - "dojo/_base/json", - "dojo/string", - "dojox/html/entities", - "dojo/text!../../../../../authenticationprovider/preferences/filesystempreferences/add.html", - "dojo/domReady!"], - function (xhr, dom, domConstruct, win, registry, parser, array, event, json, string, entities, template) { - return { - show: function(node, data) - { - this.destroy(); - this.node = node; - node.innerHTML = template; - parser.parse(node); - var pathWidget = registry.byId("preferencesProvider.path") - if (data) - { - pathWidget.set("value", entities.encode(String(data["path"]))); - } - }, - destroy: function() - { - if (this.node) - { - dojo.forEach(dijit.findWidgets(this.node), function(w) {w.destroyRecursive();}); - this.node = null; - } - }, - disable: function(val) - { - var pathWidget = registry.byId("preferencesProvider.path"); - pathWidget.set("disabled", val); - }, - getValues: function() - { - return {path: registry.byId("preferencesProvider.path").value}; - } - }; - }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/scram-sha-1/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/scram-sha-1/add.js new file mode 100644 index 0000000000..73022a0855 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/scram-sha-1/add.js @@ -0,0 +1,21 @@ +/* + * + * 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. + * + */ +define([], function () { return { show: function(data){} }; }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/scram-sha-256/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/scram-sha-256/add.js new file mode 100644 index 0000000000..73022a0855 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/scram-sha-256/add.js @@ -0,0 +1,21 @@ +/* + * + * 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. + * + */ +define([], function () { return { show: function(data){} }; }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/simpleldap/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/simpleldap/add.js new file mode 100644 index 0000000000..1334ea14fa --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/simpleldap/add.js @@ -0,0 +1,77 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +define(["dojo/_base/xhr","dojo/query","dijit/registry","qpid/common/util","qpid/common/metadata","dojo/store/Memory","dijit/form/FilteringSelect","dijit/form/ValidationTextBox","dijit/form/CheckBox"], + function (xhr, query, registry, util, metadata, Memory) + { + return { + show: function(data) + { + util.parseHtmlIntoDiv(data.containerNode, "authenticationprovider/simpleldap/add.html"); + + var that = this; + xhr.get({url: "api/latest/truststore", sync: true, handleAs: "json"}).then( + function(data) + { + that._initTrustStores(data,data.containerNode); + } + ); + + if (data.data) + { + this._initFields(data.data); + } + }, + _initTrustStores: function(trustStores, containerNode) + { + var data = []; + for (var i=0; i< trustStores.length; i++) + { + data.push( {id: trustStores[i].name, name: trustStores[i].name} ); + } + var trustStoresStore = new Memory({ data: data }); + + var trustStore = registry.byNode(query(".trustStore", data.containerNode)[0]); + trustStore.set("store", trustStoresStore); + }, + _initFields:function(data) + { + var attributes = metadata.getMetaData("AuthenticationProvider", "SimpleLDAP").attributes; + for(var name in attributes) + { + var widget = registry.byNode(query("." + name, data.containerNode)[0]); + if (widget) + { + if (widget instanceof dijit.form.CheckBox) + { + widget.set("checked", data[name]); + } + else + { + widget.set("value", data[name]); + } + } + } + var bindWithoutSearch = + bindWithoutSearch.set("checked", data.data.bindWithoutSearch); + } + }; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js new file mode 100644 index 0000000000..acb09b5fd8 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/PreferencesProviderForm.js @@ -0,0 +1,190 @@ +/* + * + * 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. + * + */ +define([ + "qpid/common/util", + "qpid/common/metadata", + "dojo/_base/xhr", + "dojo/_base/declare", + "dojo/_base/array", + "dojo/dom-construct", + "dojo/_base/window", + "dojo/query", + "dojo/json", + "dijit/_WidgetBase", + "dijit/_OnDijitClickMixin", + "dijit/_TemplatedMixin", + "dijit/_WidgetsInTemplateMixin", + "dijit/registry", + "dojo/text!preferencesprovider/preferencesProviderForm.html", + "dojox/html/entities", + "dijit/form/ValidationTextBox", + "dijit/form/FilteringSelect", + "dojox/validate/us", + "dojox/validate/web", + "dojo/domReady!"], +function (util, metadata, xhr, declare, array, domConstruct, win, query, json, _WidgetBase, + _OnDijitClickMixin, _TemplatedMixin, _WidgetsInTemplateMixin, registry, template, entities) + { + + return declare("qpid.preferencesprovider.PreferencesProviderForm", + [_WidgetBase, _OnDijitClickMixin, _TemplatedMixin, _WidgetsInTemplateMixin], { + + templateString: template, + domNode: null, + preferencesProviderForm : null, + preferencesProviderNameWidget : null, + preferencesProviderTypeWidget : null, + preferencesProviderTypeFieldsContainer: null, + + buildRendering: function() + { + //Strip out the apache comment header from the template html as comments unsupported. + this.templateString = this.templateString.replace(//g, ""); + this.inherited(arguments); + }, + postCreate: function() + { + this.inherited(arguments); + var that = this; + + this.preferencesProviderNameWidget.set("regExpGen", util.nameOrContextVarRegexp); + + var supportedPreferencesProviderTypes = metadata.getTypesForCategory("PreferencesProvider"); + supportedPreferencesProviderTypes.sort(); + supportedPreferencesProviderTypes.splice(0,0,"None"); + var preferencesProviderTypeStore = util.makeTypeStore(supportedPreferencesProviderTypes); + this.preferencesProviderTypeWidget.set("store", preferencesProviderTypeStore); + this.preferencesProviderTypeWidget.on("change", function(type){that._preferencesProviderTypeChanged(type);}); + this.preferencesProviderForm.on("submit", function() { return false; }) + }, + reset: function() + { + this.data = null; + this.preferencesProviderForm.reset(); + this.preferencesProviderTypeWidget.set("value", "None"); + }, + submit: function(encodedAuthenticationProviderName) + { + if (this.preferencesProviderTypeWidget.get("value") != "None") + { + var preferencesProviderData = util.getFormWidgetValues(this.preferencesProviderForm); // TODO initialValues + var encodedPreferencesProviderName = encodeURIComponent(preferencesProviderData.name); + var success = false; + var failureReason = null; + xhr.put({ + url: "api/latest/preferencesprovider/" + encodedAuthenticationProviderName + "/" + encodedPreferencesProviderName, + sync: true, + handleAs: "json", + headers: { "Content-Type": "application/json"}, + putData: json.stringify(preferencesProviderData), + load: function (x) { success = true; }, + error: function (error) { success = false; failureReason = error; } + }); + return { success: success, failureReason: failureReason }; + } + return { success: true, failureReason: null }; + }, + validate: function() + { + return this.preferencesProviderForm.validate(); + }, + load: function(authenticationProviderName, providerName) + { + var that = this; + xhr.get({ + url: "api/latest/preferencesprovider/" + encodeURIComponent(authenticationProviderName) + "/" + encodeURIComponent(providerName), + handleAs: "json" + }).then(function(data){that._load(data[0])}); + }, + _load:function(data) + { + this.data = data; + this.preferencesProviderNameWidget.set("value", data.name); + if (data.type == this.preferencesProviderTypeWidget.get("value")) + { + this._toggleWidgets(data.type); + } + else + { + this.preferencesProviderTypeWidget.set("value", data.type); + } + }, + _preferencesProviderTypeChanged: function(type) + { + var typeFieldsContainer = this.preferencesProviderTypeFieldsContainer; + var widgets = registry.findWidgets(typeFieldsContainer); + array.forEach(widgets, function(item) { item.destroyRecursive();}); + domConstruct.empty(typeFieldsContainer); + this._toggleWidgets(type); + if (type) + { + if (type == "None") + { + this.preferencesProviderNameWidget.set("value", ""); + } + else + { + var that = this; + require([ "qpid/management/preferencesprovider/" + type.toLowerCase() + "/add"], function(typeUI) + { + try + { + typeUI.show({containerNode:typeFieldsContainer, parent: that, data: that.data}); + util.applyMetadataToWidgets(typeFieldsContainer, "PreferencesProvider", type); + } + catch(e) + { + console.warn(e); + } + }); + } + } + }, + _toggleWidgets: function(type) + { + if (this.disabled) + { + this.preferencesProviderNameWidget.set("disabled", true); + this.preferencesProviderTypeWidget.set("disabled", true); + } + else + { + if (this.data) + { + // editing + this.preferencesProviderNameWidget.set("disabled", true); + this.preferencesProviderTypeWidget.set("disabled", true); + } + else + { + this.preferencesProviderNameWidget.set("disabled", !type || type == "None"); + this.preferencesProviderTypeWidget.set("disabled", false); + } + } + }, + _setDisabledAttr: function(disabled) + { + this.inherited(arguments); + this.disabled = disabled; + this.reset(); + }, + }); +}); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/filesystempreferences/add.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/filesystempreferences/add.js new file mode 100644 index 0000000000..d030ea2832 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/preferencesprovider/filesystempreferences/add.js @@ -0,0 +1,35 @@ +/* + * 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. + */ + +define(["dojo/query", "dijit/registry", "qpid/common/util"], + function (query, registry, util) + { + return { + show: function (data) + { + util.parseHtmlIntoDiv(data.containerNode, "preferencesprovider/filesystempreferences/add.html"); + if (data.data) + { + var pathWidget = registry.byNode(query(".addPreferencesProviderPath", data.containerNode)[0]); + pathWidget.set("value", data.data.path); + } + } + }; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/filesystempreferences/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/filesystempreferences/add.html new file mode 100644 index 0000000000..5990b43b98 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/filesystempreferences/add.html @@ -0,0 +1,37 @@ + +
+
+
Path*:
+
+ +
+
+ +
+
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/preferencesProviderForm.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/preferencesProviderForm.html new file mode 100644 index 0000000000..979b3abe8d --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/preferencesprovider/preferencesProviderForm.html @@ -0,0 +1,62 @@ + +
+
+
+
+ Preferences Provider +
+
Name*:
+
+ +
+
+
+
Type*:
+
+ +
+
+
+
+
+
+
+
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferencesProviderFields.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferencesProviderFields.html deleted file mode 100644 index f15a3a71b8..0000000000 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showPreferencesProviderFields.html +++ /dev/null @@ -1,41 +0,0 @@ - -
- - - - - - - - - -
Type*: - -
Name*:
-
- -
-- cgit v1.2.1