ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Attribute.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\XML\saml;
4
7
14{
20 public $Name;
21
28
34 public $FriendlyName = null;
35
43 public $AttributeValue = array();
44
51 public function __construct(\DOMElement $xml = null)
52 {
53 if ($xml === null) {
54 return;
55 }
56
57 if (!$xml->hasAttribute('Name')) {
58 throw new \Exception('Missing Name on Attribute.');
59 }
60 $this->Name = $xml->getAttribute('Name');
61
62 if ($xml->hasAttribute('NameFormat')) {
63 $this->NameFormat = $xml->getAttribute('NameFormat');
64 }
65
66 if ($xml->hasAttribute('FriendlyName')) {
67 $this->FriendlyName = $xml->getAttribute('FriendlyName');
68 }
69
70 foreach (Utils::xpQuery($xml, './saml_assertion:AttributeValue') as $av) {
71 $this->AttributeValue[] = new AttributeValue($av);
72 }
73 }
74
84 protected function toXMLInternal(\DOMElement $parent, $namespace, $name)
85 {
86 assert(is_string($namespace));
87 assert(is_string($name));
88 assert(is_string($this->Name));
89 assert(is_null($this->NameFormat) || is_string($this->NameFormat));
90 assert(is_null($this->FriendlyName) || is_string($this->FriendlyName));
91 assert(is_array($this->AttributeValue));
92
93 $e = $parent->ownerDocument->createElementNS($namespace, $name);
94 $parent->appendChild($e);
95
96 $e->setAttribute('Name', $this->Name);
97
98 if (isset($this->NameFormat)) {
99 $e->setAttribute('NameFormat', $this->NameFormat);
100 }
101
102 if (isset($this->FriendlyName)) {
103 $e->setAttribute('FriendlyName', $this->FriendlyName);
104 }
105
106 foreach ($this->AttributeValue as $av) {
107 $av->toXML($e);
108 }
109
110 return $e;
111 }
112
119 public function toXML(\DOMElement $parent)
120 {
121 return $this->toXMLInternal($parent, Constants::NS_SAML, 'saml:Attribute');
122 }
123}
An exception for terminatinating execution or to throw for unit testing.
const NS_SAML
The namespace for the SAML 2 assertions.
Definition: Constants.php:220
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
Definition: Utils.php:191
toXML(\DOMElement $parent)
Convert this Attribute to XML.
Definition: Attribute.php:119
toXMLInternal(\DOMElement $parent, $namespace, $name)
Internal implementation of toXML.
Definition: Attribute.php:84
__construct(\DOMElement $xml=null)
Initialize an Attribute.
Definition: Attribute.php:51
if($err=$client->getError()) $namespace
if($format !==null) $name
Definition: metadata.php:146
$xml
Definition: metadata.php:240