summaryrefslogtreecommitdiffstats
path: root/install/ui/src/freeipa/certificate.js
diff options
context:
space:
mode:
authorPavel Vomacka <pvomacka@redhat.com>2016-06-10 16:15:07 +0200
committerMartin Basti <mbasti@redhat.com>2016-06-15 09:59:50 +0200
commitf4dd2446cd8b2c2a814c7bcb95415eb186b0a70f (patch)
treeba9f2964023c775ce2398fdd48774a090ac9e0bd /install/ui/src/freeipa/certificate.js
parent6e78169e3bc71c5ff3824e91cce8a0d6d9580d7a (diff)
downloadfreeipa-f4dd2446cd8b2c2a814c7bcb95415eb186b0a70f.tar.gz
freeipa-f4dd2446cd8b2c2a814c7bcb95415eb186b0a70f.tar.xz
freeipa-f4dd2446cd8b2c2a814c7bcb95415eb186b0a70f.zip
Extend certificate entity page
Add field for choosing CA when issuing new certificate. Add new item to action menu on cert details page which allows user to download the certificate as file. Part of: https://fedorahosted.org/freeipa/ticket/5939 Reviewed-By: Fraser Tweedale <ftweedal@redhat.com> Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
Diffstat (limited to 'install/ui/src/freeipa/certificate.js')
-rwxr-xr-xinstall/ui/src/freeipa/certificate.js77
1 files changed, 72 insertions, 5 deletions
diff --git a/install/ui/src/freeipa/certificate.js b/install/ui/src/freeipa/certificate.js
index c910a5243..7e7a3baba 100755
--- a/install/ui/src/freeipa/certificate.js
+++ b/install/ui/src/freeipa/certificate.js
@@ -38,6 +38,8 @@ define([
var exp = IPA.cert = {};
+IPA.cert.TOPLEVEL_CA = 'ipa';
+
IPA.cert.BEGIN_CERTIFICATE = '-----BEGIN CERTIFICATE-----';
IPA.cert.END_CERTIFICATE = '-----END CERTIFICATE-----';
@@ -446,6 +448,14 @@ IPA.cert.request_dialog = function(spec) {
section0.fields.push(
{
$type: 'entity_select',
+ name: 'cacn',
+ label: '@i18n:objects.cert.ca',
+ other_entity: 'ca',
+ other_field: 'cn',
+ required: true
+ },
+ {
+ $type: 'entity_select',
name: 'profile_id',
other_entity: 'certprofile',
other_field: 'cn',
@@ -493,6 +503,11 @@ IPA.cert.request_dialog = function(spec) {
}
});
+ that.open = function() {
+ that.dialog_open();
+ that.get_field('cacn').set_value([IPA.cert.TOPLEVEL_CA]);
+ };
+
return that;
};
@@ -680,6 +695,51 @@ IPA.cert.get_action = function(spec) {
return that;
};
+IPA.cert.create_data_uri = function(certificate) {
+ if (typeof certificate !== 'string') return '';
+
+ var format = 'data:,';
+ var uri_new_line = '%0A';
+
+ var data_uri = IPA.cert.pem_format_base64(certificate);
+ data_uri = IPA.cert.pem_cert_format(data_uri);
+ data_uri = format + data_uri.replace(/\n/g, uri_new_line);
+
+ return data_uri;
+};
+
+IPA.cert.perform_download = function(data_uri) {
+ var a = document.createElement("a");
+ // Adding own click function as workaround for Firefox
+ a.click = function() {
+ var evt = this.ownerDocument.createEvent('MouseEvents');
+ evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView,
+ 1, 0, 0, 0, 0, false, false, false, false, 0, null);
+ this.dispatchEvent(evt);
+ };
+ a.download = 'cert.pem';
+ a.href = data_uri;
+
+ a.click();
+};
+
+IPA.cert.download_action = function(spec) {
+ spec = spec || {};
+ spec.name = spec.name || 'download_cert';
+ spec.label = spec.label || '@i18n:objects.cert.download';
+
+ var that = IPA.action(spec);
+
+ that.execute_action = function(facet) {
+ if (!facet.certificate) return;
+
+ var data_uri = IPA.cert.create_data_uri(facet.certificate.certificate);
+ IPA.cert.perform_download(data_uri);
+ };
+
+ return that;
+};
+
IPA.cert.request_action = function(spec) {
spec = spec || {};
@@ -735,7 +795,8 @@ IPA.cert.request_action = function(spec) {
request: function(values) {
var options = {
- 'principal': entity_principal
+ 'principal': entity_principal,
+ 'cacn': values.cacn[0]
};
if (values.profile_id) options.profile_id = values.profile_id[0];
if (values.principal) options.principal = values.principal[0];
@@ -1215,7 +1276,8 @@ exp.facet_group = {
facets: {
certificates: 'cert_search',
profiles: 'certprofile_search',
- acls: 'caacl_search'
+ acls: 'caacl_search',
+ ca_search: 'ca_search'
}
};
@@ -1348,14 +1410,15 @@ return {
disable_facet_tabs: true,
actions: [
'cert_revoke',
- 'cert_remove_hold'
+ 'cert_remove_hold',
+ 'download_cert'
],
state: {
evaluators: [
IPA.cert.certificate_evaluator
]
},
- header_actions: ['revoke_cert', 'remove_hold_cert'],
+ header_actions: ['revoke_cert', 'remove_hold_cert', 'download_cert'],
sections: [
{
name: 'details',
@@ -1364,7 +1427,10 @@ return {
'serial_number',
'serial_number_hex',
'subject',
- 'issuer',
+ {
+ name: 'issuer',
+ read_only: true
+ },
'valid_not_before',
'valid_not_after',
'sha1_fingerprint',
@@ -1542,6 +1608,7 @@ exp.register = function() {
a.register('cert_view', IPA.cert.view_action);
a.register('cert_get', IPA.cert.get_action);
a.register('cert_request', IPA.cert.request_action);
+ a.register('download_cert', IPA.cert.download_action);
a.register('cert_revoke', IPA.cert.revoke_action);
a.register('cert_remove_hold', IPA.cert.remove_hold_action);