diff options
author | Olav Morken <olav.morken@uninett.no> | 2010-04-21 12:56:08 +0000 |
---|---|---|
committer | Olav Morken <olav.morken@uninett.no> | 2010-04-21 12:56:08 +0000 |
commit | d970a850e835bd106bb3920d93bcb09f3a45756d (patch) | |
tree | ebb0e124ef0d34b08ab26e2decfe35fddce548cd /lib/SAML2/XML/ds/X509Data.php | |
parent | ce9c4077c5ea8898eb2480c7c251c27418bf9e53 (diff) | |
download | simplesamlphp-d970a850e835bd106bb3920d93bcb09f3a45756d.zip simplesamlphp-d970a850e835bd106bb3920d93bcb09f3a45756d.tar.gz simplesamlphp-d970a850e835bd106bb3920d93bcb09f3a45756d.tar.bz2 |
SAML2: Metadata XML classes.
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2261 44740490-163a-0410-bde0-09ae8108e29a
Diffstat (limited to 'lib/SAML2/XML/ds/X509Data.php')
-rw-r--r-- | lib/SAML2/XML/ds/X509Data.php | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/SAML2/XML/ds/X509Data.php b/lib/SAML2/XML/ds/X509Data.php new file mode 100644 index 0000000..e6b3c06 --- /dev/null +++ b/lib/SAML2/XML/ds/X509Data.php @@ -0,0 +1,74 @@ +<?php + +/** + * Class representing a ds:X509Data element. + * + * @package simpleSAMLphp + * @version $Id$ + */ +class SAML2_XML_ds_X509Data { + + /** + * The various X509 data elements. + * + * Array with various elements describing this certificate. + * Unknown elements will be represented by SAML2_XML_Chunk. + * + * @var array + */ + public $data = array(); + + + /** + * Initialize a X509Data. + * + * @param DOMElement|NULL $xml The XML element we should load. + */ + public function __construct(DOMElement $xml = NULL) { + + if ($xml === NULL) { + return; + } + + for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) { + if (!($n instanceof DOMElement)) { + continue; + } + + if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) { + $this->data[] = new SAML2_XML_Chunk($n); + continue; + } + switch ($n->localName) { + case 'X509Certificate': + $this->data[] = new SAML2_XML_ds_X509Certificate($n); + break; + default: + $this->data[] = new SAML2_XML_Chunk($n); + break; + } + } + } + + + /** + * Convert this X509Data element to XML. + * + * @param DOMElement $parent The element we should append this X509Data element to. + */ + public function toXML(DOMElement $parent) { + assert('is_array($this->data)'); + + $doc = $parent->ownerDocument; + + $e = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:X509Data'); + $parent->appendChild($e); + + foreach ($this->data as $n) { + $n->toXML($e); + } + + return $e; + } + +} |