1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Prefs_Special_SmimePrivateKey implements Horde_Core_Prefs_Ui_Special
24: {
25: 26:
27: public function init(Horde_Core_Prefs_Ui $ui)
28: {
29: }
30:
31: 32:
33: public function display(Horde_Core_Prefs_Ui $ui)
34: {
35: global $injector, $page_output, $prefs, $session;
36:
37: $page_output->addScriptPackage('IMP_Script_Package_Imp');
38:
39: $view = new Horde_View(array(
40: 'templatePath' => IMP_TEMPLATES . '/prefs'
41: ));
42: $view->addHelper('Horde_Core_View_Helper_Help');
43:
44: if (!Horde::isConnectionSecure()) {
45: $view->notsecure = true;
46: } else {
47: $smime_url = IMP_Basic_Smime::url();
48:
49: $view->has_key = ($prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key'));
50:
51: if ($view->has_key) {
52: $view->viewpublic = Horde::link($smime_url->copy()->add('actionID', 'view_personal_public_key'), _("View Personal Public Certificate"), null, 'view_key');
53: $view->infopublic = Horde::link($smime_url->copy()->add('actionID', 'info_personal_public_key'), _("Information on Personal Public Certificate"), null, 'info_key');
54:
55: if ($injector->getInstance('IMP_Crypt_Smime')->getPassphrase()) {
56: $view->passphrase = Horde::link($ui->selfUrl(array(
57: 'special' => true,
58: 'token' => true
59: ))->add('unset_smime_passphrase', 1), _("Unload Passphrase")) . _("Unload Passphrase");
60: } else {
61: $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array(
62: 'params' => array(
63: 'reload' => $ui->selfUrl()->setRaw(true)
64: ),
65: 'type' => 'smimePersonal'
66: ));
67: $view->passphrase = Horde::link('#', _("Enter Passphrase"), null, null, null, null, null, array('id' => $imple->getDomId())) . _("Enter Passphrase");
68: }
69:
70: $view->viewprivate = Horde::link($smime_url->copy()->add('actionID', 'view_personal_private_key'), _("View Personal Private Key"), null, 'view_key');
71: $page_output->addInlineScript(array(
72: '$("delete_smime_personal").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) . ')) { e.stop(); } })'
73: ), true);
74: } elseif ($session->get('imp', 'file_upload')) {
75: $view->import = true;
76: $page_output->addInlineScript(array(
77: '$("import_smime_personal").observe("click", function(e) { ' . Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_personal_certs', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 275, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'
78: ), true);
79: }
80: }
81:
82: return $view->render('smimeprivatekey');
83: }
84:
85: 86:
87: public function update(Horde_Core_Prefs_Ui $ui)
88: {
89: global $injector, $notification;
90:
91: if (isset($ui->vars->delete_smime_personal)) {
92: $injector->getInstance('IMP_Crypt_Smime')->deletePersonalKeys();
93: $notification->push(_("Personal S/MIME keys deleted successfully."), 'horde.success');
94: } elseif (isset($ui->vars->unset_smime_passphrase)) {
95: $injector->getInstance('IMP_Crypt_Smime')->unsetPassphrase();
96: $notification->push(_("S/MIME passphrase successfully unloaded."), 'horde.success');
97: }
98:
99: return false;
100: }
101:
102: }
103: