factory() public static method

Attempts to return a concrete Horde_Crypt instance based on $driver.
public static factory ( string $driver, array $params = [] ) : Horde_Crypt
$driver string Either a driver name, or the full class name to use (class must extend Horde_Crypt).
$params array A hash containing any additional configuration or parameters a subclass might need.
return Horde_Crypt The newly created concrete instance.
Ejemplo n.º 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));
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 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');
 }
Ejemplo n.º 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())));
 }
Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 7
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));
 }