|
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: Assertion.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * Zend_InfoCard_Xml_Assertion_Interface |
|
25 */ |
|
26 require_once 'Zend/InfoCard/Xml/Assertion/Interface.php'; |
|
27 |
|
28 /** |
|
29 * Factory object to retrieve an Assertion object based on the type of XML document provided |
|
30 * |
|
31 * @category Zend |
|
32 * @package Zend_InfoCard |
|
33 * @subpackage Zend_InfoCard_Xml |
|
34 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
35 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
36 */ |
|
37 final class Zend_InfoCard_Xml_Assertion |
|
38 { |
|
39 /** |
|
40 * The namespace for a SAML-formatted Assertion document |
|
41 */ |
|
42 const TYPE_SAML = 'urn:oasis:names:tc:SAML:1.0:assertion'; |
|
43 |
|
44 /** |
|
45 * Constructor (disabled) |
|
46 * |
|
47 * @return void |
|
48 */ |
|
49 private function __construct() |
|
50 { |
|
51 } |
|
52 |
|
53 /** |
|
54 * Returns an instance of a InfoCard Assertion object based on the XML data provided |
|
55 * |
|
56 * @throws Zend_InfoCard_Xml_Exception |
|
57 * @param string $xmlData The XML-Formatted Assertion |
|
58 * @return Zend_InfoCard_Xml_Assertion_Interface |
|
59 * @throws Zend_InfoCard_Xml_Exception |
|
60 */ |
|
61 static public function getInstance($xmlData) |
|
62 { |
|
63 |
|
64 if($xmlData instanceof Zend_InfoCard_Xml_Element) { |
|
65 $strXmlData = $xmlData->asXML(); |
|
66 } else if (is_string($xmlData)) { |
|
67 $strXmlData = $xmlData; |
|
68 } else { |
|
69 require_once 'Zend/InfoCard/Xml/Exception.php'; |
|
70 throw new Zend_InfoCard_Xml_Exception("Invalid Data provided to create instance"); |
|
71 } |
|
72 |
|
73 $sxe = simplexml_load_string($strXmlData); |
|
74 |
|
75 $namespaces = $sxe->getDocNameSpaces(); |
|
76 |
|
77 foreach($namespaces as $namespace) { |
|
78 switch($namespace) { |
|
79 case self::TYPE_SAML: |
|
80 include_once 'Zend/InfoCard/Xml/Assertion/Saml.php'; |
|
81 return simplexml_load_string($strXmlData, 'Zend_InfoCard_Xml_Assertion_Saml', null); |
|
82 } |
|
83 } |
|
84 |
|
85 require_once 'Zend/InfoCard/Xml/Exception.php'; |
|
86 throw new Zend_InfoCard_Xml_Exception("Unable to determine Assertion type by Namespace"); |
|
87 } |
|
88 } |