/* Open the passphrase window here. */
if ($pgp_passphrase_dialog || $pgp_symmetric_passphrase_dialog) {
- $imp_pgp = &Horde_Crypt::singleton(array('imp', 'pgp'));
- Horde::addScriptFile('popup.js', 'imp', true);
if ($pgp_passphrase_dialog) {
$notification->push(IMP::passphraseDialogJS('PGPPersonal', 'uniqSubmit(\'send_message\')'), 'javascript');
} else {
$notification->push(IMP::passphraseDialogJS('PGPSymmetric', 'uniqSubmit(\'send_message\')', array('symmetricid' => 'imp_compose_' . $composeCacheID)), 'javascript');
}
} elseif ($smime_passphrase_dialog) {
- $imp_smime = &Horde_Crypt::singleton(array('imp', 'smime'));
- Horde::addScriptFile('popup.js', 'imp', true);
- $notification->push($imp_smime->getJSOpenWinCode('open_passphrase_dialog', "opener.focus();opener.uniqSubmit('send_message');"), 'javascript');
+ $notification->push(IMP::passphraseDialogJS('SMIMEPersonal', 'uniqSubmit(\'send_message\')'), 'javascript');
}
/* If PGP encryption is set by default, and we have a recipient list on first
the PGP public key (Bug #4221).
[mms] Removed Special Characters menu.
[mms] Add 'undelete' to Other Actions menu (Bug #7496) (DIMP).
-[mms] PGP functions now work in DIMP (Bug #5388).
+[mms] All PGP & S/MIME functions now work in DIMP (Bug #5388).
[mms] Encrypted bodytext now appears when replying/forwarding a message
(Request #1345).
[mms] When deleting/emptying a folder, display message count (Request #7424).
case 'PGPSymmetric':
case 'PGPPersonal':
- $imp_pgp = &Horde_Crypt::singleton(array('imp', 'pgp'));
- $secure_check = $imp_pgp->requireSecureConnection();
+case 'SMIMEPersonal':
+ $result = new stdClass;
+ $result->success = false;
- $symmetricid = Util::getFormData('symmetricid');
$passphrase = Util::getFormData('passphrase');
- $result = new stdClass;
- $result->success = false;
+ if ($action == 'SMIMEPersonal') {
+ $imp_smime = &Horde_Crypt::singleton(array('imp', 'smime'));
+ $secure_check = $imp_smime->requireSecureConnection();
+ if (!is_a($secure_check, 'PEAR_Error') && $passphrase) {
+ $res = $imp_smime->storePassphrase($passphrase);
+ }
+ } else {
+ $imp_pgp = &Horde_Crypt::singleton(array('imp', 'pgp'));
+ $secure_check = $imp_pgp->requireSecureConnection();
+ if (is_a($secure_check, 'PEAR_Error') && $passphrase) {
+ $res = $imp_pgp->storePassphrase(($action == 'PGPSymmetric') ? 'symmetric' : 'personal', $passphrase, Util::getFormData('symmetricid'));
+ }
+ }
if (is_a($secure_check, 'PEAR_Error')) {
$result->error = $secure_check->getMessage();
- } elseif ($passphrase) {
- if ($imp_pgp->storePassphrase(($action == 'PGPSymmetric') ? 'symmetric' : 'personal', $passphrase, $symmetricid)) {
- $result->success = true;
- } else {
- $result->error = _("Invalid passphrase entered.");
- }
- } else {
+ } elseif (!$passphrase) {
$result->error = _("No passphrase entered.");
+ } elseif ($res) {
+ $result->success = true;
+ } else {
+ $result->error = _("Invalid passphrase entered.");
}
/* TODO - This code will eventually be moved to the API. But this function
require_once IMP_BASE . '/lib/DIMP.php';
$notify = false;
- print_r($_SESSION['imp']['cache']);
break;
}
*/
public function savePublicKeyURL($mailbox, $uid, $id)
{
- return $this->getJSOpenWinCode('save_attachment_public_key', false, array('mailbox' => $mailbox, 'uid' => $uid, 'mime_id' => $id));
- }
-
- /**
- * Print out the link for the javascript S/MIME popup.
- *
- * @param integer $actionid The actionID to perform.
- * @param mixed $reload If true, reload base window on close. If text,
- * run this JS on close. If false, don't do
- * anything on close.
- * @param array $params Additional parameters needed for the reload
- * page.
- *
- * @return string The javascript link.
- */
- public function getJSOpenWinCode($actionid, $reload = true,
- $params = array())
- {
- $params['actionID'] = $actionid;
- if (!empty($reload)) {
- if (is_bool($reload)) {
- $params['reload'] = html_entity_decode(Util::removeParameter(Horde::selfUrl(true), array('actionID')));
- } else {
- require_once 'Horde/SessionObjects.php';
- $cacheSess = &Horde_SessionObjects::singleton();
- $params['passphrase_action'] = $cacheSess->storeOid($reload, false);
- }
- }
-
+ $params = array(
+ 'actionID' => 'save_attachment_public_key',
+ 'uid' => $uid,
+ 'mime_id' => $id
+ );
return IMP::popupIMPString('smime.php', $params, 450, 200);
}
case 'PGPSymmetric':
$text = _("Enter the passphrase used to encrypt this message.");
break;
+
+ case 'SMIMEPersonal':
+ $text = _("Enter your personal S/MIME passphrase.");
+ break;
}
$js_params = array(
/* Make sure we have a passphrase. */
$passphrase = $this->_impsmime->getPassphrase();
if ($passphrase === false) {
- if ($_SESSION['imp']['view'] == 'imp') {
- // TODO: Fix to work with DIMP
- $status[] = Horde::link('#', _("You must enter the passphrase for your S/MIME private key to view this message"), null, null, $this->_impsmime->getJSOpenWinCode('open_passphrase_dialog') . 'return false;') . _("You must enter the passphrase for your S/MIME private key to view this message.") . '</a>';
+ $js_action = '';
+ $status[] = _("The message has been encrypted via S/MIME.");
+
+ switch ($_SESSION['imp']['view'] == 'imp') {
+ case 'dimp':
+ $js_action = 'DimpCore.reloadMessage({});';
+ // Fall through
+
+ case 'imp':
+ $status[] = _("The message below has been encrypted via S/MIME.");
+ $status[] = Horde::link('#', '', null, null, IMP::passphraseDialogJS('SMIMEPersonal', $js_action) . ';return false;') . _("You must enter the passphrase for your S/MIME private key to view this message.") . '</a>';
+ break;
}
return null;
}
}
}
-function _outputPassphraseDialog($secure_check)
-{
- if (is_a($secure_check, 'PEAR_Error')) {
- $GLOBALS['notification']->push($secure_check, 'horde.warning');
- }
-
- $title = _("S/MIME Passphrase Input");
- require IMP_TEMPLATES . '/common-header.inc';
- IMP::status();
-
- if (is_a($secure_check, 'PEAR_Error')) {
- return;
- }
-
- $t = new IMP_Template();
- $t->setOption('gettext', true);
- $t->set('submit_url', Util::addParameter(Horde::applicationUrl('smime.php'), 'actionID', 'process_passphrase_dialog'));
- $t->set('reload', htmlspecialchars(html_entity_decode(Util::getFormData('reload'))));
- $t->set('action', Util::getFormData('passphrase_action'));
- $t->set('locked_img', Horde::img('locked.png', _("S/MIME"), null, $GLOBALS['registry']->getImageDir('horde')));
- echo $t->fetch(IMP_TEMPLATES . '/smime/passphrase.html');
-}
-
function _actionWindow()
{
$oid = Util::getFormData('passphrase_action');
/* Run through the action handlers */
$actionID = Util::getFormData('actionID');
switch ($actionID) {
-case 'open_passphrase_dialog':
- if ($imp_smime->getPassphrase() !== false) {
- Util::closeWindowJS();
- } else {
- _outputPassphraseDialog($secure_check);
- }
- exit;
-
-case 'process_passphrase_dialog':
- if (is_a($secure_check, 'PEAR_Error')) {
- _outputPassphraseDialog($secure_check);
- } elseif (Util::getFormData('passphrase')) {
- if ($imp_smime->storePassphrase(Util::getFormData('passphrase'))) {
- if (Util::getFormData('passphrase_action')) {
- _actionWindow();
- } elseif (Util::getFormData('reload')) {
- _reloadWindow();
- } else {
- Util::closeWindowJS();
- }
- } else {
- $notification->push("Invalid passphrase entered.", 'horde.error');
- _outputPassphraseDialog($secure_check);
- }
- } else {
- $notification->push("No passphrase entered.", 'horde.error');
- _outputPassphraseDialog($secure_check);
- }
- exit;
-
case 'delete_key':
$imp_smime->deletePersonalKeys();
$notification->push(_("Personal S/MIME keys deleted successfully."), 'horde.success');
if (!is_a($openssl_check, 'PEAR_Error') && $prefs->getValue('use_smime')) {
Horde::addScriptFile('popup.js', 'imp', true);
$t->set('smimeactive', true);
- $opensmimewin = $imp_smime->getJSOpenWinCode('open_passphrase_dialog');
$t->set('manage_pubkey-help', Help::link('imp', 'smime-manage-pubkey'));
$t->set('verify_notlocked', !$prefs->isLocked('smime_verify'));
$t->set('viewpublic', Horde::link(Util::addParameter($selfURL, 'actionID', 'view_personal_public_key'), _("View Personal Public Key"), null, 'view_key'));
$t->set('infopublic', Horde::link(Util::addParameter($selfURL, 'actionID', 'info_personal_public_key'), _("Information on Personal Public Key"), null, 'info_key'));
$passphrase = $imp_smime->getPassphrase();
- $t->set('passphrase', (empty($passphrase)) ? Horde::link('#', _("Enter Passphrase"), null, null, htmlspecialchars($imp_smime->getJSOpenWinCode('open_passphrase_dialog')) . ' return false;') . _("Enter Passphrase") : Horde::link(Util::addParameter($selfURL, 'actionID', 'unset_passphrase'), _("Unload Passphrase")) . _("Unload Passphrase"));
+ $t->set('passphrase', (empty($passphrase)) ? Horde::link('#', _("Enter Passphrase"), null, null, IMP::passphraseDialogJS('SMIMEPersonal') . ';return false;') . ' return false;') . _("Enter Passphrase") : Horde::link(Util::addParameter($selfURL, 'actionID', 'unset_passphrase'), _("Unload Passphrase")) . _("Unload Passphrase"));
$t->set('viewprivate', Horde::link(Util::addParameter($selfURL, 'actionID', 'view_personal_private_key'), _("View Personal Private Key"), null, 'view_key'));
$t->set('deletekeypair', addslashes(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")));
$t->set('personalkey-delete-help', Help::link('imp', 'smime-delete-personal-certs'));
+++ /dev/null
-<form method="post" name="passphrase_dialog" action="<tag:submit_url />">
-<if:reload>
-<input type="hidden" name="reload" value="<tag:reload />" />
-</if:reload>
-<if:action>
-<input type="hidden" name="passphrase_action" value="<tag:action />" />
-</if:action>
-
-<table class="smallheader">
- <tr>
- <td>
- <tag:locked_img />
- </td>
- <td>
- <gettext>Please enter the passphrase for your S/MIME private key. You will only need to enter this passphrase once per session.</gettext>
- </td>
- </tr>
-</table>
-
-<div class="nowrap padded">
- <label for="passphrase"><strong><gettext>Passphrase:</gettext></strong></label>
- <input type="password" id="passphrase" name="passphrase" size="15" maxlength="60" />
- <input type="submit" name="submit" class="button" value="<gettext>Submit</gettext>" />
- <input type="button" class="button" onclick="window.close();" value="<gettext>Cancel</gettext>" />
-</p>
-
-</form>
-
-<script type="text/javascript">
-document.passphrase_dialog.passphrase.focus();
-</script>