diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/InfoCard/Xml/EncryptedData/Abstract.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/InfoCard/Xml/EncryptedData/Abstract.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,92 @@ +KeyInfo[0]); + } + + /** + * Return the Encryption method used to encrypt the assertion document + * (the symmetric cipher) + * + * @throws Zend_InfoCard_Xml_Exception + * @return string The URI of the Symmetric Encryption Method used + */ + public function getEncryptionMethod() + { + + /** + * @todo This is pretty hacky unless we can always be confident that the first + * EncryptionMethod block is the correct one (the AES or compariable symetric algorithm).. + * the second is the PK method if provided. + */ + list($encryption_method) = $this->xpath("//enc:EncryptionMethod"); + + if(!($encryption_method instanceof Zend_InfoCard_Xml_Element)) { + throw new Zend_InfoCard_Xml_Exception("Unable to find the enc:EncryptionMethod symmetric encryption block"); + } + + $dom = self::convertToDOM($encryption_method); + + if(!$dom->hasAttribute('Algorithm')) { + throw new Zend_InfoCard_Xml_Exception("Unable to determine the encryption algorithm in the Symmetric enc:EncryptionMethod XML block"); + } + + return $dom->getAttribute('Algorithm'); + } + + /** + * Returns the value of the encrypted block + * + * @return string the value of the encrypted CipherValue block + */ + abstract function getCipherValue(); +}