/* Authors: * Endi Sukma Dewata * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ define([ './ipa', './jquery', './phases', './reg', './rpc', './text', './details', './search', './association', './entity'], function(IPA, $, phases, reg, rpc, text) { var exp =IPA.service = {}; var make_spec = function() { return { name: 'service', policies: [ IPA.search_facet_update_policy, IPA.details_facet_update_policy, { $factory: IPA.cert.cert_update_policy, source_facet: 'details', dest_entity: 'cert', dest_facet: 'details' }, { $factory: IPA.cert.cert_update_policy, source_facet: 'details', dest_entity: 'cert', dest_facet: 'search' } ], facets: [ { $type: 'search', columns: [ 'krbprincipalname' ] }, { $type: 'details', $factory: IPA.service.details_facet, sections: [ { name: 'details', fields: [ 'krbprincipalname', { $type: 'service_name', name: 'service', label: '@i18n:objects.service.service', read_only: true }, { $type: 'service_host', name: 'host', label: '@i18n:objects.service.host', read_only: true }, { name: 'ipakrbauthzdata', $type: 'radio', layout: 'vertical', options: [ { label: '@i18n:krbauthzdata.inherited', value: '' }, { label: '@i18n:krbauthzdata.override', name: 'ipakrbauthzdata_override', $factory: IPA.option_widget_base, input_type: 'checkbox', value: 'NONE', combine_values: false, options: [ { label: '@i18n:krbauthzdata.mspac', value: 'MS-PAC' }, { label: '@i18n:krbauthzdata.pad', value: 'PAD' } ] } ] }, { name: 'ipakrbokasdelegate', $type: 'checkbox', acl_param: 'krbticketflags' } ] }, { name: 'provisioning', action_panel: { $factory: IPA.action_panel, name: 'provisioning_actions', actions: ['unprovision'] }, fields: [ { $type: 'service_provisioning_status', name: 'has_keytab', label: '@i18n:objects.service.status' } ] }, { name: 'certificate', action_panel: { $factory: IPA.action_panel, name: 'cert_actions', actions: [ 'request_cert', 'view_cert', 'get_cert', 'revoke_cert', 'restore_cert' ] }, fields: [ { $type: 'certificate_status', name: 'certificate_status', label: '@i18n:objects.service.status' } ] } ], actions: [ 'service_unprovision', 'cert_view', 'cert_get', 'cert_request', 'cert_revoke', 'cert_restore' ], state: { evaluators: [ IPA.service.has_keytab_evaluator, IPA.service.krbprincipalkey_acl_evaluator, IPA.cert.certificate_evaluator ] }, policies: [ IPA.service.certificate_policy ] }, { $type: 'association', name: 'managedby_host', add_method: 'add_host', remove_method: 'remove_host' } ], standard_association_facets: true, adder_dialog: { $factory: IPA.service_adder_dialog, height: 350, sections: [ { fields: [ { $type: 'combobox', name: 'service', label: '@i18n:objects.service.service', options: [ 'cifs', 'DNS', 'ftp', 'HTTP', 'imap', 'ldap', 'libvirt', 'nfs', 'smtp', 'qpidd' ], editable: true, size: 10, required: true, z_index: 2 }, { $type: 'entity_select', name: 'host', other_entity: 'host', other_field: 'fqdn', label: '@i18n:objects.service.host', required: true, z_index: 1 }, { $type: 'checkbox', name: 'force', metadata: '@mc-opt:service_add:force' } ] } ] } };}; IPA.service.details_facet = function(spec, no_init) { var that = IPA.details_facet(spec, true); that.certificate_loaded = IPA.observer(); that.certificate_updated = IPA.observer(); if (!no_init) that.init_details_facet(); return that; }; IPA.service_adder_dialog = function(spec) { spec = spec || {}; var that = IPA.entity_adder_dialog(spec); var init = function() { //small hack - krbprincipalname should not be displayed. This way //creation of associated widget is skipped. //In future it would be better split section definion into widget and //fields definition and create custom field with two associated //widgets - 'service' and 'host' with this dialog's save logic. that.builder.build_field({ $type: 'field', name: 'krbprincipalname', required: false }); }; that.save = function(record) { var field = that.fields.get_field('service'); var service = field.save()[0]; field = that.fields.get_field('host'); var host = field.save()[0]; record['krbprincipalname'] = [ service+'/'+host ]; field = that.fields.get_field('force'); record['force'] = field.save(); }; init(); return that; }; IPA.service_name_field = function(spec) { spec = spec || {}; var that = IPA.field(spec); that.load = function(record) { that.field_load(record); var krbprincipalname = record.krbprincipalname[0]; var value = krbprincipalname.replace(/\/.*$/, ''); that.values = [value]; that.reset(); }; return that; }; IPA.service_host_field = function(spec) { spec = spec || {}; var that = IPA.field(spec); that.load = function(record) { that.field_load(record); var krbprincipalname = record.krbprincipalname[0]; var value = krbprincipalname.replace(/^.*\//, '').replace(/@.*$/, ''); that.values = [value]; that.reset(); }; return that; }; IPA.service_provisioning_status_widget = function (spec) { spec = spec || {}; var that = IPA.input_widget(spec); that.create = function(container) { that.widget_create(container); that.status_valid = $('
', { name: 'kerberos-key-valid', 'class': 'provisioning-status', style: 'display: none;' }).appendTo(container); var content = $('