ac7d03
From be6eedde5a5aaf7ad1b527c0cfb9699ccb98a6b5 Mon Sep 17 00:00:00 2001
ac7d03
From: Pavel Vomacka <pvomacka@redhat.com>
ac7d03
Date: Mon, 27 Mar 2017 14:14:32 +0200
ac7d03
Subject: [PATCH] WebUI: Allow to add certs to certmapping with CERT LINES
ac7d03
 around
ac7d03
ac7d03
The certificate to the certmapping might be inserted as
ac7d03
base64 encoded blob. This patch allows to also insert the certificate
ac7d03
blob with surrounding "-----BEGIN CERTIFICATE-----" and
ac7d03
"-----END CERTIFICATE-----" lines. This behavior is the same in
ac7d03
widget for assigning certificates to users, so the change helps
ac7d03
WebUI to be more consistent.
ac7d03
ac7d03
https://pagure.io/freeipa/issue/6772
ac7d03
ac7d03
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
ac7d03
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
ac7d03
---
ac7d03
 install/ui/src/freeipa/plugins/certmap.js | 13 +++++++++++--
ac7d03
 1 file changed, 11 insertions(+), 2 deletions(-)
ac7d03
ac7d03
diff --git a/install/ui/src/freeipa/plugins/certmap.js b/install/ui/src/freeipa/plugins/certmap.js
ac7d03
index ecbe095b9ead5c3dad70380202836608d564cd58..c613601e989f065a3d6289b02b60563020acf978 100644
ac7d03
--- a/install/ui/src/freeipa/plugins/certmap.js
ac7d03
+++ b/install/ui/src/freeipa/plugins/certmap.js
ac7d03
@@ -8,6 +8,7 @@ define([
ac7d03
         'dojo/_base/declare',
ac7d03
         'dojo/Evented',
ac7d03
         'dojo/on',
ac7d03
+        '../certificate',
ac7d03
         '../navigation',
ac7d03
         '../field',
ac7d03
         '../ipa',
ac7d03
@@ -19,8 +20,8 @@ define([
ac7d03
         // plain imports
ac7d03
         '../search',
ac7d03
         '../entity'],
ac7d03
-            function(lang, declare, Evented, on, navigation, mod_field, IPA,
ac7d03
-                     phases, reg, widget_mod, text, util) {
ac7d03
+            function(lang, declare, Evented, on, certificate, navigation,
ac7d03
+                 mod_field, IPA, phases, reg, widget_mod, text, util) {
ac7d03
 /**
ac7d03
  * Certificate map module
ac7d03
  * @class
ac7d03
@@ -312,6 +313,12 @@ certmap.certmap_multivalued_widget = function (spec) {
ac7d03
         var widget = widgets[0];
ac7d03
         var inner_widgets = widget.widgets.get_widgets();
ac7d03
 
ac7d03
+        var normalize_certs = function(certs) {
ac7d03
+            for (var k = 0, l = certs.length; k
ac7d03
+                certs[k] = certificate.get_base64(certs[k]);
ac7d03
+            }
ac7d03
+        };
ac7d03
+
ac7d03
         for (var i = 0, l = inner_widgets.length; i
ac7d03
             var w = inner_widgets[i];
ac7d03
 
ac7d03
@@ -321,6 +328,8 @@ certmap.certmap_multivalued_widget = function (spec) {
ac7d03
 
ac7d03
                 if (field.name === 'issuer' || field.name === 'subject') {
ac7d03
                     value = value[0];
ac7d03
+                } else if (field.name === 'certificate') {
ac7d03
+                    normalize_certs(value);
ac7d03
                 }
ac7d03
 
ac7d03
                 if (!util.is_empty(value)) options[field.name] = value;
ac7d03
-- 
ac7d03
2.12.1
ac7d03