~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/InfoCard/Xml/EncryptedData.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
20
 * @version    $Id: EncryptedData.php 9094 2008-03-30 18:36:55Z thomas $
 
21
 */
 
22
 
 
23
/**
 
24
 * Zend_InfoCard_Xml_EncryptedData
 
25
 */
 
26
require_once 'Zend/InfoCard/Xml/Exception.php';
 
27
 
 
28
/**
 
29
 * A factory class for producing Zend_InfoCard_Xml_EncryptedData objects based on
 
30
 * the type of XML document provided
 
31
 *
 
32
 * @category   Zend
 
33
 * @package    Zend_InfoCard
 
34
 * @subpackage Zend_InfoCard_Xml
 
35
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
36
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
37
 */
 
38
final class Zend_InfoCard_Xml_EncryptedData
 
39
{
 
40
    /**
 
41
     * Constructor (disabled)
 
42
     *
 
43
     * @return void
 
44
     */
 
45
    private function __construct()
 
46
    {
 
47
    }
 
48
 
 
49
    /**
 
50
     * Returns an instance of the class
 
51
     *
 
52
     * @param string $xmlData The XML EncryptedData String
 
53
     * @return Zend_InfoCard_Xml_EncryptedData_Abstract
 
54
     * @throws Zend_InfoCard_Xml_Exception
 
55
     */
 
56
    static public function getInstance($xmlData)
 
57
    {
 
58
 
 
59
        if($xmlData instanceof Zend_InfoCard_Xml_Element) {
 
60
            $strXmlData = $xmlData->asXML();
 
61
        } else if (is_string($xmlData)) {
 
62
            $strXmlData = $xmlData;
 
63
        } else {
 
64
            throw new Zend_InfoCard_Xml_Exception("Invalid Data provided to create instance");
 
65
        }
 
66
 
 
67
        $sxe = simplexml_load_string($strXmlData);
 
68
 
 
69
        switch($sxe['Type']) {
 
70
            case 'http://www.w3.org/2001/04/xmlenc#Element':
 
71
                include_once 'Zend/InfoCard/Xml/EncryptedData/XmlEnc.php';
 
72
                return simplexml_load_string($strXmlData, 'Zend_InfoCard_Xml_EncryptedData_XmlEnc');
 
73
            default:
 
74
                throw new Zend_InfoCard_Xml_Exception("Unknown EncryptedData type found");
 
75
        }
 
76
    }
 
77
}