ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
KeyInfo.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\XML\ds;
4
7
14{
20 public $Id = null;
21
30 public $info = array();
31
37 public function __construct(\DOMElement $xml = null)
38 {
39 if ($xml === null) {
40 return;
41 }
42
43 if ($xml->hasAttribute('Id')) {
44 $this->Id = $xml->getAttribute('Id');
45 }
46
47 for ($n = $xml->firstChild; $n !== null; $n = $n->nextSibling) {
48 if (!($n instanceof \DOMElement)) {
49 continue;
50 }
51
52 if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) {
53 $this->info[] = new Chunk($n);
54 continue;
55 }
56 switch ($n->localName) {
57 case 'KeyName':
58 $this->info[] = new KeyName($n);
59 break;
60 case 'X509Data':
61 $this->info[] = new X509Data($n);
62 break;
63 default:
64 $this->info[] = new Chunk($n);
65 break;
66 }
67 }
68 }
69
76 public function toXML(\DOMElement $parent)
77 {
78 assert(is_null($this->Id) || is_string($this->Id));
79 assert(is_array($this->info));
80
81 $doc = $parent->ownerDocument;
82
83 $e = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:KeyInfo');
84 $parent->appendChild($e);
85
86 if (isset($this->Id)) {
87 $e->setAttribute('Id', $this->Id);
88 }
89
91 foreach ($this->info as $n) {
92 $n->toXML($e);
93 }
94
95 return $e;
96 }
97}
$n
Definition: RandomTest.php:85
An exception for terminatinating execution or to throw for unit testing.
__construct(\DOMElement $xml=null)
Initialize a KeyInfo element.
Definition: KeyInfo.php:37
info()
Definition: info.php:2