From 1dc0a3ab3e145e0f8fdfd71a1205b546a906bd51 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Thu, 7 Oct 2010 14:02:44 -0500 Subject: [PATCH] Certificate management for services. This is an initial implementation of certificate management for services. It addresses the mechanism required to view and update certificates. The complete UI implementation will be addressed in subsequent patches. On the server side, the service.py has been modified to define usercertificate in the service object's takes_params. This is needed to generate the proper JSON metadata which is needed by the UI. It also has been modified to accept null certificate for deletion. On the client side, the service details page has been modified to display the base64-encoded certificate in a text area. When the page is saved, the action handler will store the base64-encoded certificate in the proper JSON structure. Also the service name and service hostname are now displayed in separate fields. The details configuration has been modified to support displaying and updating certificates. The structure is changed to use maps to define sections and fields. A section contains name, label, and an array of fields. A field contains name, label, setup function, load function, and save function. This is used to implement custom interface and behavior for certificates. All other entities, test cases, and test data have been updated accordingly. Some functions and variables have been renamed to improve clarity and consistency. --- install/static/details.js | 348 +++++++++++--------- install/static/entity.js | 50 +-- install/static/group.js | 10 +- install/static/host.js | 10 +- install/static/hostgroup.js | 8 +- install/static/netgroup.js | 10 +- install/static/policy.js | 90 ++--- install/static/serverconfig.js | 52 +-- install/static/service.js | 75 ++++- install/static/test/data/json_metadata.json | 25 ++ install/static/test/data/service_mod.json | 21 ++ install/static/test/data/service_show.json | 5 + install/static/test/details_tests.js | 83 +++-- install/static/user.js | 104 +++--- ipalib/plugins/service.py | 39 +-- 15 files changed, 546 insertions(+), 384 deletions(-) create mode 100644 install/static/test/data/service_mod.json diff --git a/install/static/details.js b/install/static/details.js index 41f3a5101..2daf0a21b 100644 --- a/install/static/details.js +++ b/install/static/details.js @@ -1,6 +1,7 @@ /* Authors: * Pavel Zuna * Adam Young + * Endi S. Dewata * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information @@ -23,35 +24,35 @@ /* REQUIRES: ipa.js */ -var IPA_DETAILS_POPULATE = 1; -var IPA_DETAILS_UPDATE = 2; - var ipa_details_cache = {}; -function ipa_details_create(obj_name, dls, container) +function ipa_details_create(container, sections) { if (!container) { alert('ERROR: ipa_details_create: Missing container argument!'); return; } + var obj_name = container.attr('id'); container.attr('title', obj_name); container.addClass('details-container'); var details = $('
', { - class: 'details' + 'class': 'details' }).appendTo(container); - details.append('
'); - var jobj = details.children().last(); - jobj.append(' Reset'); - jobj.append('Update'); + var buttons = $('
', { + 'class': 'details-buttons' + }).appendTo(details); + + buttons.append(' Reset'); + buttons.append('Update'); details.append('
'); - for (var i = 0; i < dls.length; ++i) { - var d = dls[i]; - ipa_generate_dl(details.children().last(), d[0], d[1], d[2]); + for (var i = 0; i < sections.length; ++i) { + var section = sections[i]; + ipa_details_section_setup(container, details, section); } details.append('
'); @@ -60,49 +61,61 @@ function ipa_details_create(obj_name, dls, container) } -function ipa_generate_dl(jobj, id, name, dts) +function ipa_details_section_setup(container, details, section) { - if (!dts) + var id = section.name; + var name = section.label; + var fields = section.fields; + + if (!fields) return; - var parent = jobj.parent(); - var obj_name = parent.attr('title'); - - parent.append($("

",{ + details.append($("

",{ click: function(){_h2_on_click(this)}, html:"− "+name })); var dl = $('
',{ id:id, - "class":"entryattrs"}) + "class":"entryattrs" + }).appendTo(details); - for (var i = 0; i < dts.length; ++i) { - var label = ''; - var param_info = ipa_get_param_info(obj_name, dts[i][0]); - if (param_info) - label = param_info['label']; - if ((!label) && (dts[i].length > 1)) - label = dts[i][1]; + for (var i = 0; i < fields.length; ++i) { + var field = fields[i]; - var title = dts[i][0]; - if (typeof dts[i][2] == 'function') - title = 'call_' + dts[i][2].name; - dl.append( - $('
', { - title: title, - html: label + ':', - }) - ); + if (field.setup) { + field.setup.call(field, container, dl, section); + + } else { + ipa_details_field_setup.call(field, container, dl, section); + } } - parent.append(dl); - parent.append('
'); + details.append('
'); } -function ipa_details_load(jobj, pkey, on_win, on_fail) +function ipa_details_field_setup(container, dl, section) { + + var obj_name = container.attr('title'); + + var title = this.name; + var label = ''; + var param_info = ipa_get_param_info(obj_name, this.name); + if (param_info) + label = param_info['label']; + if (!label) + label = this.label; + + $('
', { + id: this.name, + title: title, + html: label + ':' + }).appendTo(dl); +} + +function ipa_details_load(container, pkey, on_win, on_fail) { - var obj_name = jobj.attr('id'); + var obj_name = container.attr('id'); function load_on_win(data, text_status, xhr) { if (on_win) @@ -112,18 +125,18 @@ function ipa_details_load(jobj, pkey, on_win, on_fail) var result = data.result.result; ipa_details_cache[obj_name] = $.extend(true, {}, result); - ipa_details_display(obj_name, result); - }; + ipa_details_display(container, result); + } function load_on_fail(xhr, text_status, error_thrown) { if (on_fail) on_fail(xhr, text_status, error_thrown); - var details = $('.details', jobj).empty(); + var details = $('.details', container).empty(); details.append('

Error: '+error_thrown.name+'

'); details.append('

URL: '+this.url+'

'); details.append('

'+error_thrown.message+'

'); - }; + } var params = [pkey]; if (!pkey){ @@ -133,8 +146,10 @@ function ipa_details_load(jobj, pkey, on_win, on_fail) 'show', params, {all: true}, load_on_win, load_on_fail, obj_name ); } -function ipa_details_update(obj_name, pkey, on_win, on_fail) +function ipa_details_update(container, pkey, on_win, on_fail) { + var obj_name = container.attr('id'); + function update_on_win(data, text_status, xhr) { if (on_win) on_win(data, text_status, xhr); @@ -143,79 +158,76 @@ function ipa_details_update(obj_name, pkey, on_win, on_fail) var result = data.result.result; ipa_details_cache[obj_name] = $.extend(true, {}, result); - ipa_details_display(obj_name, result); - }; + ipa_details_display(container, result); + } function update_on_fail(xhr, text_status, error_thrown) { if (on_fail) on_fail(xhr, text_status, error_thrown); - }; + } if (!pkey) return; - var selector = '.details-container[title=' + obj_name + ']'; - + var values; var modlist = {'all': true, 'setattr': [], 'addattr': []}; var attrs_wo_option = {}; - $(selector + ' .entryattrs input').each(function () { - var jobj = $(this); + var sections = ipa_entity_get_details_sections(obj_name); + for (var i=0; i tags i.e. all attribute values */ - $(selector + ' .entryattrs dd').remove(); + $('dd', container).remove(); /* go through all
tags and pair them with newly created
s */ - $(selector + ' .entryattrs dt').each(function () { - var jobj = $(this); + var sections = ipa_entity_get_details_sections(obj_name); + for (var i=0; i",{ - "class":"attrhint", - html:"Hint: " + hint}); - } - } + if (field.load) { + field.load.call(field, dt, entry_attrs); - var value = entry_attrs[attr]; - if (value) { - ipa_insert_first_dd( - jobj, ipa_create_input(obj_name, attr, value[0],hint_span) - ); - for (var i = 1; i < value.length; ++i) { - jobj = jobj.next(); - ipa_insert_other_dd( - jobj, ipa_create_input(obj_name, attr, value[i],hint_span) - ); - } - if (multivalue) { - ipa_insert_other_dd( - jobj.next(), _ipa_a_add_template.replace('A', attr) - ); - } } else { - if (multivalue) { - ipa_insert_first_dd( - jobj, _ipa_a_add_template.replace('A', attr) /*.append( hint_span)*/ - ); - } else { - ipa_insert_first_dd( - jobj, ipa_create_input(obj_name, attr, '')/*.append( hint_span)*/ - ); - } + ipa_details_field_load.call(field, container, dt, entry_attrs); } } - }); + } } +function ipa_details_field_load(container, dt, entry_attrs) { + var obj_name = container.attr('id'); -function ipa_insert_first_dd(jobj, content) -{ - jobj.after( $('
').append(content)) + var multivalue = false; + var hint_span = null; + var dd; + var param_info = ipa_get_param_info(obj_name, this.name); + if (param_info) { + if (param_info['multivalue'] || param_info['class'] == 'List') + multivalue = true; + var hint = param_info['hint']; + if (hint){ + hint_span = $('',{ + 'class': 'attrhint', + 'html': 'Hint: ' + hint}); + } + } + + var value = entry_attrs[this.name]; + if (value) { + dd = ipa_create_first_dd( + this.name, ipa_create_input(obj_name, this.name, value[0],hint_span) + ); + dt.after(dd); + var last_dd = dd; + for (var i = 1; i < value.length; ++i) { + dd = ipa_create_other_dd( + this.name, ipa_create_input(obj_name, this.name, value[i],hint_span) + ); + last_dd.after(dd); + last_dd = dd; + } + if (multivalue) { + dd = ipa_create_other_dd( + this.name, _ipa_a_add_template.replace('A', this.name) + ); + last_dd.after(dd); + } + } else { + if (multivalue) { + dd = ipa_create_first_dd( + this.name, _ipa_a_add_template.replace('A', this.name) /*.append(hint_span)*/ + ); + dt.after(dd); + } else { + dd = ipa_create_first_dd( + this.name, ipa_create_input(obj_name, this.name, '') /*.append(hint_span)*/ + ); + dt.after(dd); + } + } } -function ipa_insert_other_dd(jobj, content) +function ipa_create_first_dd(field_name, content) { - jobj.after($('
').append(content)); + return $('
', { + + 'class': 'first', + 'title': field_name + }).append(content); +} + +function ipa_create_other_dd(field_name, content) +{ + return $('
', { + 'class': 'other', + 'title': field_name + }).append(content); } @@ -412,15 +445,17 @@ function _ipa_create_text_input(attr, value, param_info) })).after($("",{ html:"Does not match pattern", "class":"ui-state-error ui-corner-all", - style:"display:none", + style:"display:none" })); } -function ipa_details_reset(obj_name) +function ipa_details_reset(container) { + var obj_name = container.attr('id'); + if (ipa_details_cache[obj_name]){ - ipa_details_display(obj_name, ipa_details_cache[obj_name]); + ipa_details_display(container, ipa_details_cache[obj_name]); } } @@ -435,7 +470,8 @@ function _ipa_add_on_click(obj) var obj_name = jobj.closest('.details-container').attr('title'); par.prepend(ipa_create_input(obj_name, attr, '')); - ipa_insert_other_dd(par, _ipa_a_add_template.replace('A', attr)); + var dd = ipa_create_other_dd(field.name, _ipa_a_add_template.replace('A', attr)); + par.after(dd); jobj.next('input').focus(); jobj.remove(); @@ -448,7 +484,7 @@ function _ipa_remove_on_click(obj) var attr = jobj.attr('title'); var par = jobj.parent(); - var next = par.next('dd'); + var next = par.next('dd[title='+attr+']'); if (next.length) { if (par.hasClass('first')) { var hint = par.children('span').detach(); diff --git a/install/static/entity.js b/install/static/entity.js index e77d46513..c911c0f23 100644 --- a/install/static/entity.js +++ b/install/static/entity.js @@ -44,6 +44,13 @@ function ipa_entity_set_details_definition(obj_name, data) ipa_entity_details_list[obj_name] = data; } +function ipa_entity_get_details_sections(obj_name) +{ + var sections = ipa_entity_details_list[obj_name]; + if (sections) return sections; + return []; +} + function ipa_entity_set_association_definition(obj_name, data) { ipa_entity_association_list[obj_name] = data; @@ -95,25 +102,25 @@ function ipa_entity_setup(container, unspecified) } } -function _ipa_entity_setup(jobj,unspecified) { +function _ipa_entity_setup(container, unspecified) { - var obj_name = jobj.attr('id'); + var obj_name = container.attr('id'); function reset_on_click() { - ipa_details_reset(obj_name); + ipa_details_reset(container); return (false); - }; + } function update_on_click() { var pkey_name = ipa_objs[obj_name].primary_key; - ipa_details_update(obj_name, ipa_details_cache[obj_name][pkey_name][0]); + ipa_details_update(container, ipa_details_cache[obj_name][pkey_name][0]); return (false); - }; + } function new_on_click() { add_dialog_create(obj_name, ipa_entity_add_list[obj_name]); return (false); - }; + } function switch_view() { var enroll_obj_name = $(this).attr('title'); @@ -126,11 +133,11 @@ function _ipa_entity_setup(jobj,unspecified) { state[obj_name + '-enroll'] = ''; } $.bbq.pushState(state); - }; + } function setup_search_facet() { var filter = $.bbq.getState(obj_name + '-filter', true) || ''; - search_create(obj_name, ipa_entity_search_list[obj_name], jobj); + search_create(obj_name, ipa_entity_search_list[obj_name], container); $('',{ type:"submit", @@ -138,20 +145,21 @@ function _ipa_entity_setup(jobj,unspecified) { click:new_on_click }).appendTo($( "div#" + obj_name + " > div.search-controls")); - search_load(jobj, filter, null, null); - }; + search_load(container, filter, null, null); + } function setup_details_facet(unspecified) { var pkey = $.bbq.getState(obj_name + '-pkey', true); - ipa_entity_generate_views(obj_name, jobj, switch_view); - ipa_details_create(obj_name, ipa_entity_details_list[obj_name], jobj); - jobj.find('.details-reset').click(reset_on_click); - jobj.find('.details-update').click(update_on_click); + ipa_entity_generate_views(obj_name, container, switch_view); + var sections = ipa_entity_get_details_sections(obj_name); + ipa_details_create(container, sections); + container.find('.details-reset').click(reset_on_click); + container.find('.details-update').click(update_on_click); if (pkey||unspecified){ - ipa_details_load(jobj, pkey, null, null); + ipa_details_load(container, pkey, null, null); } - }; + } function setup_associate_facet() { var pkey = $.bbq.getState(obj_name + '-pkey', true) || ''; @@ -170,15 +178,15 @@ function _ipa_entity_setup(jobj,unspecified) { var method = association_config ? association_config.method : null; var frm = new AssociationList( - obj_name, pkey, enroll_obj_name, columns, jobj, + obj_name, pkey, enroll_obj_name, columns, container, associator, method ); - ipa_entity_generate_views(obj_name, jobj, switch_view); + ipa_entity_generate_views(obj_name, container, switch_view); frm.setup(); - }; + } - jobj.empty(); + container.empty(); var facet = $.bbq.getState(obj_name + '-facet', true) || unspecified || 'search'; diff --git a/install/static/group.js b/install/static/group.js index 591184de5..3770e1fb1 100644 --- a/install/static/group.js +++ b/install/static/group.js @@ -37,11 +37,11 @@ ipa_entity_set_add_definition('group', [ ]); ipa_entity_set_details_definition('group', [ - ['identity', 'Group Details', [ - ['cn', 'Group Name'], - ['description', 'Description'], - ['gidnumber', 'Group ID'] - ]] + {name:'identity', label:'Group Details', fields:[ + {name:'cn', label:'Group Name'}, + {name:'description', label:'Description'}, + {name:'gidnumber', label:'Group ID'} + ]} ]); ipa_entity_set_association_definition('group', { diff --git a/install/static/host.js b/install/static/host.js index d19ac0d00..907f24dfd 100644 --- a/install/static/host.js +++ b/install/static/host.js @@ -35,11 +35,11 @@ ipa_entity_set_add_definition('host', [ ]); ipa_entity_set_details_definition('host', [ - ['host', 'Host Details', [ - ['fqdn', 'Fully Qualified Domain Name', null], - ['krbprincipalname', 'Kerberos Principal', null], - ['serverhostname', 'Server Host Name', null] - ]] + {name:'host', label:'Host Details', fields:[ + {name:'fqdn', label:'Fully Qualified Domain Name'}, + {name:'krbprincipalname', label:'Kerberos Principal'}, + {name:'serverhostname', label:'Server Host Name'} + ]} ]); ipa_entity_set_association_definition('host', { diff --git a/install/static/hostgroup.js b/install/static/hostgroup.js index fd062dc5e..58a20588a 100644 --- a/install/static/hostgroup.js +++ b/install/static/hostgroup.js @@ -34,8 +34,8 @@ ipa_entity_set_add_definition('hostgroup', [ ]); ipa_entity_set_details_definition('hostgroup', [ - ['identity', 'Hostgroup Details', [ - ['cn', 'Name', null], - ['description', 'Description', null] - ]] + {name:'identity', label:'Hostgroup Details', fields:[ + {name:'cn', label:'Name'}, + {name:'description', label:'Description'} + ]} ]); diff --git a/install/static/netgroup.js b/install/static/netgroup.js index 577590ac2..7e8868fed 100644 --- a/install/static/netgroup.js +++ b/install/static/netgroup.js @@ -34,10 +34,10 @@ ipa_entity_set_add_definition('netgroup', [ ]); ipa_entity_set_details_definition('netgroup', [ - ['identity', 'Netgroup Details', [ - ['cn', 'Name', null], - ['description', 'Description', null], - ['nisdomainname', 'NIS Domain', null] - ]] + {name:'identity', label:'Netgroup Details', fields:[ + {name:'cn', label:'Name'}, + {name:'description', label:'Description'}, + {name:'nisdomainname', label:'NIS Domain'} + ]} ]); diff --git a/install/static/policy.js b/install/static/policy.js index 7f0d43b5b..257ede592 100644 --- a/install/static/policy.js +++ b/install/static/policy.js @@ -28,21 +28,21 @@ ipa_entity_set_search_definition('hbac', [ ipa_entity_set_add_definition('hbac', [ 'dialog-add-hbac', 'Add New Zone', [ - ['cn', 'Name', null], + ['cn', 'Name', null] ] ]); ipa_entity_set_details_definition('hbac', [ - ['identity', 'HBAC Details', [ - ['cn', 'HBAC Name'], - ["accessruletype", "Rule Type"], - [ "description", "Description"], - ["hostcategory", "Host Category"], - ["ipaenabledflag", "Enabled"], - ["servicecategory", "Service Category"], - ["sourcehostcategory", "Source Host Category"], - ["usercategory", "User Category"] - ]] + {name:'identity', label:'HBAC Details', fields:[ + {name:'cn', label:'HBAC Name'}, + {name:'accessruletype', label:'Rule Type'}, + {name:'description', label:'Description'}, + {name:'hostcategory', label:'Host Category'}, + {name:'ipaenabledflag', label:'Enabled'}, + {name:'servicecategory', label:'Service Category'}, + {name:'sourcehostcategory', label:'Source Host Category'}, + {name:'usercategory', label:'User Category'} + ]} ]); ipa_entity_set_association_definition('hbac', { @@ -58,26 +58,26 @@ ipa_entity_set_add_definition('dns', [ 'dialog-add-dns', 'Add New Zone', [ ['idnsname', 'Name', null], ['idnssoamname', 'Authoritative name server'], - ['idnssoarname','administrator e-mail address'], + ['idnssoarname','administrator e-mail address'] ] ]); ipa_entity_set_details_definition('dns', [ - ['identity', 'DNS Zone Details', [ - ['idnsname', 'DNS Name'], - ['idnszoneactive', 'Zone Active'], - ['idnssoamname', 'Authoritative name server'], - ['idnssoarname','administrator e-mail address'], - ['idnssoaserial', 'SOA serial'], - ['idnssoarefresh', 'SOA refresh'], - ['idnssoaretry', 'SOA retry'], - ['idnssoaexpire','SOA expire'], - ['idnssoaminimum', 'SOA minimum'], - ['dnsttl','SOA time to live'], - ['dnsclass','SOA class'], - ['idnsallowdynupdate','allow dynamic update?'], - ['idnsupdatepolicy', 'BIND update policy'], - ]] + {name:'identity', label:'DNS Zone Details', fields:[ + {name:'idnsname', label:'DNS Name'}, + {name:'idnszoneactive', label:'Zone Active'}, + {name:'idnssoamname', label:'Authoritative name server'}, + {name:'idnssoarname', label:'administrator e-mail address'}, + {name:'idnssoaserial', label:'SOA serial'}, + {name:'idnssoarefresh', label:'SOA refresh'}, + {name:'idnssoaretry', label:'SOA retry'}, + {name:'idnssoaexpire',label:'SOA expire'}, + {name:'idnssoaminimum', label:'SOA minimum'}, + {name:'dnsttl', label:'SOA time to live'}, + {name:'dnsclass', label:'SOA class'}, + {name:'idnsallowdynupdate', label:'allow dynamic update?'}, + {name:'idnsupdatepolicy', label:'BIND update policy'} + ]} ]); ipa_entity_set_association_definition('dns', { @@ -94,14 +94,15 @@ ipa_entity_set_search_definition('automountlocation', [ ipa_entity_set_add_definition('automountlocation', [ 'dialog-add-location', 'Add New Location', [ - ['cn', 'Name', null], + ['cn', 'Name', null] ] ]); ipa_entity_set_details_definition('automountlocation', [ - ['identity', 'Automount Location Details', [ - ['cn', 'Automount Location'],] -]]); + {name:'identity', label:'Automount Location Details', fields:[ + {name:'cn', label:'Automount Location'} + ]} +]); ipa_entity_set_association_definition('automountlocation', { }); @@ -117,18 +118,18 @@ ipa_entity_set_search_definition('pwpolicy', [ ipa_entity_set_add_definition('pwpolicy', [ 'dialog-add-dns', 'Add New Location', [ - ['cn', 'Name', null], + ['cn', 'Name', null] ] ]); ipa_entity_set_details_definition('pwpolicy', [ - ['identity', 'Password Policy', [ - ["krbmaxpwdlife","Max Password Life"], - ["krbminpwdlife","Min Password Life"], - ["krbpwdhistorylength","Password History Length"], - ["krbpwdmindiffchars", "Min Different Characters"], - ["krbpwdminlength", "Password Minimum Length"] - ]] + {name:'identity', label:'Password Policy', fields:[ + {name:'krbmaxpwdlife', label:'Max Password Life'}, + {name:'krbminpwdlife', label:'Min Password Life'}, + {name:'krbpwdhistorylength', label:'Password History Length'}, + {name:'krbpwdmindiffchars', label:'Min Different Characters'}, + {name:'krbpwdminlength', label:'Password Minimum Length'} + ]} ]); ipa_entity_set_association_definition('pwpolicy', { @@ -141,11 +142,12 @@ ipa_entity_set_association_definition('pwpolicy', { */ ipa_entity_set_details_definition('krbtpolicy', [ - ['identity', 'Krbtpolicy Location Details', [ - ['cn', 'Krbtpolicy Location'], - ["krbmaxrenewableage", "Max Renewable Age"], - ["krbmaxticketlife", "Max Ticket Life"] -]]]); + {name:'identity', label:'Krbtpolicy Location Details', fields:[ + {name:'cn', label:'Krbtpolicy Location'}, + {name:'krbmaxrenewableage', label:'Max Renewable Age'}, + {name:'krbmaxticketlife', label:'Max Ticket Life'} + ]} +]); ipa_entity_set_association_definition('krbtpolicy', { }); diff --git a/install/static/serverconfig.js b/install/static/serverconfig.js index 97a436fd3..1d25a3b08 100644 --- a/install/static/serverconfig.js +++ b/install/static/serverconfig.js @@ -37,10 +37,10 @@ ipa_entity_set_add_definition('aci', [ ]); ipa_entity_set_details_definition('aci', [ - ['ipaserver', 'Aci Details', [ - ['cn', 'Name', null], - ['description', 'Description', null], - ]] + {name:'ipaserver', label:'Aci Details', fields:[ + {name:'cn', label:'Name'}, + {name:'description', label:'Description'} + ]} ]); @@ -60,10 +60,10 @@ ipa_entity_set_add_definition('taskgroup', [ ]); ipa_entity_set_details_definition('taskgroup', [ - ['ipaserver', 'Taskgroup Details', [ - ['cn', 'Name', null], - ['description', 'Description', null], - ]] + {name:'ipaserver', label:'Taskgroup Details', fields:[ + {name:'cn', label:'Name'}, + {name:'description', label:'Description'} + ]} ]); ipa_entity_set_association_definition('rolegroup', { @@ -89,10 +89,10 @@ ipa_entity_set_add_definition('rolegroup', [ ]); ipa_entity_set_details_definition('rolegroup', [ - ['ipaserver', 'Rolegroup Details', [ - ['cn', 'Name', null], - ['description', 'Description', null], - ]] + {name:'ipaserver', label:'Rolegroup Details', fields:[ + {name:'cn', label:'Name'}, + {name:'description', label:'Description'} + ]} ]); ipa_entity_set_association_definition('rolegroup', { @@ -101,18 +101,18 @@ ipa_entity_set_association_definition('rolegroup', { /* Configuration */ ipa_entity_set_details_definition('config',[ - ['ipaserver', 'Configuration', [ - ['cn', 'Name', null], - ['description', 'Description', null], - ['ipacertificatesubjectbase', 'Certificat Subject Base',null], - [ 'ipadefaultloginshell', 'Default Login Shell',null], - ['ipadefaultprimarygroup', 'Default Primary Group',null], - ['ipagroupsearchfields', 'Group Search Fields',null], - ['ipahomesrootdir', 'Home Root Dir',null], - ['ipamaxusernamelength', 'Max Username Length',null], - ['ipamigrationenabled', 'Migration enabled?',null], - ['ipasearchrecordslimit', 'Search Record Limit',null], - ['ipasearchtimelimit', 'Search Time Limit',null], - ['ipausersearchfields', 'User Search Fields',null] - ]] + {name:'ipaserver', label:'Configuration', fields:[ + {name:'cn', label:'Name'}, + {name:'description', label:'Description'}, + {name:'ipacertificatesubjectbase', label:'Certificat Subject Base'}, + {name:'ipadefaultloginshell', label:'Default Login Shell'}, + {name:'ipadefaultprimarygroup', label:'Default Primary Group'}, + {name:'ipagroupsearchfields', label:'Group Search Fields'}, + {name:'ipahomesrootdir', label:'Home Root Dir'}, + {name:'ipamaxusernamelength', label:'Max Username Length'}, + {name:'ipamigrationenabled', label:'Migration enabled?'}, + {name:'ipasearchrecordslimit', label:'Search Record Limit'}, + {name:'ipasearchtimelimit', label:'Search Time Limit'}, + {name:'ipausersearchfields', label:'User Search Fields'} + ]} ]); diff --git a/install/static/service.js b/install/static/service.js index 43ef968a0..0afcb4688 100644 --- a/install/static/service.js +++ b/install/static/service.js @@ -29,18 +29,21 @@ ipa_entity_set_add_definition('service', [ 'dialog-add-service', 'Add New Service', [ ['krbprincipalname', 'Principal', service_add_krbprincipalname], ['service', 'Service', null], - ['host', 'Host Name', null], + ['host', 'Host Name', null] ] ]); ipa_entity_set_details_definition('service', [ - ['identity', 'Service Details', [ - ['krbprincipalname', 'Principal', null], - ]] + {name:'identity', label:'Service Details', fields:[ + {name:'krbprincipalname', label:'Principal', setup:service_krbprincipalname_setup, load:service_krbprincipalname_load}, + {name:'service', label:'Service', load:service_service_load}, + {name:'host', label:'Host Name', load:service_host_load}, + {name:'usercertificate', label:'Certificate', load:service_usercertificate_load, save:service_usercertificate_save} + ]} ]); -function service_add_krbprincipalname(add_dialog, flag) { - if (flag == IPA_ADD_UPDATE) { +function service_add_krbprincipalname(add_dialog, mode) { + if (mode == IPA_ADD_UPDATE) { var service = add_dialog.find('input[name=service]').val(); var host = add_dialog.find('input[name=host]').val(); return service+'/'+host; @@ -51,3 +54,63 @@ function service_add_krbprincipalname(add_dialog, flag) { ipa_entity_set_association_definition('service', { 'host': { method: 'add_host' } }); + +function service_krbprincipalname_setup(container, dl, section) { + // skip krbprincipalname +} + +function service_krbprincipalname_load(dt, result) { + // skip krbprincipalname +} + +function service_service_load(dt, result) { + var krbprincipalname = result['krbprincipalname'][0]; + var service = krbprincipalname.replace(/\/.*$/, ''); + var dd = ipa_create_first_dd(this.name, service); + dt.after(dd); +} + +function service_host_load(dt, result) { + var krbprincipalname = result['krbprincipalname'][0]; + var host = krbprincipalname.replace(/^.*\//, ''); + var dd = ipa_create_first_dd(this.name, host); + dt.after(dd); +} + +function service_usercertificate_load(dt, result) { + var textarea = $("