/** * 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_Element) { throw new Zend_InfoCard_Xml_Exception("Failed to retrieve encrypted key"); } return Zend_InfoCard_Xml_EncryptedKey::getInstance($encryptedkey); }
public function testEncryptedKeyErrors() { try { Zend_InfoCard_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 { Zend_InfoCard_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 = Zend_InfoCard_Xml_EncryptedKey::getInstance($doc); try { $ek->getEncryptionMethod(); $this->fail("Expected Exception not thrown"); } catch (Exception $e) { /* yay */ } }