Copyright 2002-2014 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Автор: Michael Slusarz (slusarz@horde.org)
Пример #1
0
 protected function setUp()
 {
     $backends = $this->_setUp();
     @date_default_timezone_set('GMT');
     $this->_language = getenv('LANGUAGE');
     $this->_pgp = Horde_Crypt::factory('Pgp', array('backends' => $backends));
 }
Пример #2
0
 protected function setUp()
 {
     $c = self::getConfig('CRYPTPGP_TEST_CONFIG', __DIR__);
     $gnupg = isset($c['gnupg']) ? $c['gnupg'] : '/usr/bin/gpg';
     if (!is_executable($gnupg)) {
         $this->markTestSkipped(sprintf('GPG binary not found at %s.', $gnupg));
     }
     $this->_ks = new Horde_Crypt_Pgp_Keyserver(Horde_Crypt::factory('Pgp', array('program' => $gnupg)));
 }
Пример #3
0
 protected function setUp()
 {
     if (!is_executable('/usr/bin/gpg')) {
         $this->markTestSkipped('GPG binary not found at /usr/bin/gpg.');
     }
     @date_default_timezone_set('GMT');
     putenv('LANGUAGE=C');
     $this->_pgp = Horde_Crypt::factory('Pgp', array('program' => '/usr/bin/gpg', 'temp' => sys_get_temp_dir()));
     $this->_privkey = file_get_contents(__DIR__ . '/fixtures/pgp_private.asc');
     $this->_pubkey = file_get_contents(__DIR__ . '/fixtures/pgp_public.asc');
 }
Пример #4
0
 protected function setUp()
 {
     $config = self::getConfig('CRYPT_TEST_CONFIG');
     if (!$config || empty($config['crypt']['gnupg'])) {
         $this->markTestSkipped('Keyserver test has not been enabled.');
     }
     if (!is_executable($config['crypt']['gnupg'])) {
         $this->markTestSkipped('GPG binary not found.');
     }
     $this->_ks = new Horde_Crypt_Pgp_Keyserver(Horde_Crypt::factory('Pgp', array('program' => $config['crypt']['gnupg'], 'temp' => sys_get_temp_dir())));
 }
Пример #5
0
 public function testBrokenKeyserver()
 {
     $ks = new Horde_Crypt_Pgp_Keyserver(Horde_Crypt::factory('Pgp', array('program' => $this->_gnupg)), array('keyserver' => 'http://pgp.key-server.io'));
     try {
         $this->assertEquals('4DE5B969', $ks->getKeyID('*****@*****.**'));
     } catch (Horde_Crypt_Exception $e) {
         if ($e->getPrevious() instanceof Horde_Http_Exception) {
             $this->markTestSkipped($e->getMessage());
         } else {
             throw $e;
         }
     }
 }
Пример #6
0
 /**
  * Return the Horde_Crypt:: instance.
  *
  * @param string $driver  The driver name.
  * @param array $params   Any parameters needed by the driver.
  *
  * @return Horde_Crypt  The instance.
  * @throws Horde_Exception
  */
 public function create($driver, $params = array())
 {
     global $registry;
     $params = array_merge(array('email_charset' => $registry->getEmailCharset(), 'temp' => Horde::getTempDir()), $params);
     return Horde_Crypt::factory($driver, $params);
 }
Пример #7
0
 /**
  * Constructor.
  *
  * @param array $params  Configuration parameters:
  *   - backends: (array) The explicit list of backend drivers
  *               (Horde_Crypt_Pgp_Backend objects) to use.
  *   - program: (string) The path to the GnuPG binary.
  *   - temp: (string) Location of temporary directory.
  */
 public function __construct($params = array())
 {
     parent::__construct($params);
 }
Пример #8
0
 public function testSubjectAltName()
 {
     $smime = Horde_Crypt::factory('Smime', array('temp' => sys_get_temp_dir()));
     $key = file_get_contents(__DIR__ . '/fixtures/smime_subjectAltName.pem');
     $this->assertEquals('*****@*****.**', $smime->getEmailFromKey($key));
 }
Пример #9
0
 /**
  * Constructor.
  *
  * @param array $params  The following parameters:
  * <pre>
  * 'program' - (string) [REQUIRED] The path to the GnuPG binary.
  * 'proxy_host - (string) Proxy host. (@deprecated)
  * 'proxy_port - (integer) Proxy port. (@deprecated)
  * </pre>
  *
  * @throws InvalidArgumentException
  */
 public function __construct($params = array())
 {
     parent::__construct($params);
     if (empty($params['program'])) {
         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. */
     $this->_gnupg = array($params['program'], '--no-tty', '--no-secmem-warning', '--no-options', '--no-default-keyring', '--yes', '--homedir ' . $this->_tempdir);
     if (strncasecmp(PHP_OS, 'WIN', 3)) {
         array_unshift($this->_gnupg, 'LANG= ;');
     }
     $this->_params = $params;
 }