2011-01-14 12:16:25 -05:00
|
|
|
/*jsl:import ipa.js */
|
|
|
|
|
|
2010-10-15 12:22:01 -05:00
|
|
|
/* Authors:
|
|
|
|
|
* Endi Sukma Dewata <edewata@redhat.com>
|
2012-06-12 14:28:30 +02:00
|
|
|
* Petr Vobornik <pvoborni@redhat.com>
|
2010-10-15 12:22:01 -05:00
|
|
|
*
|
|
|
|
|
* Copyright (C) 2010 Red Hat
|
|
|
|
|
* see file 'COPYING' for use and warranty information
|
|
|
|
|
*
|
2010-12-09 13:59:11 +01:00
|
|
|
* 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.
|
2010-10-15 12:22:01 -05:00
|
|
|
*
|
|
|
|
|
* 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
|
2010-12-09 13:59:11 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-10-15 12:22:01 -05:00
|
|
|
*/
|
|
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
IPA.cert = {};
|
|
|
|
|
|
|
|
|
|
IPA.cert.BEGIN_CERTIFICATE = '-----BEGIN CERTIFICATE-----';
|
|
|
|
|
IPA.cert.END_CERTIFICATE = '-----END CERTIFICATE-----';
|
|
|
|
|
|
|
|
|
|
IPA.cert.BEGIN_CERTIFICATE_REQUEST = '-----BEGIN CERTIFICATE REQUEST-----';
|
|
|
|
|
IPA.cert.END_CERTIFICATE_REQUEST = '-----END CERTIFICATE REQUEST-----';
|
|
|
|
|
|
2011-10-18 18:19:25 -04:00
|
|
|
/*
|
|
|
|
|
* Pre-compiled regular expression to match a PEM cert.
|
|
|
|
|
*
|
|
|
|
|
* regexp group 1: entire canonical cert (delimiters plus base64)
|
|
|
|
|
* regexp group 2: base64 data inside PEM delimiters
|
|
|
|
|
*/
|
|
|
|
|
IPA.cert.PEM_CERT_REGEXP = RegExp('(-----BEGIN CERTIFICATE-----([^-]*)-----END CERTIFICATE-----)');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Pre-compiled regular expression to match a CSR (Certificate Signing Request).
|
|
|
|
|
* The delimiter "CERTIFICATE REQUEST" is the cononical standard, however some legacy
|
|
|
|
|
* software will produce a delimiter with "NEW" in it, i.e. "NEW CERTIFICATE REQUEST"
|
|
|
|
|
* This regexp will work with either form.
|
|
|
|
|
*
|
|
|
|
|
* regexp group 1: entire canonical CSR (delimiters plus base64)
|
|
|
|
|
* regexp group 2: base64 data inside canonical CSR delimiters
|
|
|
|
|
* regexp group 3: entire legacy CSR (delimiters plus base64)
|
|
|
|
|
* regexp group 4: base64 data inside legacy CSR delimiters
|
|
|
|
|
*/
|
|
|
|
|
IPA.cert.PEM_CSR_REGEXP = RegExp('(-----BEGIN CERTIFICATE REQUEST-----([^-]*)-----END CERTIFICATE REQUEST-----)|(-----BEGIN NEW CERTIFICATE REQUEST-----([^-]*)-----END NEW CERTIFICATE REQUEST-----)');
|
|
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
IPA.cert.CERTIFICATE_STATUS_MISSING = 0;
|
|
|
|
|
IPA.cert.CERTIFICATE_STATUS_VALID = 1;
|
|
|
|
|
IPA.cert.CERTIFICATE_STATUS_REVOKED = 2;
|
|
|
|
|
|
|
|
|
|
IPA.cert.CRL_REASON = [
|
2011-06-30 14:33:33 -04:00
|
|
|
'unspecified',
|
|
|
|
|
'key_compromise',
|
|
|
|
|
'ca_compromise',
|
|
|
|
|
'affiliation_changed',
|
|
|
|
|
'superseded',
|
|
|
|
|
'cessation_of_operation',
|
|
|
|
|
'certificate_hold',
|
2011-02-16 12:46:59 -06:00
|
|
|
null,
|
2011-06-30 14:33:33 -04:00
|
|
|
'remove_from_crl',
|
|
|
|
|
'privilege_withdrawn',
|
|
|
|
|
'aa_compromise'
|
2011-02-16 12:46:59 -06:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
IPA.cert.parse_dn = function(dn) {
|
|
|
|
|
|
|
|
|
|
var result = {};
|
|
|
|
|
if (!dn) return result;
|
|
|
|
|
|
|
|
|
|
// TODO: Use proper LDAP DN parser
|
|
|
|
|
var rdns = dn.split(',');
|
|
|
|
|
for (var i=0; i<rdns.length; i++) {
|
|
|
|
|
var rdn = rdns[i];
|
|
|
|
|
if (!rdn) continue;
|
|
|
|
|
|
|
|
|
|
var parts = rdn.split('=');
|
|
|
|
|
var name = $.trim(parts[0].toLowerCase());
|
|
|
|
|
var value = $.trim(parts[1]);
|
|
|
|
|
|
|
|
|
|
var old_value = result[name];
|
|
|
|
|
if (!old_value) {
|
|
|
|
|
result[name] = value;
|
|
|
|
|
} else if (typeof old_value == "string") {
|
|
|
|
|
result[name] = [old_value, value];
|
|
|
|
|
} else {
|
|
|
|
|
result[name].push(value);
|
2010-10-15 23:40:38 -05:00
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
}
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
return result;
|
|
|
|
|
};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-10-18 18:19:25 -04:00
|
|
|
IPA.cert.pem_format_base64 = function(text) {
|
|
|
|
|
/*
|
|
|
|
|
* Input is assumed to be base64 possibly with embedded whitespace.
|
|
|
|
|
* Format the base64 text such that it conforms to PEM, which is a
|
|
|
|
|
* sequence of 64 character lines, except for the last line which
|
|
|
|
|
* may be less than 64 characters. The last line does NOT have a
|
|
|
|
|
* new line appended to it.
|
|
|
|
|
*/
|
|
|
|
|
var formatted = "";
|
|
|
|
|
|
|
|
|
|
/* Strip out any whitespace including line endings */
|
|
|
|
|
text = text.replace(/\s*/g,"");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Break up into lines with 64 chars each.
|
|
|
|
|
* Do not add a newline to final line.
|
|
|
|
|
*/
|
|
|
|
|
for (var i = 0; i < text.length; i+=64) {
|
|
|
|
|
formatted += text.substring(i, i+64);
|
|
|
|
|
if (i+64 < text.length) {
|
|
|
|
|
formatted += "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (formatted);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IPA.cert.pem_cert_format = function(text) {
|
|
|
|
|
/*
|
|
|
|
|
* Input is assumed to be either PEM formated data or the
|
|
|
|
|
* base64 encoding of DER binary certificate data. Return data
|
|
|
|
|
* in PEM format. The function checks if the input text is PEM
|
|
|
|
|
* formatted, if so it just returns the input text. Otherwise
|
|
|
|
|
* the input is treated as base64 which is formatted to be PEM>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Does the text already have the PEM delimiters?
|
|
|
|
|
* If so just return the text unmodified.
|
|
|
|
|
*/
|
|
|
|
|
if (text.match(IPA.cert.PEM_CERT_REGEXP)) {
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
/* No PEM delimiters so format the base64 & add the delimiters. */
|
|
|
|
|
return IPA.cert.BEGIN_CERTIFICATE + "\n" +
|
|
|
|
|
IPA.cert.pem_format_base64(text) + "\n" +
|
|
|
|
|
IPA.cert.END_CERTIFICATE;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IPA.cert.pem_csr_format = function(text) {
|
|
|
|
|
/*
|
|
|
|
|
* Input is assumed to be either PEM formated data or the base64
|
|
|
|
|
* encoding of DER binary certificate request (csr) data. Return
|
|
|
|
|
* data in PEM format. The function checks if the input text is
|
|
|
|
|
* PEM formatted, if so it just returns the input text. Otherwise
|
|
|
|
|
* the input is treated as base64 which is formatted to be PEM>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Does the text already have the PEM delimiters?
|
|
|
|
|
* If so just return the text unmodified.
|
|
|
|
|
*/
|
|
|
|
|
if (text.match(IPA.cert.PEM_CSR_REGEXP)) {
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* No PEM delimiters so format the base64 & add the delimiters. */
|
|
|
|
|
return IPA.cert.BEGIN_CERTIFICATE_REQUEST + "\n" +
|
|
|
|
|
IPA.cert.pem_format_base64(text) + "\n" +
|
|
|
|
|
IPA.cert.END_CERTIFICATE_REQUEST;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 15:43:57 -05:00
|
|
|
IPA.cert.download_dialog = function(spec) {
|
2011-02-16 14:26:35 +01:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
spec = spec || {};
|
2011-02-16 14:26:35 +01:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
var that = IPA.dialog(spec);
|
|
|
|
|
|
|
|
|
|
that.width = spec.width || 500;
|
2012-01-31 11:31:22 -06:00
|
|
|
that.height = spec.height || 380;
|
2011-04-14 15:43:57 -05:00
|
|
|
that.add_pem_delimiters = typeof spec.add_pem_delimiters == 'undefined' ? true : spec.add_pem_delimiters;
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-04-14 15:43:57 -05:00
|
|
|
that.certificate = spec.certificate || '';
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-09-28 15:56:25 -05:00
|
|
|
that.create_button({
|
|
|
|
|
name: 'close',
|
|
|
|
|
label: IPA.messages.buttons.close,
|
|
|
|
|
click: function() {
|
|
|
|
|
that.close();
|
|
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
});
|
|
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
that.create = function() {
|
|
|
|
|
var textarea = $('<textarea/>', {
|
2012-01-31 11:31:22 -06:00
|
|
|
'class': 'certificate',
|
|
|
|
|
readonly: 'yes'
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(that.container);
|
2011-02-21 18:36:42 -06:00
|
|
|
|
2011-04-14 15:43:57 -05:00
|
|
|
var certificate = that.certificate;
|
|
|
|
|
|
|
|
|
|
if (that.add_pem_delimiters) {
|
2011-10-18 18:19:25 -04:00
|
|
|
certificate = IPA.cert.pem_cert_format(that.certificate);
|
2011-04-14 15:43:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
textarea.val(certificate);
|
2011-02-16 12:46:59 -06:00
|
|
|
};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
return that;
|
|
|
|
|
};
|
2011-02-16 14:26:35 +01:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
IPA.cert.revoke_dialog = function(spec) {
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
spec = spec || {};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
var that = IPA.dialog(spec);
|
|
|
|
|
|
|
|
|
|
that.width = spec.width || 500;
|
|
|
|
|
that.height = spec.height || 300;
|
2010-10-15 20:51:52 -04:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
that.revoke = spec.revoke;
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-09-28 15:56:25 -05:00
|
|
|
that.create_button({
|
|
|
|
|
name: 'revoke',
|
|
|
|
|
label: IPA.messages.buttons.revoke,
|
|
|
|
|
click: function() {
|
|
|
|
|
var values = {};
|
2012-06-12 14:28:30 +02:00
|
|
|
values.reason = that.select.val();
|
2011-09-28 15:56:25 -05:00
|
|
|
if (that.revoke) {
|
|
|
|
|
that.revoke(values);
|
|
|
|
|
}
|
|
|
|
|
that.close();
|
2011-03-07 12:35:11 -06:00
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
});
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-09-28 15:56:25 -05:00
|
|
|
that.create_button({
|
|
|
|
|
name: 'cancel',
|
|
|
|
|
label: IPA.messages.buttons.cancel,
|
|
|
|
|
click: function() {
|
|
|
|
|
that.close();
|
|
|
|
|
}
|
2011-03-07 12:35:11 -06:00
|
|
|
});
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
that.create = function() {
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
var table = $('<table/>').appendTo(that.container);
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
var tr = $('<tr/>').appendTo(table);
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
var td = $('<td/>').appendTo(tr);
|
|
|
|
|
td.append(IPA.messages.objects.cert.note+':');
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
td = $('<td/>').appendTo(tr);
|
|
|
|
|
td.append(IPA.messages.objects.cert.revoke_confirmation);
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
tr = $('<tr/>').appendTo(table);
|
2011-02-16 14:26:35 +01:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
td = $('<td/>').appendTo(tr);
|
|
|
|
|
td.append(IPA.messages.objects.cert.reason+':');
|
2011-02-21 18:36:42 -06:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
td = $('<td/>').appendTo(tr);
|
2011-02-21 18:36:42 -06:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
that.select = $('<select/>').appendTo(td);
|
|
|
|
|
for (var i=0; i<IPA.cert.CRL_REASON.length; i++) {
|
2011-06-30 14:33:33 -04:00
|
|
|
var reason = IPA.cert.CRL_REASON[i];
|
|
|
|
|
if (!reason) continue;
|
2011-03-07 12:35:11 -06:00
|
|
|
$('<option/>', {
|
|
|
|
|
'value': i,
|
2011-06-30 14:33:33 -04:00
|
|
|
'html': IPA.messages.objects.cert[reason]
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(that.select);
|
|
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
return that;
|
|
|
|
|
};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
IPA.cert.restore_dialog = function(spec) {
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
spec = spec || {};
|
2011-02-16 14:26:35 +01:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
var that = IPA.dialog(spec);
|
|
|
|
|
|
|
|
|
|
that.width = spec.width || 400;
|
|
|
|
|
that.height = spec.height || 200;
|
2011-02-16 14:26:35 +01:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
that.restore = spec.restore;
|
|
|
|
|
|
2011-09-28 15:56:25 -05:00
|
|
|
that.create_button({
|
|
|
|
|
name: 'restore',
|
|
|
|
|
label: IPA.messages.buttons.restore,
|
|
|
|
|
click: function() {
|
|
|
|
|
if (that.restore) {
|
2012-06-12 14:28:30 +02:00
|
|
|
that.restore();
|
2011-09-28 15:56:25 -05:00
|
|
|
}
|
|
|
|
|
that.close();
|
2011-03-07 12:35:11 -06:00
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
});
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-09-28 15:56:25 -05:00
|
|
|
that.create_button({
|
|
|
|
|
name: 'cancel',
|
|
|
|
|
label: IPA.messages.buttons.cancel,
|
|
|
|
|
click: function() {
|
|
|
|
|
that.close();
|
|
|
|
|
}
|
2011-03-07 12:35:11 -06:00
|
|
|
});
|
2011-02-21 18:36:42 -06:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
that.create = function() {
|
|
|
|
|
that.container.append(
|
|
|
|
|
IPA.messages.objects.cert.restore_confirmation);
|
2011-02-16 12:46:59 -06:00
|
|
|
};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
return that;
|
|
|
|
|
};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
IPA.cert.view_dialog = function(spec) {
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
spec = spec || {};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
var that = IPA.dialog(spec);
|
|
|
|
|
|
|
|
|
|
that.width = spec.width || 600;
|
|
|
|
|
that.height = spec.height || 500;
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.subject = IPA.cert.parse_dn(spec.certificate.subject);
|
|
|
|
|
that.serial_number = spec.certificate.serial_number || '';
|
|
|
|
|
that.serial_number_hex = spec.certificate.serial_number_hex || '';
|
|
|
|
|
that.issuer = IPA.cert.parse_dn(spec.certificate.issuer);
|
|
|
|
|
that.issued_on = spec.certificate.valid_not_before || '';
|
|
|
|
|
that.expires_on = spec.certificate.valid_not_after || '';
|
|
|
|
|
that.md5_fingerprint = spec.certificate.md5_fingerprint || '';
|
|
|
|
|
that.sha1_fingerprint = spec.certificate.sha1_fingerprint || '';
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-09-28 15:56:25 -05:00
|
|
|
that.create_button({
|
|
|
|
|
name: 'close',
|
|
|
|
|
label: IPA.messages.buttons.close,
|
|
|
|
|
click: function() {
|
|
|
|
|
that.close();
|
|
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
});
|
|
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
that.create = function() {
|
|
|
|
|
|
|
|
|
|
var table = $('<table/>').appendTo(that.container);
|
|
|
|
|
|
|
|
|
|
var tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td/>', {
|
|
|
|
|
'colspan': 2,
|
|
|
|
|
'html': '<h3>'+IPA.messages.objects.cert.issued_to+'</h3>'
|
|
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.common_name+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.subject.cn
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.organization+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.subject.o
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.organizational_unit+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.subject.ou
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.serial_number+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.serial_number
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
2012-03-06 15:53:07 -05:00
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.serial_number_hex+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
|
|
|
|
text: that.serial_number_hex
|
|
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td/>', {
|
|
|
|
|
'colspan': 2,
|
|
|
|
|
'html': '<h3>'+IPA.messages.objects.cert.issued_by+'</h3>'
|
|
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.common_name+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.issuer.cn
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.organization+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.issuer.o
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.organizational_unit+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.issuer.ou
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td/>', {
|
|
|
|
|
'colspan': 2,
|
|
|
|
|
'html': '<h3>'+IPA.messages.objects.cert.validity+'</h3>'
|
|
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.issued_on+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.issued_on
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.expires_on+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.expires_on
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td/>', {
|
|
|
|
|
'colspan': 2,
|
|
|
|
|
'html': '<h3>'+IPA.messages.objects.cert.fingerprints+'</h3>'
|
|
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.sha1_fingerprint+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.sha1_fingerprint
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
tr = $('<tr/>').appendTo(table);
|
|
|
|
|
$('<td>'+IPA.messages.objects.cert.md5_fingerprint+':</td>').appendTo(tr);
|
|
|
|
|
$('<td/>', {
|
2011-09-19 21:04:57 -05:00
|
|
|
text: that.md5_fingerprint
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(tr);
|
2011-02-16 12:46:59 -06:00
|
|
|
};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
return that;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IPA.cert.request_dialog = function(spec) {
|
|
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
var that = IPA.dialog(spec);
|
|
|
|
|
|
2012-01-06 01:18:48 -06:00
|
|
|
that.width = spec.width || 600;
|
2012-01-31 11:31:22 -06:00
|
|
|
that.height = spec.height || 480;
|
2012-01-06 01:18:48 -06:00
|
|
|
that.message = spec.message;
|
2011-02-16 12:46:59 -06:00
|
|
|
|
|
|
|
|
that.request = spec.request;
|
|
|
|
|
|
2011-09-28 15:56:25 -05:00
|
|
|
that.create_button({
|
|
|
|
|
name: 'issue',
|
|
|
|
|
label: IPA.messages.buttons.issue,
|
|
|
|
|
click: function() {
|
|
|
|
|
var values = {};
|
2011-10-18 18:19:25 -04:00
|
|
|
var request = $.trim(that.textarea.val());
|
2012-06-12 14:28:30 +02:00
|
|
|
values.request = IPA.cert.pem_csr_format(request);
|
2011-09-28 15:56:25 -05:00
|
|
|
if (that.request) {
|
|
|
|
|
that.request(values);
|
|
|
|
|
}
|
|
|
|
|
that.close();
|
2011-03-07 12:35:11 -06:00
|
|
|
}
|
2011-02-16 12:46:59 -06:00
|
|
|
});
|
|
|
|
|
|
2011-09-28 15:56:25 -05:00
|
|
|
that.create_button({
|
|
|
|
|
name: 'cancel',
|
|
|
|
|
label: IPA.messages.buttons.cancel,
|
|
|
|
|
click: function() {
|
|
|
|
|
that.close();
|
|
|
|
|
}
|
2011-03-07 12:35:11 -06:00
|
|
|
});
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
that.create = function() {
|
2012-01-06 01:18:48 -06:00
|
|
|
that.container.append(that.message);
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2011-03-07 12:35:11 -06:00
|
|
|
that.textarea = $('<textarea/>', {
|
2012-01-31 11:31:22 -06:00
|
|
|
'class': 'certificate'
|
2011-03-07 12:35:11 -06:00
|
|
|
}).appendTo(that.container);
|
2011-02-16 12:46:59 -06:00
|
|
|
};
|
2010-10-15 12:22:01 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
return that;
|
2011-02-16 14:26:35 +01:00
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
IPA.cert.loader = function(spec) {
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2010-10-15 23:40:38 -05:00
|
|
|
spec = spec || {};
|
|
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var that = {};
|
|
|
|
|
that.get_pkey = spec.get_pkey;
|
|
|
|
|
that.get_name = spec.get_name;
|
|
|
|
|
that.get_principal = spec.get_principal;
|
|
|
|
|
that.get_hostname = spec.get_hostname;
|
|
|
|
|
|
|
|
|
|
that.load = function (result) {
|
|
|
|
|
|
|
|
|
|
var certificate = {
|
|
|
|
|
issuer: result.issuer,
|
|
|
|
|
certificate: result.certificate,
|
|
|
|
|
md5_fingerprint: result.md5_fingerprint,
|
|
|
|
|
revocation_reason: result.revocation_reason,
|
|
|
|
|
serial_number: result.serial_number,
|
|
|
|
|
serial_number_hex: result.serial_number_hex,
|
|
|
|
|
sha1_fingerprint: result.sha1_fingerprint,
|
|
|
|
|
subject: result.subject,
|
|
|
|
|
valid_not_after: result.valid_not_after,
|
|
|
|
|
valid_not_before: result.valid_not_before
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (that.get_entity_certificate) {
|
|
|
|
|
certificate.certificate = that.get_entity_certificate(result);
|
|
|
|
|
} else if (!certificate.certificate && result.usercertificate) {
|
|
|
|
|
// default method of storing certificate for object commands
|
|
|
|
|
// which include certificate
|
|
|
|
|
certificate.certificate = result.usercertificate[0].__base64__;
|
|
|
|
|
}
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var info = {};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
if (that.get_pkey) info.pkey = that.get_pkey(result);
|
|
|
|
|
if (that.get_name) info.name = that.get_name(result);
|
|
|
|
|
if (that.get_principal) info.principal = that.get_principal(result);
|
|
|
|
|
if (that.get_hostname) info.hostname = that.get_hostname(result);
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
certificate.entity_info = info;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
return certificate;
|
2010-12-01 21:46:38 -06:00
|
|
|
};
|
|
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
return that;
|
|
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
IPA.cert.load_policy = function(spec) {
|
2011-01-13 13:59:57 +07:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
spec = spec || {};
|
|
|
|
|
spec.loader = spec.loader || {
|
|
|
|
|
factory: IPA.cert.loader,
|
|
|
|
|
get_pkey: spec.get_pkey,
|
|
|
|
|
get_name: spec.get_name,
|
|
|
|
|
get_principal: spec.get_principal,
|
|
|
|
|
get_hostname: spec.get_hostname
|
|
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var that = IPA.facet_policy();
|
|
|
|
|
that.loader = IPA.build(spec.loader);
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.post_load = function(data) {
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
// update cert info in facet (show at least something)
|
|
|
|
|
var certificate = that.loader.load(data.result.result);
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
//store cert directly to facet. FIXME: introduce concept of models
|
|
|
|
|
that.container.certificate = certificate;
|
|
|
|
|
that.notify_loaded();
|
2011-01-13 17:20:12 +07:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
// initialize another load of certificate because current entity
|
|
|
|
|
// show commands don't contain revocation_reason so previous data
|
|
|
|
|
// might be slightly incorrect
|
|
|
|
|
if (certificate && certificate.certificate && !IPA.cert.is_selfsign()) {
|
|
|
|
|
that.load_revocation_reason(certificate.serial_number);
|
2010-12-01 21:46:38 -06:00
|
|
|
}
|
2012-06-12 14:28:30 +02:00
|
|
|
};
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.load_revocation_reason = function(serial_number) {
|
|
|
|
|
IPA.command({
|
|
|
|
|
entity: 'cert',
|
|
|
|
|
method: 'show',
|
|
|
|
|
args: [serial_number],
|
|
|
|
|
on_success: function(data, text_status, xhr) {
|
|
|
|
|
var cert = that.container.certificate;
|
|
|
|
|
cert.revocation_reason = data.result.result.revocation_reason;
|
|
|
|
|
that.notify_loaded();
|
|
|
|
|
}
|
|
|
|
|
}).execute();
|
|
|
|
|
};
|
2011-01-17 20:43:43 +07:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.notify_loaded = function() {
|
|
|
|
|
if (that.container.certificate_loaded) {
|
|
|
|
|
that.container.certificate_loaded.notify(
|
|
|
|
|
[that.container.certificate], that.container);
|
2010-12-01 21:46:38 -06:00
|
|
|
}
|
2012-06-12 14:28:30 +02:00
|
|
|
};
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
return that;
|
|
|
|
|
};
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
IPA.cert.is_selfsign = function() {
|
|
|
|
|
return IPA.env.ra_plugin == 'selfsign';
|
|
|
|
|
};
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
IPA.cert.view_action = function(spec) {
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
spec = spec || {};
|
|
|
|
|
spec.name = spec.name || 'view_cert';
|
|
|
|
|
spec.label = spec.label || IPA.messages.buttons.view;
|
|
|
|
|
spec.enable_cond = spec.enable_cond || ['has_certificate'];
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var that = IPA.action(spec);
|
|
|
|
|
that.entity_label = spec.entity_label;
|
2010-11-16 18:10:40 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.execute_action = function(facet) {
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var certificate = facet.certificate;
|
|
|
|
|
if (!certificate) that.facet.refresh();
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var entity_label = that.entity_label || facet.entity.metadata.label_singular;
|
|
|
|
|
var entity_name = certificate.entity_info.name;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var title = IPA.messages.objects.cert.view_certificate;
|
|
|
|
|
title = title.replace('${entity}', entity_label);
|
|
|
|
|
title = title.replace('${primary_key}', entity_name);
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var dialog = IPA.cert.view_dialog({
|
|
|
|
|
title: title,
|
|
|
|
|
certificate: certificate
|
2010-11-16 18:10:40 -06:00
|
|
|
});
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
dialog.open();
|
2011-10-24 14:53:29 +02:00
|
|
|
};
|
|
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
return that;
|
|
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
IPA.cert.get_action = function(spec) {
|
2010-12-01 21:46:38 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
spec = spec || {};
|
|
|
|
|
spec.name = spec.name || 'get_cert';
|
|
|
|
|
spec.label = spec.label || IPA.messages.buttons.get;
|
|
|
|
|
spec.enable_cond = spec.enable_cond || ['has_certificate'];
|
2010-12-01 21:46:38 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var that = IPA.action(spec);
|
|
|
|
|
that.entity_label = spec.entity_label;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.execute_action = function(facet) {
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var certificate = facet.certificate;
|
|
|
|
|
if (!certificate) that.facet.refresh();
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var entity_label = that.entity_label || facet.entity.metadata.label_singular;
|
|
|
|
|
var entity_name = certificate.entity_info.name;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
var title = IPA.messages.objects.cert.view_certificate;
|
2012-06-12 14:28:30 +02:00
|
|
|
title = title.replace('${entity}', entity_label);
|
2011-02-16 12:46:59 -06:00
|
|
|
title = title.replace('${primary_key}', entity_name);
|
|
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var dialog = IPA.cert.download_dialog({
|
|
|
|
|
title: title,
|
|
|
|
|
certificate: certificate.certificate
|
2010-10-15 23:40:38 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dialog.open();
|
2012-06-12 14:28:30 +02:00
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
return that;
|
|
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
IPA.cert.request_action = function(spec) {
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
spec = spec || {};
|
|
|
|
|
spec.name = spec.name || 'request_cert';
|
|
|
|
|
spec.label = spec.label || IPA.messages.objects.cert.new_certificate;
|
2011-02-16 12:46:59 -06:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var that = IPA.action(spec);
|
|
|
|
|
that.entity_label = spec.entity_label;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.execute_action = function(facet) {
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var certificate = facet.certificate;
|
|
|
|
|
if (!certificate) facet.refresh();
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var entity_principal = certificate.entity_info.principal;
|
|
|
|
|
var entity_label = that.entity_label || facet.entity.metadata.label_singular;
|
|
|
|
|
var entity_name = certificate.entity_info.name;
|
|
|
|
|
var hostname = certificate.entity_info.hostname;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
var title = IPA.messages.objects.cert.issue_certificate;
|
2012-06-12 14:28:30 +02:00
|
|
|
title = title.replace('${entity}', entity_label);
|
2011-02-16 12:46:59 -06:00
|
|
|
title = title.replace('${primary_key}', entity_name);
|
|
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
var request_message = IPA.messages.objects.cert.request_message;
|
|
|
|
|
request_message = request_message.replace(/\$\{hostname\}/g, hostname);
|
|
|
|
|
request_message = request_message.replace(/\$\{realm\}/g, IPA.env.realm);
|
|
|
|
|
|
2011-02-16 14:26:35 +01:00
|
|
|
var dialog = IPA.cert.request_dialog({
|
2012-01-06 01:18:48 -06:00
|
|
|
title: title,
|
2012-06-12 14:28:30 +02:00
|
|
|
message: request_message,
|
2012-01-06 01:18:48 -06:00
|
|
|
request: function(values) {
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
IPA.command({
|
|
|
|
|
entity: 'cert',
|
|
|
|
|
method: 'request',
|
2012-06-12 14:28:30 +02:00
|
|
|
args: [values.request],
|
2011-04-12 02:13:30 -05:00
|
|
|
options: {
|
2010-10-15 23:40:38 -05:00
|
|
|
'principal': entity_principal
|
|
|
|
|
},
|
2011-04-12 02:13:30 -05:00
|
|
|
on_success: function(data, text_status, xhr) {
|
2012-06-12 14:28:30 +02:00
|
|
|
facet.refresh();
|
2012-08-27 10:57:47 +02:00
|
|
|
IPA.notify_success(IPA.messages.objects.cert.requested);
|
2010-10-15 23:40:38 -05:00
|
|
|
}
|
2011-04-12 02:13:30 -05:00
|
|
|
}).execute();
|
2010-10-15 23:40:38 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dialog.open();
|
2012-06-12 14:28:30 +02:00
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
return that;
|
|
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
IPA.cert.revoke_action = function(spec) {
|
|
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
spec.name = spec.name || 'revoke_cert';
|
|
|
|
|
spec.label = spec.label || IPA.messages.buttons.revoke;
|
|
|
|
|
spec.enable_cond = spec.enable_cond || ['has_certificate'];
|
|
|
|
|
spec.disable_cond = spec.disable_cond || ['certificate_revoked'];
|
|
|
|
|
spec.hide_cond = spec.hide_cond || ['selfsign'];
|
|
|
|
|
|
|
|
|
|
var that = IPA.action(spec);
|
|
|
|
|
that.entity_label = spec.entity_label;
|
|
|
|
|
that.request_message = spec.request_message;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.execute_action = function(facet) {
|
|
|
|
|
|
|
|
|
|
var certificate = facet.certificate;
|
|
|
|
|
if (!certificate) facet.refresh();
|
|
|
|
|
|
|
|
|
|
var entity_label = that.entity_label || facet.entity.metadata.label_singular;
|
|
|
|
|
var entity_name = certificate.entity_info.name;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
var title = IPA.messages.objects.cert.revoke_certificate;
|
2012-06-12 14:28:30 +02:00
|
|
|
title = title.replace('${entity}', entity_label);
|
2011-02-16 12:46:59 -06:00
|
|
|
title = title.replace('${primary_key}', entity_name);
|
|
|
|
|
|
2011-02-16 14:26:35 +01:00
|
|
|
var dialog = IPA.cert.revoke_dialog({
|
2012-06-12 14:28:30 +02:00
|
|
|
title: title,
|
|
|
|
|
message: that.request_message,
|
|
|
|
|
revoke: function(values) {
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
IPA.command({
|
|
|
|
|
entity: 'cert',
|
|
|
|
|
method: 'revoke',
|
2012-06-12 14:28:30 +02:00
|
|
|
args: [certificate.serial_number],
|
2011-04-12 02:13:30 -05:00
|
|
|
options: {
|
2012-06-12 14:28:30 +02:00
|
|
|
'revocation_reason': values.reason
|
2010-10-15 23:40:38 -05:00
|
|
|
},
|
2011-04-12 02:13:30 -05:00
|
|
|
on_success: function(data, text_status, xhr) {
|
2012-06-12 14:28:30 +02:00
|
|
|
facet.refresh();
|
2012-08-27 10:57:47 +02:00
|
|
|
IPA.notify_success(IPA.messages.objects.cert.revoked);
|
2010-10-15 23:40:38 -05:00
|
|
|
}
|
2011-04-12 02:13:30 -05:00
|
|
|
}).execute();
|
2010-10-15 23:40:38 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dialog.open();
|
2012-06-12 14:28:30 +02:00
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
return that;
|
|
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
IPA.cert.restore_action = function(spec) {
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
spec = spec || {};
|
|
|
|
|
spec.name = spec.name || 'restore_cert';
|
|
|
|
|
spec.label = spec.label || IPA.messages.buttons.restore;
|
|
|
|
|
spec.enable_cond = spec.enable_cond || ['has_certificate', 'certificate_hold'];
|
|
|
|
|
spec.hide_cond = spec.hide_cond || ['selfsign'];
|
|
|
|
|
|
|
|
|
|
var that = IPA.action(spec);
|
|
|
|
|
that.entity_label = spec.entity_label;
|
|
|
|
|
that.request_message = spec.request_message;
|
|
|
|
|
|
|
|
|
|
that.execute_action = function(facet) {
|
|
|
|
|
|
|
|
|
|
var certificate = facet.certificate;
|
|
|
|
|
if (!certificate) facet.refresh();
|
|
|
|
|
|
|
|
|
|
var entity_label = that.entity_label || facet.entity.metadata.label_singular;
|
|
|
|
|
var entity_name = certificate.entity_info.name;
|
2010-10-15 23:40:38 -05:00
|
|
|
|
2011-02-16 12:46:59 -06:00
|
|
|
var title = IPA.messages.objects.cert.restore_certificate;
|
2012-06-12 14:28:30 +02:00
|
|
|
title = title.replace('${entity}', entity_label);
|
2011-02-16 12:46:59 -06:00
|
|
|
title = title.replace('${primary_key}', entity_name);
|
|
|
|
|
|
2011-02-16 14:26:35 +01:00
|
|
|
var dialog = IPA.cert.restore_dialog({
|
2012-06-12 14:28:30 +02:00
|
|
|
title: title,
|
|
|
|
|
message: that.request_message,
|
|
|
|
|
restore: function() {
|
|
|
|
|
|
2011-04-12 02:13:30 -05:00
|
|
|
IPA.command({
|
|
|
|
|
entity: 'cert',
|
|
|
|
|
method: 'remove_hold',
|
2012-06-12 14:28:30 +02:00
|
|
|
args: [certificate.serial_number],
|
2011-04-12 02:13:30 -05:00
|
|
|
on_success: function(data, text_status, xhr) {
|
2012-06-12 14:28:30 +02:00
|
|
|
facet.refresh();
|
2012-08-27 10:57:47 +02:00
|
|
|
IPA.notify_success(IPA.messages.objects.cert.restored);
|
2010-10-15 23:40:38 -05:00
|
|
|
}
|
2011-04-12 02:13:30 -05:00
|
|
|
}).execute();
|
2010-10-15 23:40:38 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dialog.open();
|
2012-06-12 14:28:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IPA.cert.certificate_evaluator = function(spec) {
|
|
|
|
|
|
|
|
|
|
spec.name = spec.name || 'has_certificate_evaluator';
|
|
|
|
|
spec.event = spec.event || 'certificate_loaded';
|
|
|
|
|
|
|
|
|
|
var that = IPA.state_evaluator(spec);
|
|
|
|
|
|
|
|
|
|
that.on_event = function(certificate) {
|
|
|
|
|
|
|
|
|
|
var old_state, record, state, value, loaded_value;
|
|
|
|
|
|
|
|
|
|
old_state = that.state;
|
|
|
|
|
that.state = [];
|
|
|
|
|
|
|
|
|
|
if (certificate && certificate.certificate) {
|
|
|
|
|
that.state.push('has_certificate');
|
|
|
|
|
|
|
|
|
|
if (certificate.revocation_reason !== undefined) {
|
|
|
|
|
that.state.push('certificate_revoked');
|
|
|
|
|
|
|
|
|
|
if (certificate.revocation_reason === 6) {
|
|
|
|
|
that.state.push('certificate_hold');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IPA.cert.is_selfsign()) {
|
|
|
|
|
that.state.push('selfsign');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
that.notify_on_change(old_state);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IPA.cert.status_widget = function(spec) {
|
|
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
|
|
var that = IPA.input_widget(spec);
|
|
|
|
|
|
|
|
|
|
that.create = function(container) {
|
|
|
|
|
|
|
|
|
|
that.widget_create(container);
|
|
|
|
|
|
|
|
|
|
that.status_valid = $('<div/>', {
|
|
|
|
|
name: 'certificate-valid',
|
|
|
|
|
style: 'display: none;'
|
|
|
|
|
}).appendTo(container);
|
|
|
|
|
|
|
|
|
|
$('<img/>', {
|
|
|
|
|
src: 'images/check-icon.png',
|
|
|
|
|
style: 'float: left;',
|
|
|
|
|
'class': 'status-icon'
|
|
|
|
|
}).appendTo(that.status_valid);
|
|
|
|
|
|
|
|
|
|
var content_div = $('<div/>', {
|
|
|
|
|
style: 'float: left;'
|
|
|
|
|
}).appendTo(that.status_valid);
|
|
|
|
|
|
|
|
|
|
content_div.append('<b>'+IPA.messages.objects.cert.valid+'</b>');
|
|
|
|
|
|
|
|
|
|
that.status_revoked = $('<div/>', {
|
|
|
|
|
name: 'certificate-revoked',
|
|
|
|
|
style: 'display: none;'
|
|
|
|
|
}).appendTo(container);
|
|
|
|
|
|
|
|
|
|
$('<img/>', {
|
|
|
|
|
src: 'images/caution-icon.png',
|
|
|
|
|
style: 'float: left;',
|
|
|
|
|
'class': 'status-icon'
|
|
|
|
|
}).appendTo(that.status_revoked);
|
|
|
|
|
|
|
|
|
|
content_div = $('<div/>', {
|
|
|
|
|
style: 'float: left;'
|
|
|
|
|
}).appendTo(that.status_revoked);
|
|
|
|
|
|
|
|
|
|
content_div.append('<b>'+IPA.messages.objects.cert.revoked+'</b>');
|
|
|
|
|
content_div.append(' ');
|
|
|
|
|
that.revocation_reason = $('<span/>', {
|
|
|
|
|
'name': 'revocation_reason'
|
|
|
|
|
}).appendTo(content_div);
|
|
|
|
|
|
|
|
|
|
that.status_missing = $('<div/>', {
|
|
|
|
|
name: 'certificate-missing',
|
|
|
|
|
style: 'display: none;'
|
|
|
|
|
}).appendTo(container);
|
|
|
|
|
|
|
|
|
|
$('<img/>', {
|
|
|
|
|
src: 'images/caution-icon.png',
|
|
|
|
|
style: 'float: left;',
|
|
|
|
|
'class': 'status-icon'
|
|
|
|
|
}).appendTo(that.status_missing);
|
|
|
|
|
|
|
|
|
|
content_div = $('<div/>', {
|
|
|
|
|
style: 'float: left;'
|
|
|
|
|
}).appendTo(that.status_missing);
|
|
|
|
|
|
|
|
|
|
content_div.append('<b>'+IPA.messages.objects.cert.missing+'</b>');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
that.update = function(certificate) {
|
|
|
|
|
|
|
|
|
|
certificate = certificate || {};
|
|
|
|
|
|
|
|
|
|
var selfsign = IPA.cert.is_selfsign();
|
|
|
|
|
var has_certificate = certificate.certificate;
|
|
|
|
|
var revoked = certificate.revocation_reason !== undefined;
|
|
|
|
|
var status = IPA.cert.CERTIFICATE_STATUS_MISSING;
|
|
|
|
|
|
|
|
|
|
if (has_certificate && (selfsign || !revoked)) {
|
|
|
|
|
status = IPA.cert.CERTIFICATE_STATUS_VALID;
|
|
|
|
|
} else if (has_certificate) {
|
|
|
|
|
status = IPA.cert.CERTIFICATE_STATUS_REVOKED;
|
|
|
|
|
}
|
|
|
|
|
that.set_status(status, certificate.revocation_reason);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
that.clear = function() {
|
|
|
|
|
that.status_valid.css('display', 'none');
|
|
|
|
|
that.status_missing.css('display', 'none');
|
|
|
|
|
that.status_revoked.css('display', 'none');
|
|
|
|
|
that.revocation_reason.text('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
that.set_status = function(status, revocation_reason) {
|
|
|
|
|
that.status_valid.css('display', status === IPA.cert.CERTIFICATE_STATUS_VALID ? '' : 'none');
|
|
|
|
|
that.status_missing.css('display', status === IPA.cert.CERTIFICATE_STATUS_MISSING ? '' : 'none');
|
|
|
|
|
|
|
|
|
|
if (!IPA.cert.is_selfsign()) {
|
|
|
|
|
that.status_revoked.css('display', status === IPA.cert.CERTIFICATE_STATUS_REVOKED ? '' : 'none');
|
|
|
|
|
|
|
|
|
|
var reason = IPA.cert.CRL_REASON[revocation_reason];
|
|
|
|
|
that.revocation_reason.html(revocation_reason === undefined || reason === null ? '' : IPA.messages.objects.cert[reason]);
|
|
|
|
|
}
|
|
|
|
|
};
|
2010-10-15 23:40:38 -05:00
|
|
|
|
|
|
|
|
return that;
|
2011-02-16 14:26:35 +01:00
|
|
|
};
|
2011-11-23 13:42:23 +01:00
|
|
|
|
|
|
|
|
IPA.cert.status_field = function(spec) {
|
|
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
|
|
var that = IPA.field(spec);
|
2012-06-12 14:28:30 +02:00
|
|
|
that.registered = false;
|
2011-11-23 13:42:23 +01:00
|
|
|
|
|
|
|
|
that.load = function(result) {
|
2012-06-12 14:28:30 +02:00
|
|
|
that.register_listener();
|
|
|
|
|
that.reset();
|
|
|
|
|
};
|
2011-11-23 13:42:23 +01:00
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.set_certificate = function(certificate) {
|
|
|
|
|
that.values = certificate;
|
2011-11-23 13:42:23 +01:00
|
|
|
that.reset();
|
|
|
|
|
};
|
|
|
|
|
|
2012-06-12 14:28:30 +02:00
|
|
|
that.register_listener = function() {
|
|
|
|
|
if (!that.registered) {
|
|
|
|
|
that.registered = true;
|
|
|
|
|
that.container.certificate_loaded.attach(that.set_certificate);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-23 13:42:23 +01:00
|
|
|
return that;
|
|
|
|
|
};
|
2012-06-12 14:28:30 +02:00
|
|
|
|
|
|
|
|
IPA.widget_factories['certificate_status'] = IPA.cert.status_widget;
|
|
|
|
|
IPA.field_factories['certificate_status'] = IPA.cert.status_field;
|