Abstract.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_InfoCard
  17. * @subpackage Zend_InfoCard_Xml
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Zend_InfoCard_Xml_Element
  24. */
  25. require_once 'Zend/InfoCard/Xml/Element.php';
  26. /**
  27. * Zend_InfoCard_Xml_KeyInfo
  28. */
  29. require_once 'Zend/InfoCard/Xml/KeyInfo.php';
  30. /**
  31. * An abstract class representing a generic EncryptedData XML block. This class is extended
  32. * into a specific type of EncryptedData XML block (i.e. XmlEnc) as necessary
  33. *
  34. * @category Zend
  35. * @package Zend_InfoCard
  36. * @subpackage Zend_InfoCard_Xml
  37. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. */
  40. abstract class Zend_InfoCard_Xml_EncryptedData_Abstract extends Zend_InfoCard_Xml_Element
  41. {
  42. /**
  43. * Returns the KeyInfo Block
  44. *
  45. * @return Zend_InfoCard_Xml_KeyInfo_Abstract
  46. */
  47. public function getKeyInfo()
  48. {
  49. return Zend_InfoCard_Xml_KeyInfo::getInstance($this->KeyInfo[0]);
  50. }
  51. /**
  52. * Return the Encryption method used to encrypt the assertion document
  53. * (the symmetric cipher)
  54. *
  55. * @throws Zend_InfoCard_Xml_Exception
  56. * @return string The URI of the Symmetric Encryption Method used
  57. */
  58. public function getEncryptionMethod()
  59. {
  60. /**
  61. * @todo This is pretty hacky unless we can always be confident that the first
  62. * EncryptionMethod block is the correct one (the AES or compariable symetric algorithm)..
  63. * the second is the PK method if provided.
  64. */
  65. list($encryption_method) = $this->xpath("//enc:EncryptionMethod");
  66. if(!($encryption_method instanceof Zend_InfoCard_Xml_Element)) {
  67. throw new Zend_InfoCard_Xml_Exception("Unable to find the enc:EncryptionMethod symmetric encryption block");
  68. }
  69. $dom = self::convertToDOM($encryption_method);
  70. if(!$dom->hasAttribute('Algorithm')) {
  71. throw new Zend_InfoCard_Xml_Exception("Unable to determine the encryption algorithm in the Symmetric enc:EncryptionMethod XML block");
  72. }
  73. return $dom->getAttribute('Algorithm');
  74. }
  75. /**
  76. * Returns the value of the encrypted block
  77. *
  78. * @return string the value of the encrypted CipherValue block
  79. */
  80. abstract function getCipherValue();
  81. }