Remove Horde_Core dependency in Horde_Crypt
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 25 Mar 2010 20:27:20 +0000 (14:27 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 25 Mar 2010 20:27:20 +0000 (14:27 -0600)
18 files changed:
framework/Crypt/lib/Horde/Crypt.php
framework/Crypt/lib/Horde/Crypt/Pgp.php
framework/Crypt/lib/Horde/Crypt/Smime.php
framework/Nls/package.xml
framework/Tree/package.xml
imp/compose.php
imp/lib/Ajax/Imple/PassphraseDialog.php
imp/lib/Application.php
imp/lib/Compose.php
imp/lib/Crypt/Pgp.php
imp/lib/Crypt/Smime.php
imp/lib/Injector/Binder/Pgp.php [new file with mode: 0644]
imp/lib/Injector/Binder/Smime.php [new file with mode: 0644]
imp/lib/Mime/Viewer/Pgp.php
imp/lib/Mime/Viewer/Plain.php
imp/lib/Mime/Viewer/Smime.php
imp/pgp.php
imp/smime.php

index 50b64fa..2aa6b07 100644 (file)
 class Horde_Crypt
 {
     /**
-     * Singleton instances.
-     *
-     * @var array
-     */
-    static protected $_instances = array();
-
-    /**
      * The temporary directory to use.
      *
      * @var string
@@ -64,35 +57,22 @@ class Horde_Crypt
     }
 
     /**
-     * Attempts to return a reference to a concrete Horde_Crypt instance
-     * based on $driver. It will only create a new instance if no
-     * Horde_Crypt instance with the same parameters currently exists.
+     * Constructor.
      *
-     * This should be used if multiple crypto backends (and, thus,
-     * multiple Horde_Crypt instances) are required.
+     * @param array $params  Configuration parameters:
+     * <pre>
+     * 'temp' - (string) [REQUIRED] Location of temporary directory.
+     * </pre>
      *
-     * This method must be invoked as: $var = Horde_Crypt::singleton()
-     *
-     * @param mixed $driver  The type of concrete Horde_Crypt subclass to
-     *                       return. If $driver is an array, then we will look
-     *                       in $driver[0]/lib/Crypt/ for the subclass
-     *                       implementation named $driver[1].php.
-     * @param array $params  A hash containing any additional configuration or
-     *                       connection parameters a subclass might need.
-     *
-     * @return Horde_Crypt  The concrete Horde_Crypt reference.
-     * @throws Horde_Exception
+     * @throws InvalidArgumentException
      */
-    static public function singleton($driver, $params = array())
+    public function __construct($params = array())
     {
-        ksort($params);
-        $signature = hash('md5', serialize(array($driver, $params)));
-
-        if (!isset(self::$_instances[$signature])) {
-            self::$_instances[$signature] = self::factory($driver, $params);
+        if (empty($params['temp'])) {
+            throw new InvalidArgumentException('A temporary directory must be provided.');
         }
 
-        return self::$_instances[$signature];
+        $this->_tempdir = Horde_Util::createTempDir(true, $params['temp']);
     }
 
     /**
index 03fd21a..1d3a8a6 100644 (file)
@@ -117,22 +117,30 @@ class Horde_Crypt_Pgp extends Horde_Crypt
     protected $_privateKeyring;
 
     /**
+     * Configuration parameters.
+     *
+     * @var array
+     */
+    protected $_params = array();
+
+    /**
      * Constructor.
      *
      * @param array $params  The following parameters:
      * <pre>
      * 'program' - (string) [REQUIRED] The path to the GnuPG binary.
-     * 'temp' - (string) [OPTIONAL] Path to a temporary directory.
+     * 'proxy_host - (string) Proxy host.
+     * 'proxy_port - (integer) Proxy port.
      * </pre>
      *
-     * @throws Horde_Exception
+     * @throws InvalidArgumentException
      */
-    protected function __construct($params = array())
+    public function __construct($params = array())
     {
-        $this->_tempdir = Horde_Util::createTempDir(true, $params['temp']);
+        parent::__construct($params);
 
         if (empty($params['program'])) {
-            throw new Horde_Exception('The location of the GnuPG binary must be given to the Horde_Crypt_Pgp:: class.');
+            throw new InvalidArgumentException('The location of the GnuPG binary must be given to the Horde_Crypt_Pgp:: class.');
         }
 
         /* Store the location of GnuPG and set common options. */
@@ -149,6 +157,8 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         if (strncasecmp(PHP_OS, 'WIN', 3)) {
             array_unshift($this->_gnupg, 'LANG= ;');
         }
+
+        $this->_params = $params;
     }
 
     /**
@@ -880,11 +890,11 @@ class Horde_Crypt_Pgp extends Horde_Crypt
     /**
      * Connects to a public key server via HKP (Horrowitz Keyserver Protocol).
      *
-     * @param string $method   POST, GET, etc.
-     * @param string $server   The keyserver to use.
-     * @param string $uri      The URI to access (relative to the server).
-     * @param string $command  The PGP command to run.
-     * @param float $timeout   The timeout value.
+     * @param string $method    POST, GET, etc.
+     * @param string $server    The keyserver to use.
+     * @param string $resource  The URI to access (relative to the server).
+     * @param string $command   The PGP command to run.
+     * @param float $timeout    The timeout value.
      *
      * @return string  The text from standard output on success.
      * @throws Horde_Exception
@@ -896,15 +906,13 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $output = '';
 
         $port = '11371';
-        if (!empty($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
+        if (!empty($this->_params['proxy_host'])) {
             $resource = 'http://' . $server . ':' . $port . $resource;
 
-            $server = $GLOBALS['conf']['http']['proxy']['proxy_host'];
-            if (!empty($GLOBALS['conf']['http']['proxy']['proxy_port'])) {
-                $port = $GLOBALS['conf']['http']['proxy']['proxy_port'];
-            } else {
-                $port = 80;
-            }
+            $server = $this->_params['proxy_host'];
+            $port = isset($this->_params['proxy_port'])
+                ? $this->_params['proxy_port']
+                : 80;
         }
 
         $command = $method . ' ' . $resource . ' HTTP/1.0' . ($command ? "\r\n" . $command : '');
index bf97949..856cf82 100644 (file)
@@ -62,17 +62,6 @@ class Horde_Crypt_Smime extends Horde_Crypt
     );
 
     /**
-     * Constructor.
-     *
-     * @param array $params  Parameter array.
-     *                       'temp' => Location of temporary directory.
-     */
-    protected function __construct($params)
-    {
-        $this->_tempdir = $params['temp'];
-    }
-
-    /**
      * Verify a passphrase for a given private key.
      *
      * @param string $private_key  The user's private key.
index 699b0ed..9b25f52 100644 (file)
@@ -61,6 +61,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <channel>pear.horde.org</channel>
    </package>
    <package>
+    <name>Core</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
     <name>Util</name>
     <channel>pear.horde.org</channel>
    </package>
index f50927e..da0e0f3 100644 (file)
@@ -55,6 +55,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <min>1.7.0</min>
    </pearinstaller>
    <package>
+    <name>Core</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
     <name>Util</name>
     <channel>pear.horde.org</channel>
    </package>
index d0b8457..974a550 100644 (file)
@@ -673,7 +673,7 @@ if ($prefs->getValue('use_pgp') && !$prefs->isLocked('default_encrypt')) {
         try {
             $addrs = $imp_compose->recipientList($header);
             if (!empty($addrs['list'])) {
-                $imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
+                $imp_pgp = $injector->getInstance('IMP_Crypt_Pgp');
                 foreach ($addrs['list'] as $val) {
                     $imp_pgp->getPublicKey($val);
                 }
index 43e5b09..e0abbb0 100644 (file)
@@ -133,7 +133,7 @@ class IMP_Ajax_Imple_PassphraseDialog extends Horde_Ajax_Imple_Base
             case 'pgpPersonal':
             case 'pgpSymmetric':
                 if ($this->_vars->dialog_input) {
-                    $imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
+                    $imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
                     if ((($vars->type == 'pgpPersonal') &&
                          $imp_pgp->storePassphrase('personal', $this->_vars->dialog_input)) ||
                         (($vars->type == 'pgpSymmeetric') &&
@@ -149,7 +149,7 @@ class IMP_Ajax_Imple_PassphraseDialog extends Horde_Ajax_Imple_Base
 
             case 'smimePersonal':
                 if ($this->_vars->dialog_input) {
-                $imp_smime = Horde_Crypt::singleton(array('IMP', 'Smime'));
+                    $imp_smime = $GLOBALS['injector']->getInstance('IMP_Crypt_Smime');
                     if ($imp_smime->storePassphrase($this->_vars->dialog_input)) {
                         $result->success = 1;
                     } else {
index 54c811b..ef334a8 100644 (file)
@@ -100,6 +100,8 @@ class IMP_Application extends Horde_Registry_Application
     {
         /* Add IMP-specific binders. */
         $binders = array(
+            'IMP_Crypt_Pgp' => new IMP_Injector_Binder_Pgp(),
+            'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(),
             'IMP_Folder' => new IMP_Injector_Binder_Folder(),
             'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(),
             'IMP_Sentmail' => new IMP_Injector_Binder_Sentmail()
index 6859287..4b57063 100644 (file)
@@ -1183,7 +1183,7 @@ class IMP_Compose
 
         if ($attach_flag) {
             if ($this->_pgpAttachPubkey) {
-                $imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
+                $imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
                 $base->addPart($imp_pgp->publicKeyMIMEPart());
             }
 
@@ -1197,7 +1197,7 @@ class IMP_Compose
         if ($GLOBALS['prefs']->getValue('use_pgp') &&
             !empty($GLOBALS['conf']['gnupg']['path']) &&
             in_array($encrypt, array(IMP::PGP_ENCRYPT, IMP::PGP_SIGN, IMP::PGP_SIGNENC, IMP::PGP_SYM_ENCRYPT, IMP::PGP_SYM_SIGNENC))) {
-            $imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
+            $imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
 
             switch ($encrypt) {
             case IMP::PGP_SIGN:
@@ -1253,7 +1253,7 @@ class IMP_Compose
             }
         } elseif ($GLOBALS['prefs']->getValue('use_smime') &&
                   in_array($encrypt, array(IMP::SMIME_ENCRYPT, IMP::SMIME_SIGN, IMP::SMIME_SIGNENC))) {
-            $imp_smime = Horde_Crypt::singleton(array('IMP', 'Smime'));
+            $imp_smime = $GLOBALS['injector']->getInstance('IMP_Crypt_Smime');
 
             /* Check to see if we have the user's passphrase yet. */
             if (in_array($encrypt, array(IMP::SMIME_SIGN, IMP::SMIME_SIGNENC))) {
index 43eeede..6ecdd18 100644 (file)
@@ -17,17 +17,6 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
     const PUBKEY_FIELD = 'pgpPublicKey';
 
     /**
-     * Constructor
-     */
-    public function __construct()
-    {
-        parent::__construct(array(
-            'program' => $GLOBALS['conf']['gnupg']['path'],
-            'temp' => Horde::getTempDir()
-        ));
-    }
-
-    /**
      * Generate the personal Public/Private keypair and store in prefs.
      *
      * @param string $realname    See Horde_Crypt_Pgp::
index e42d788..5cf3841 100644 (file)
@@ -17,14 +17,6 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
     const PUBKEY_FIELD = 'smimePublicKey';
 
     /**
-     * Constructor.
-     */
-    public function __construct()
-    {
-        parent::__construct(array('temp' => Horde::getTempDir()));
-    }
-
-    /**
      * Add the personal public key to the prefs.
      *
      * @param mixed $key  The public key to add (either string or array).
diff --git a/imp/lib/Injector/Binder/Pgp.php b/imp/lib/Injector/Binder/Pgp.php
new file mode 100644 (file)
index 0000000..7fcfdf8
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Binder for IMP_Crypt_Pgp.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package IMP
+ */
+class IMP_Injector_Binder_Pgp implements Horde_Injector_Binder
+{
+    /**
+     */
+    public function create(Horde_Injector $injector)
+    {
+        $params = array(
+            'program' => $GLOBALS['conf']['gnupg']['path'],
+            'temp' => Horde::getTempDir()
+        );
+
+        if (isset($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
+            $params['proxy_host'] = $GLOBALS['conf']['http']['proxy']['proxy_host'];
+            if (isset($GLOBALS['conf']['http']['proxy']['proxy_port'])) {
+                $params['proxy_port'] = $GLOBALS['conf']['http']['proxy']['proxy_port'];
+            }
+        }
+
+        return Horde_Crypt::factory(array('IMP', 'Pgp'), $params);
+    }
+
+    /**
+     */
+    public function equals(Horde_Injector_Binder $binder)
+    {
+        return false;
+    }
+
+}
diff --git a/imp/lib/Injector/Binder/Smime.php b/imp/lib/Injector/Binder/Smime.php
new file mode 100644 (file)
index 0000000..45bd8a5
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Binder for IMP_Crypt_Smime.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package IMP
+ */
+class IMP_Injector_Binder_Smime implements Horde_Injector_Binder
+{
+    /**
+     */
+    public function create(Horde_Injector $injector)
+    {
+        return Horde_Crypt::factory(array('IMP', 'Smime'), array(
+            'temp' => Horde::getTempDir()
+        ));
+    }
+
+    /**
+     */
+    public function equals(Horde_Injector_Binder $binder)
+    {
+        return false;
+    }
+
+}
index 28edf68..ed6d8e7 100644 (file)
@@ -49,13 +49,6 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
     );
 
     /**
-     * IMP_Crypt_Pgp object.
-     *
-     * @var IMP_Crypt_Pgp
-     */
-    protected $_imppgp;
-
-    /**
      * The address of the sender.
      *
      * @var string
@@ -86,11 +79,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
             )
         );
 
-        if (empty($this->_imppgp)) {
-            $this->_imppgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
-        }
-
-        $parts = $this->_imppgp->parsePGPData($this->_mimepart->getContents());
+        $parts = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp')->parsePGPData($this->_mimepart->getContents());
         foreach (array_keys($parts) as $key) {
             if ($parts[$key]['type'] == Horde_Crypt_Pgp::ARMOR_SIGNATURE) {
                 $ret[$id]['data'] = implode("\r\n", $parts[$key]['data']);
@@ -110,11 +99,6 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
     {
         $id = $this->_mimepart->getMimeId();
 
-        if (empty($this->_imppgp) &&
-            !empty($GLOBALS['conf']['gnupg']['path'])) {
-            $this->_imppgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
-        }
-
         if (Horde_Util::getFormData('rawpgpkey')) {
             return array(
                 $id => array(
@@ -198,10 +182,6 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
             return null;
         }
 
-        if (empty($this->_imppgp)) {
-            $this->_imppgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
-        }
-
         /* PGP version information appears in the first MIME subpart. We
          * don't currently need to do anything with this information. The
          * encrypted data appears in the second MIME subpart. */
@@ -212,10 +192,11 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
 
         /* Check if this a symmetrically encrypted message. */
         try {
-            $symmetric = $this->_imppgp->encryptedSymmetrically($encrypted_data);
+            $imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
+            $symmetric = $imp_pgp->encryptedSymmetrically($encrypted_data);
             if ($symmetric) {
                 $symmetric_id = $this->_getSymmetricID();
-                $symmetric_pass = $this->_imppgp->getPassphrase('symmetric', $symmetric_id);
+                $symmetric_pass = $imp_pgp->getPassphrase('symmetric', $symmetric_id);
 
                 if (is_null($symmetric_pass)) {
                     $status[] = _("The data in this part has been encrypted via PGP.");
@@ -235,7 +216,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
 
         /* Check if this is a literal compressed message. */
         try {
-            $info = $this->_imppgp->pgpPacketInformation($encrypted_data);
+            $info = $imp_pgp->pgpPacketInformation($encrypted_data);
         } catch (Horde_Exception $e) {
             Horde::logMessage($e, 'INFO');
             return null;
@@ -248,8 +229,8 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
             $status[] = _("The data in this part has been encrypted via PGP.");
 
             if (!$symmetric) {
-                if ($this->_imppgp->getPersonalPrivateKey()) {
-                    $personal_pass = $this->_imppgp->getPassphrase('personal');
+                if ($imp_pgp->getPersonalPrivateKey()) {
+                    $personal_pass = $imp_pgp->getPassphrase('personal');
                     if (is_null($personal_pass)) {
                         /* Ask for the private key's passphrase if this is
                          * encrypted asymmetrically. */
@@ -269,16 +250,16 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
 
         try {
             if (!is_null($symmetric_pass)) {
-                $decrypted_data = $this->_imppgp->decryptMessage($encrypted_data, 'symmetric', $symmetric_pass);
+                $decrypted_data = $imp_pgp->decryptMessage($encrypted_data, 'symmetric', $symmetric_pass);
             } elseif (!is_null($personal_pass)) {
-                $decrypted_data = $this->_imppgp->decryptMessage($encrypted_data, 'personal', $personal_pass);
+                $decrypted_data = $imp_pgp->decryptMessage($encrypted_data, 'personal', $personal_pass);
             } else {
-                $decrypted_data = $this->_imppgp->decryptMessage($encrypted_data, 'literal');
+                $decrypted_data = $imp_pgp->decryptMessage($encrypted_data, 'literal');
             }
         } catch (Horde_Exception $e) {
             $status[] = _("The data in this part does not appear to be a valid PGP encrypted message. Error: ") . $e->getMessage();
             if (!is_null($symmetric_pass)) {
-                $this->_imppgp->unsetPassphrase('symmetric', $this->_getSymmetricID());
+                $imp_pgp->unsetPassphrase('symmetric', $this->_getSymmetricID());
                 return $this->_getEmbeddedMimeParts();
             }
             return null;
@@ -311,16 +292,17 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
         );
 
         $mime_id = $this->_mimepart->getMimeId();
+        $imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
 
         if ($GLOBALS['prefs']->getValue('use_pgp') &&
             $GLOBALS['prefs']->getValue('add_source') &&
             $GLOBALS['registry']->hasMethod('contacts/addField')) {
-            $status['text'][] = Horde::link('#', '', '', '', $this->_imppgp->savePublicKeyURL($this->_params['contents']->getMailbox(), $this->_params['contents']->getUid(), $mime_id) . 'return false;') . _("Save the key to your address book.") . '</a>';
+            $status['text'][] = Horde::link('#', '', '', '', $imp_pgp->savePublicKeyURL($this->_params['contents']->getMailbox(), $this->_params['contents']->getUid(), $mime_id) . 'return false;') . _("Save the key to your address book.") . '</a>';
         }
         $status['text'][] = $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("View the raw text of the Public Key."), array('jstext' => _("View Public Key"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE, 'rawpgpkey' => 1)));
 
         try {
-            $data = '<span class="fixed">' . nl2br(str_replace(' ', '&nbsp;', $this->_imppgp->pgpPrettyKey($this->_mimepart->getContents()))) . '</span>';
+            $data = '<span class="fixed">' . nl2br(str_replace(' ', '&nbsp;', $imp_pgp->pgpPrettyKey($this->_mimepart->getContents()))) . '</span>';
         } catch (Horde_Exception $e) {
             $data = $e->getMessage();
         }
@@ -377,9 +359,10 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
             $sig_part = $this->_params['contents']->getMIMEPart($sig_id);
 
             try {
+                $imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
                 $sig_result = $sig_part->getMetadata('imp-pgp-signature')
-                    ? $this->_imppgp->verifySignature($sig_part->getContents(array('canonical' => true)), $this->_address)
-                    : $this->_imppgp->verifySignature($sig_part->replaceEOL($this->_params['contents']->getBodyPart($signed_id, array('mimeheaders' => true)), Horde_Mime_Part::RFC_EOL), $this->_address, $sig_part->getContents());
+                    ? $imp_pgp->verifySignature($sig_part->getContents(array('canonical' => true)), $this->_address)
+                    : $imp_pgp->verifySignature($sig_part->replaceEOL($this->_params['contents']->getBodyPart($signed_id, array('mimeheaders' => true)), Horde_Mime_Part::RFC_EOL), $this->_address, $sig_part->getContents());
 
                 $icon = Horde::img('alerts/success.png', _("Success"));
                 $sig_text = $sig_result->message;
@@ -423,7 +406,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Driver
      */
     protected function _getSymmetricID()
     {
-        return $this->_imppgp->getSymmetricID($this->_params['contents']->getMailbox(), $this->_params['contents']->getUid(), $this->_mimepart->getMimeId());
+        return $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp')->getSymmetricID($this->_params['contents']->getMailbox(), $this->_params['contents']->getUid(), $this->_mimepart->getMimeId());
     }
 
     /**
index b641f80..0d93ff9 100644 (file)
@@ -207,8 +207,7 @@ class IMP_Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
     protected function _parsePGP()
     {
         /* Avoid infinite loop. */
-        $imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
-        $parts = $imp_pgp->parsePGPData($this->_mimepart->getContents());
+        $parts = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp')->parsePGPData($this->_mimepart->getContents());
         if (empty($parts) ||
             ((count($parts) == 1) &&
              ($parts[0]['type'] == Horde_Crypt_Pgp::ARMOR_TEXT))) {
index bbd32e1..46757f0 100644 (file)
@@ -69,7 +69,7 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Driver
         if (is_null($this->_impsmime) &&
             $GLOBALS['prefs']->getValue('use_smime')) {
             try {
-                $this->_impsmime = Horde_Crypt::singleton(array('IMP', 'Smime'));
+                $this->_impsmime = $GLOBALS['injector']->getInstance('IMP_Crypt_Smime');
                 $this->_impsmime->checkForOpenSSL();
             } catch (Horde_Exception $e) {
                 $this->_impsmime = null;
index 28f576c..c1f8cda 100644 (file)
@@ -14,7 +14,7 @@
 require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('imp');
 
-$imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
+$imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
 $secure_check = Horde::isConnectionSecure();
 
 /* Run through the action handlers */
index 589a3bc..84ec9d5 100644 (file)
@@ -15,7 +15,7 @@
 require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('imp');
 
-$imp_smime = Horde_Crypt::singleton(array('IMP', 'Smime'));
+$imp_smime = $GLOBALS['injector']->getInstance('IMP_Crypt_Smime');
 
 /* Run through the action handlers */
 $actionID = Horde_Util::getFormData('actionID');