コード例 #1
0
ファイル: XMLDSig.php プロジェクト: rexmac/zf2
 /**
  * Returns an instance of the EncryptedKey Data Block
  *
  * @throws \Zend\InfoCard\XML\Exception
  * @return \Zend\InfoCard\XML\EncryptedKey
  */
 public function getEncryptedKey()
 {
     $this->registerXPathNamespace('e', 'http://www.w3.org/2001/04/xmlenc#');
     list($encryptedkey) = $this->xpath('//e:EncryptedKey');
     if (!$encryptedkey instanceof \Zend\InfoCard\XML\AbstractElement) {
         throw new \Zend\InfoCard\XML\Exception\RuntimeException("Failed to retrieve encrypted key");
     }
     return \Zend\InfoCard\XML\EncryptedKey::getInstance($encryptedkey);
 }
コード例 #2
0
ファイル: XmlParsingTest.php プロジェクト: niallmccrudden/zf2
    public function testEncryptedKeyThrowsExceptionOnGetEncryptionMethodWithBadXml()
    {
        $doc = file_get_contents(__DIR__ . "/_files/encryptedkey_missing_enc_algo.xml");
        $ek = XML\EncryptedKey::getInstance($doc);

        $this->setExpectedException('Zend\InfoCard\XML\Exception\RuntimeException', 'Unable to determine the encryption algorithm in the');
        $ek->getEncryptionMethod();
    }
コード例 #3
0
ファイル: XmlParsingTest.php プロジェクト: stunti/zf2
 public function testEncryptedKeyErrors()
 {
     try {
         XML\EncryptedKey::getInstance(10);
         $this->fail("Expected Exception Not thrown");
     } catch (\Exception $e) {
         /* yay */
     }
     $doc = file_get_contents(dirname(__FILE__) . "/_files/encryptedkey_bad_block.xml");
     try {
         XML\EncryptedKey::getInstance($doc);
         $this->fail("Expected Exception not thrown");
     } catch (\Exception $e) {
         /* yay */
     }
     $doc = file_get_contents(dirname(__FILE__) . "/_files/encryptedkey_missing_enc_algo.xml");
     $ek = XML\EncryptedKey::getInstance($doc);
     try {
         $ek->getEncryptionMethod();
         $this->fail("Expected Exception not thrown");
     } catch (\Exception $e) {
         /* yay */
     }
 }