[Tickets #5896] Enabling retrieving PGP-PublicKeys withing the Horde pref System

bugs at bugs.horde.org bugs at bugs.horde.org
Sun Nov 18 20:01:05 UTC 2007


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=5896
-----------------------------------------------------------------------
 Ticket             | 5896
 Created By         | horde at immerda.ch
 Summary            | Enabling retrieving PGP-PublicKeys withing the Horde pref System
 Queue              | IMP
 Version            | 4.1.5
 Type               | Enhancement
 State              | New
 Priority           | 1. Low
 Owners             | 
-----------------------------------------------------------------------


horde at immerda.ch (2007-11-18 12:01) wrote:

This patch enables that IMP is first looking within horde's own preference
storage to retrieve a public key. This can be very comfortable on systems
where a lot of users are using webmail with pgp however nor exchange keys
nor upload them on keyservers due to various reasons.
As well it fixes some behaviour lookup by setting the fingerprint as the
mailaddress if it haven't yet been set.

--- ./lib/Crypt/PGP.php-old     2007-11-18 20:31:33.000000000 +0100
+++ ./lib/Crypt/PGP.php 2007-11-18 21:00:10.000000000 +0100
@@ -163,6 +163,18 @@
         return $key_info;
     }
 
+       /**
+        * Retrieves the public key from the preference storage.
+        */
+    function _getPublicKeyFromPrefs($address)
+    {
+        global $conf;
+        $userprefs = &Prefs::singleton($conf['prefs']['driver'],'imp',
$address, '', null, false);
+        $userprefs->retrieve();
+        return $pk = $userprefs->getValue('pgp_public_key');
+    }
+
+
     /**
      * Retrieves a public key by e-mail.
      * First, the key will be attempted to be retrieved from a user's
@@ -178,10 +190,20 @@
      */
     function getPublicKey($address, $fingerprint = null)
     {
-        /* Try retrieving by e-mail only first. */
+       /* 1. try users database */
+        $prefs_key = $this->_getPublicKeyFromPrefs($address);
+        if(strlen($prefs_key) > 100 &&
+            preg_match('/-----BEGIN PGP ([^-]+)-----/', $prefs_key)){
+            return $prefs_key;
+        }
+
+        /* 2. try retrieving from Contacts */
         $result = $GLOBALS['registry']->call('contacts/getField',
array($address, IMP_PGP_PUBKEY_FIELD, $this->_sources, false, true));
 
         /* TODO: Retrieve by ID. */
+       if($fingerprint == null){
+            $fingerprint = $address;
+        }
 
         /* Try retrieving via a PGP public keyserver. */
         if (is_a($result, 'PEAR_Error') && !empty($fingerprint)) {





More information about the bugs mailing list