diff --git a/install/ui/field.js b/install/ui/field.js
index c79c59bb4..46802be6c 100644
--- a/install/ui/field.js
+++ b/install/ui/field.js
@@ -148,22 +148,28 @@ IPA.field = function(spec) {
that.load = function(record) {
that.record = record;
- var value = record[that.name];
- if (value instanceof Array) {
- that.values = value;
- } else {
- that.values = value !== undefined ? [value] : [];
- }
-
- if (!that.values.length) {
- that.values = [''];
- }
+ that.values = that.get_value(record, that.name);
that.load_writable(record);
that.reset();
};
+ that.get_value = function(record, name) {
+
+ var value = record[name];
+
+ if (!(value instanceof Array)) {
+ value = value !== undefined ? [value] : [];
+ }
+
+ if (!value.length) {
+ value = [''];
+ }
+
+ return value;
+ };
+
that.load_writable = function(record) {
that.writable = true;
@@ -272,16 +278,21 @@ IPA.field = function(spec) {
//compare values in array
if (values.length !== that.values.length) return true;
- values.sort();
- that.values.sort();
+ return !that.dirty_are_equal(that.values, values);
+ };
- for (var i=0; i', {
+ 'class': 'sshkey-status',
+ text: ''
+ }).appendTo(container);
+
+ that.link = $('', {
+ type: that.type,
+ 'class': 'sshkey-set',
+ name: that.name,
+ href: '#show-certificate',
+ title: that.tooltip,
+ text: IPA.messages.objects.sshkeystore.show_set_key,
+ onclick: function() {
+ that.open_edit_dialog();
+ return false;
+ }
+ }).appendTo(container);
+
+ if (that.undo) {
+ that.create_undo(container);
+ }
+
+ that.create_error_link(container);
+ };
+
+ that.update = function(values) {
+
+ var key = values && values.length ? values[0] : null;
+
+ if (!key || key === '') {
+ key = {};
+ }
+
+ that.key = $.extend({}, key);
+
+ if (that.key.key && that.key.key !== '' &&
+ that.key.fingerprint && that.key.fingerprint !== '') {
+ that.originally_set = true;
+ that.original_key = that.key.key;
+ }
+ that.update_link();
+ };
+
+ that.set_deleted = function(deleted) {
+ if (deleted) {
+ that.status_label.addClass('strikethrough');
+ } else {
+ that.status_label.removeClass('strikethrough');
+ }
+ };
+
+ that.save = function() {
+ var value = that.key.key;
+ value = value ? [value] : [''];
+ return value;
+ };
+
+ that.update_link = function() {
+ var text = that.get_status();
+ that.status_label.text(text);
+ };
+
+ that.get_status = function() {
+
+ var text = '';
+ var value = that.key.key;
+
+ if (that.original_key) {
+
+ if (value !== that.original_key) {
+ if (value === '') {
+ text = IPA.messages.objects.sshkeystore.status_mod_ns;
+ } else {
+ text = IPA.messages.objects.sshkeystore.status_mod_s;
+ }
+ } else {
+ text = that.key.fingerprint;
+ }
+
+ } else {
+
+ if (!value || value === '') {
+ text = IPA.messages.objects.sshkeystore.status_new_ns;
+ } else {
+ text = IPA.messages.objects.sshkeystore.status_new_s;
+ }
+ }
+
+ return text;
+ };
+
+ that.set_user_value = function(value) {
+
+ var previous = that.key.key;
+ that.key.key = value;
+ that.update_link();
+
+ if (value !== previous) {
+ that.value_changed.notify([], that);
+ }
+ };
+
+ that.open_edit_dialog = function() {
+
+ var dialog = that.create_edit_dialog();
+ dialog.open();
+ };
+
+ that.create_edit_dialog = function() {
+
+ var dialog = IPA.dialog({
+ title: IPA.messages.objects.sshkeystore.set_dialog_title,
+ width: 500,
+ height: 380
+ });
+
+ dialog.message = IPA.messages.objects.sshkeystore.set_dialog_help;
+
+ dialog.create_button({
+ name: 'update',
+ label: IPA.messages.buttons.set,
+ click: function() {
+ var value = dialog.textarea.val();
+ that.set_user_value(value);
+ dialog.close();
+ }
+ });
+
+ dialog.create_button({
+ name: 'cancel',
+ label: IPA.messages.buttons.cancel,
+ click: function() {
+ dialog.close();
+ }
+ });
+
+ dialog.create = function() {
+
+ dialog.container.append(dialog.message);
+
+ dialog.textarea = $('', {
+ 'class': 'certificate',
+ readonly: that.read_only
+ }).appendTo(dialog.container);
+
+ var key = that.key.key || '';
+ dialog.textarea.val(key);
+ };
+
+ return dialog;
+ };
+
+ return that;
+};
+
IPA.widget_factories['attribute_table'] = IPA.attribute_table_widget;
IPA.widget_factories['checkbox'] = IPA.checkbox_widget;
@@ -2825,9 +3024,10 @@ IPA.widget_factories['enable'] = IPA.enable_widget;
IPA.widget_factories['entity_select'] = IPA.entity_select_widget;
IPA.widget_factories['header'] = IPA.header_widget;
IPA.widget_factories['link'] = IPA.link_widget;
-IPA.widget_factories['multivalued'] = IPA.multivalued_text_widget;
+IPA.widget_factories['multivalued'] = IPA.multivalued_widget;
IPA.widget_factories['password'] = IPA.password_widget;
IPA.widget_factories['radio'] = IPA.radio_widget;
IPA.widget_factories['select'] = IPA.select_widget;
+IPA.widget_factories['sshkeys'] = IPA.sshkeys_widget;
IPA.widget_factories['textarea'] = IPA.textarea_widget;
IPA.widget_factories['text'] = IPA.text_widget;
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 805f458a2..7557ff99c 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -194,6 +194,7 @@ class i18n_messages(Command):
"restore": _("Restore"),
"retry": _("Retry"),
"revoke": _("Revoke"),
+ "set": _("Set"),
"update": _("Update"),
"view": _("View"),
},
@@ -457,6 +458,16 @@ class i18n_messages(Command):
"unprovision_title": _("Unprovisioning ${entity}"),
"valid": _("Kerberos Key Present, Service Provisioned"),
},
+ "sshkeystore": {
+ "keys": _("SSH public keys"),
+ "set_dialog_help": _("Base-64 encoded SSH public key:"),
+ "set_dialog_title": _("Set SSH key"),
+ "show_set_key": _("Show/Set key"),
+ "status_mod_ns": _("Modified: key not set"),
+ "status_mod_s": _("Modified"),
+ "status_new_ns": _("New: key not set"),
+ "status_new_s": _("New: key set"),
+ },
"sudocmd": {
"groups": _("Groups"),
},