|
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-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * Zend_InfoCard_Xml_Element |
|
25 */ |
|
26 require_once 'Zend/InfoCard/Xml/Element.php'; |
|
27 |
|
28 /** |
|
29 * Zend_InfoCard_Xml_KeyInfo |
|
30 */ |
|
31 require_once 'Zend/InfoCard/Xml/KeyInfo.php'; |
|
32 |
|
33 /** |
|
34 * An abstract class representing a generic EncryptedData XML block. This class is extended |
|
35 * into a specific type of EncryptedData XML block (i.e. XmlEnc) as necessary |
|
36 * |
|
37 * @category Zend |
|
38 * @package Zend_InfoCard |
|
39 * @subpackage Zend_InfoCard_Xml |
|
40 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
41 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
42 */ |
|
43 abstract class Zend_InfoCard_Xml_EncryptedData_Abstract extends Zend_InfoCard_Xml_Element |
|
44 { |
|
45 |
|
46 /** |
|
47 * Returns the KeyInfo Block |
|
48 * |
|
49 * @return Zend_InfoCard_Xml_KeyInfo_Abstract |
|
50 */ |
|
51 public function getKeyInfo() |
|
52 { |
|
53 return Zend_InfoCard_Xml_KeyInfo::getInstance($this->KeyInfo[0]); |
|
54 } |
|
55 |
|
56 /** |
|
57 * Return the Encryption method used to encrypt the assertion document |
|
58 * (the symmetric cipher) |
|
59 * |
|
60 * @throws Zend_InfoCard_Xml_Exception |
|
61 * @return string The URI of the Symmetric Encryption Method used |
|
62 */ |
|
63 public function getEncryptionMethod() |
|
64 { |
|
65 |
|
66 /** |
|
67 * @todo This is pretty hacky unless we can always be confident that the first |
|
68 * EncryptionMethod block is the correct one (the AES or compariable symetric algorithm).. |
|
69 * the second is the PK method if provided. |
|
70 */ |
|
71 list($encryption_method) = $this->xpath("//enc:EncryptionMethod"); |
|
72 |
|
73 if(!($encryption_method instanceof Zend_InfoCard_Xml_Element)) { |
|
74 throw new Zend_InfoCard_Xml_Exception("Unable to find the enc:EncryptionMethod symmetric encryption block"); |
|
75 } |
|
76 |
|
77 $dom = self::convertToDOM($encryption_method); |
|
78 |
|
79 if(!$dom->hasAttribute('Algorithm')) { |
|
80 throw new Zend_InfoCard_Xml_Exception("Unable to determine the encryption algorithm in the Symmetric enc:EncryptionMethod XML block"); |
|
81 } |
|
82 |
|
83 return $dom->getAttribute('Algorithm'); |
|
84 } |
|
85 |
|
86 /** |
|
87 * Returns the value of the encrypted block |
|
88 * |
|
89 * @return string the value of the encrypted CipherValue block |
|
90 */ |
|
91 abstract function getCipherValue(); |
|
92 } |