Author: Mike Cochrane (mike@graftonhall.co.nz)
コード例 #1
0
ファイル: Ui.php プロジェクト: horde/horde
 /**
  * Return a list of valid encrypt HTML option tags.
  *
  * @param string $default      The default encrypt option.
  * @param boolean $returnList  Whether to return a hash with options
  *                             instead of the options tag.
  *
  * @return mixed  The list of option tags. This is empty if no encryption
  *                is available.
  */
 public function encryptList($default = null, $returnList = false)
 {
     global $injector, $prefs;
     if (is_null($default)) {
         $default = $prefs->getValue('default_encrypt');
     }
     $enc_opts = array();
     $output = '';
     if (IMP_Pgp::enabled()) {
         $enc_opts += $injector->getInstance('IMP_Pgp')->encryptList();
     }
     if (IMP_Smime::enabled()) {
         $enc_opts += $injector->getInstance('IMP_Smime')->encryptList();
     }
     if (!empty($enc_opts)) {
         $enc_opts = array_merge(array(IMP::ENCRYPT_NONE => _("None")), $enc_opts);
     }
     if ($returnList) {
         return $enc_opts;
     }
     foreach ($enc_opts as $key => $val) {
         $output .= '<option value="' . $key . '"' . ($default == $key ? ' selected="selected"' : '') . '>' . $val . "</option>\n";
     }
     return $output;
 }
コード例 #2
0
ファイル: Compose.php プロジェクト: horde/horde
 /**
  * Constructor.
  */
 public function __construct()
 {
     global $page_output, $prefs, $registry;
     $this->_files[] = new Horde_Script_File_JsDir('compose.js', 'imp');
     $this->_files[] = new Horde_Script_File_JsDir('draghandler.js', 'imp');
     $this->_files[] = new Horde_Script_File_JsDir('editor.js', 'imp');
     $this->_files[] = new Horde_Script_File_JsDir('imp.js', 'imp');
     if (!$prefs->isLocked('default_encrypt') && (IMP_Pgp::enabled() || IMP_Smime::enabled())) {
         $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
         $this->_files[] = new Horde_Script_File_JsDir('passphrase.js', 'imp');
     }
     if (!IMP_Compose::canHtmlCompose()) {
         return;
     }
     switch ($registry->getView()) {
         case $registry::VIEW_BASIC:
         case $registry::VIEW_DYNAMIC:
             $this->_files[] = new Horde_Script_File_JsDir('ckeditor/imageupload.js', 'imp');
             $this->_files[] = new Horde_Script_File_JsDir('ckeditor/images.js', 'imp');
             $page_output->addInlineJsVars(array('ImpCkeditorImgs.related_attr' => IMP_Compose::RELATED_ATTR));
             $js = new Horde_Script_File_JsDir('ckeditor/pasteattachment.js', 'imp');
             $upload_url = $registry->getServiceLink('ajax', 'imp')->url . 'addAttachmentCkeditor';
             $page_output->addInlineScript(array('if (window.CKEDITOR) { CKEDITOR.on("loaded", function(e) {' . 'CKEDITOR.plugins.addExternal("pasteattachment", "' . $js->url->url . '", "");' . 'CKEDITOR.config.filebrowserImageUploadUrl = "' . $upload_url . '";' . '}); };'), true);
             break;
     }
 }
コード例 #3
0
ファイル: Smime.php プロジェクト: horde/horde
 /**
  * Generates HTML output for the S/MIME key.
  *
  * @return string  The HTML output.
  */
 protected function _outputSmimeKey()
 {
     if (empty($this->_impsmime)) {
         return array();
     }
     $raw_text = $this->_getPartStream($this->_mimepart->getMimeId());
     try {
         $sig_result = $this->_impsmime->verifySignature($this->_mimepart->replaceEOL($raw_text, Horde_Mime_Part::RFC_EOL));
     } catch (Horde_Exception $e) {
         return array();
     }
     return array($this->_mimepart->getMimeId() => array('data' => $this->_impsmime->certToHTML($sig_result->cert), 'type' => 'text/html; charset=' . $this->getConfigParam('charset')));
 }
コード例 #4
0
ファイル: Common.php プロジェクト: horde/horde
 /**
  */
 protected function _compose($base, $view, $args)
 {
     global $injector, $registry, $page_output, $prefs;
     $view->title = $args['title'];
     /* Load Identity. */
     $identity = $injector->getInstance('IMP_Identity');
     $selected_identity = intval($identity->getDefault());
     /* Generate identities list. */
     $this->_addIdentityJs();
     if (IMP_Compose::canHtmlCompose()) {
         $view->compose_html = !empty($args['show_editor']);
         $view->rte = true;
         $page_output->addScriptPackage('IMP_Script_Package_Editor');
         $page_output->addScriptFile('external/base64.js');
     }
     /* Create list for sent-mail selection. */
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS) && !$prefs->isLocked('save_sent_mail')) {
         $view->save_sent_mail = true;
         $view->save_sent_mail_select = !$prefs->isLocked(IMP_Mailbox::MBOX_SENT);
     }
     $view->drafts = $imp_imap->access(IMP_Imap::ACCESS_DRAFTS) && ($draft = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS)) && !$draft->readonly;
     $view->compose_link = $registry->getServiceLink('ajax', 'imp')->url . 'addAttachment';
     $view->resume = !empty($args['resume']);
     $view->is_template = !empty($args['template']);
     $view->read_receipt_set = strcasecmp($prefs->getValue('request_mdn'), 'always') === 0;
     $view->user = $registry->getAuth();
     if (IMP_Compose::canUploadAttachment()) {
         $view->attach = true;
         $view->max_size = IMP_Compose::maxAttachmentSize();
         $view->save_attach_set = strcasecmp($prefs->getValue('save_attachments'), 'always') === 0;
     } else {
         $view->attach = false;
     }
     if ($prefs->getValue('use_pgp') && $prefs->getValue('pgp_public_key')) {
         $view->pgp_pubkey = $prefs->getValue('pgp_attach_pubkey');
     }
     if ($registry->hasMethod('contacts/ownVCard')) {
         $view->vcard_attach = true;
     }
     $view->priority = $prefs->getValue('set_priority');
     if (!$prefs->isLocked('default_encrypt') && (IMP_Pgp::enabled() || IMP_Smime::enabled())) {
         $view->encrypt = $prefs->getValue('default_encrypt');
     }
     $from_list = array();
     foreach ($identity->getSelectList() as $id => $from) {
         $from_list[] = array('label' => $from, 'sel' => $id == $selected_identity, 'val' => $id);
     }
     $view->from_list = $from_list;
     $view->signature = $identity->hasSignature(true);
     $view->sigExpanded = $prefs->getValue('signature_expanded');
 }
コード例 #5
0
ファイル: Compose.php プロジェクト: raz0rsdge/horde
 /**
  * Encrypt an outgoing message.
  *
  * @param Horde_Mime_Part $msg             Outgoing message.
  * @param integer $encrypt                 Encryption type.
  * @param Horde_Mail_Rfc822_List $recip    Recipient list.
  * @param Horde_Mail_Rfc822_Address $from  Sending address.
  *
  * @return Horde_Mime_Part $msg  Processed outgoing message.
  */
 protected function _encryptMessage(Horde_Mime_Part $msg, $encrypt, Horde_Mail_Rfc822_List $recip, Horde_Mail_Rfc822_Address $from)
 {
     global $injector;
     /* Add personal address to encrypted message. */
     switch ($encrypt) {
         case IMP_Pgp::ENCRYPT:
         case IMP_Pgp::SIGNENC:
         case IMP_Pgp::SYM_ENCRYPT:
         case IMP_Pgp::SYM_SIGNENC:
         case IMP_Smime::ENCRYPT:
         case IMP_Smime::SIGNENC:
             $recip2 = clone $recip;
             $recip2->add($from);
             break;
     }
     switch ($encrypt) {
         case IMP_Pgp::ENCRYPT:
         case IMP_Pgp::SIGN:
         case IMP_Pgp::SIGNENC:
         case IMP_Pgp::SYM_ENCRYPT:
         case IMP_Pgp::SYM_SIGNENC:
             if (IMP_Pgp::enabled()) {
                 break;
             }
             $imp_pgp = $injector->getInstance('IMP_Pgp');
             switch ($encrypt) {
                 case IMP_Pgp::SIGN:
                 case IMP_Pgp::SIGNENC:
                 case IMP_Pgp::SYM_SIGNENC:
                     /* Check to see if we have the user's passphrase yet. */
                     $passphrase = $imp_pgp->getPassphrase('personal');
                     if (empty($passphrase)) {
                         $e = new IMP_Compose_Exception(_("PGP: Need passphrase for personal private key."));
                         $e->encrypt = 'pgp_passphrase_dialog';
                         throw $e;
                     }
                     break;
                 case IMP_Pgp::SYM_ENCRYPT:
                 case IMP_Pgp::SYM_SIGNENC:
                     /* Check to see if we have the user's symmetric passphrase
                      * yet. */
                     $symmetric_passphrase = $imp_pgp->getPassphrase('symmetric', 'imp_compose_' . $this->_cacheid);
                     if (empty($symmetric_passphrase)) {
                         $e = new IMP_Compose_Exception(_("PGP: Need passphrase to encrypt your message with."));
                         $e->encrypt = 'pgp_symmetric_passphrase_dialog';
                         throw $e;
                     }
                     break;
             }
             /* Do the encryption/signing requested. */
             try {
                 switch ($encrypt) {
                     case IMP_Pgp::SIGN:
                         $msg2 = $imp_pgp->signMimePart($msg);
                         $this->_setMetadata('encrypt_sign', true);
                         return $msg2;
                     case IMP_Pgp::ENCRYPT:
                     case IMP_Pgp::SYM_ENCRYPT:
                         return $imp_pgp->encryptMimePart($msg, $recip2, $encrypt == IMP_Pgp::SYM_ENCRYPT ? $symmetric_passphrase : null);
                     case IMP_Pgp::SIGNENC:
                     case IMP_Pgp::SYM_SIGNENC:
                         return $imp_pgp->signAndEncryptMimePart($msg, $recip2, $encrypt == IMP_Pgp::SYM_SIGNENC ? $symmetric_passphrase : null);
                         break;
                 }
             } catch (Horde_Exception $e) {
                 throw new IMP_Compose_Exception(_("PGP Error: ") . $e->getMessage(), $e->getCode());
             }
             break;
         case IMP_Smime::ENCRYPT:
         case IMP_Smime::SIGN:
         case IMP_Smime::SIGNENC:
             if (!IMP_Smime::enabled()) {
                 break;
             }
             $imp_smime = $injector->getInstance('IMP_Smime');
             /* Check to see if we have the user's passphrase yet. */
             switch ($encrypt) {
                 case IMP_Smime::SIGN:
                 case IMP_Smime::SIGNENC:
                     if (($passphrase = $imp_smime->getPassphrase()) === false) {
                         $e = new IMP_Compose_Exception(_("S/MIME Error: Need passphrase for personal private key."));
                         $e->encrypt = 'smime_passphrase_dialog';
                         throw $e;
                     }
                     break;
             }
             /* Do the encryption/signing requested. */
             try {
                 switch ($encrypt) {
                     case IMP_Smime::SIGN:
                         $msg2 = $imp_smime->signMimePart($msg);
                         $this->_setMetadata('encrypt_sign', true);
                         return $msg2;
                     case IMP_Smime::ENCRYPT:
                         return $imp_smime->encryptMimePart($msg, $recip2);
                     case IMP_Smime::SIGNENC:
                         return $imp_smime->signAndEncryptMimePart($msg, $recip2);
                 }
             } catch (Horde_Exception $e) {
                 throw new IMP_Compose_Exception(_("S/MIME Error: ") . $e->getMessage(), $e->getCode());
             }
             break;
     }
     return $msg;
 }
コード例 #6
0
ファイル: Smime.php プロジェクト: raz0rsdge/horde
 /**
  * Print certificate information.
  *
  * @param string $cert  The S/MIME certificate.
  */
 protected function _printCertInfo($cert = '')
 {
     $cert_info = $this->_smime->certToHTML($cert);
     $this->_textWindowOutput(_("S/MIME Key Information"), empty($cert_info) ? _("Invalid key") : $cert_info, !empty($cert_info));
 }