From 4b9b5aa7e49129c992d64fc3b63affce17ecfaff Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 28 Aug 2017 16:14:56 +0200 Subject: [PATCH] S/MIME: - Add password remember option for smime_passphrase dialog in compose --- api/src/Mailer.php | 2 +- api/templates/default/password.xet | 4 ++++ mail/inc/class.mail_compose.inc.php | 8 ++++++++ mail/js/app.js | 5 ++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/api/src/Mailer.php b/api/src/Mailer.php index c3ee376e38..4641ce2891 100644 --- a/api/src/Mailer.php +++ b/api/src/Mailer.php @@ -1027,7 +1027,7 @@ class Mailer extends Horde_Mime_Mail { throw new Exception\WrongUserinput('no certificate found to sign the messase'); } - + if (Cache::getSession('mail', 'smime_passphrase')) $params['passphrase'] = Cache::getSession('mail', 'smime_passphrase'); if (!$smime->verifyPassphrase($params['senderPrivKey'], $params['passphrase'])) { return false; diff --git a/api/templates/default/password.xet b/api/templates/default/password.xet index 6a26757a20..170bb8e09a 100644 --- a/api/templates/default/password.xet +++ b/api/templates/default/password.xet @@ -10,6 +10,10 @@ + + + + diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 604e0b1015..9744e3b076 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -2992,6 +2992,14 @@ class mail_compose try { if ($_formData['smime_sign'] == 'on') { + if ($_formData['smime_passphrase'] != '') { + Api\Cache::setSession( + 'mail', + 'smime_passphrase', + $_formData['smime_passphrase'], + $GLOBALS['egw_info']['user']['preferences']['mail']['smime_pass_exp'] * 60 + ); + } $smime_success = $this->_encrypt( $mail, $_formData['smime_encrypt'] == 'on'? Mail\Smime::TYPE_SIGN_ENCRYPT: Mail\Smime::TYPE_SIGN, diff --git a/mail/js/app.js b/mail/js/app.js index fe91aee1fc..e8f697100f 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -5734,6 +5734,7 @@ app.classes.mail = AppJS.extend( smimePassDialog: function (_msg) { var self = this; + var pass_exp = egw.preference('smime_pass_exp', 'mail'); et2_createWidget("dialog", { callback: function(_button_id, _value) @@ -5744,6 +5745,7 @@ app.classes.mail = AppJS.extend( pass.set_value(_value.value); var toolbar = self.et2.getWidgetById('composeToolbar'); toolbar.value = 'send'; + egw.set_preference('mail', 'smime_pass_exp', _value.pass_exp); self.compose_submitAction(false); } }, @@ -5755,7 +5757,8 @@ app.classes.mail = AppJS.extend( value:{ content:{ value: '', - message: _msg + message: _msg, + 'exp_min': pass_exp }}, template: egw.webserverUrl+'/api/templates/default/password.xet', resizable: false