1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\wsa_200408; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Chunk; |
10
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
11
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
12
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class representing a wsa:ReferenceProperties element. |
16
|
|
|
* |
17
|
|
|
* @package simplesamlphp/ws-security |
18
|
|
|
*/ |
19
|
|
|
final class ReferenceProperties extends AbstractWsaElement |
20
|
|
|
{ |
21
|
|
|
use ExtendableElementTrait; |
22
|
|
|
|
23
|
|
|
/** The namespace-attribute for the xs:any element */ |
24
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::ANY; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Initialize a wsa:ReferenceProperties |
29
|
|
|
* |
30
|
|
|
* @param \SimpleSAML\XML\Chunk[] $children |
31
|
|
|
*/ |
32
|
|
|
public function __construct(array $children = []) |
33
|
|
|
{ |
34
|
|
|
$this->setElements($children); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
40
|
|
|
* |
41
|
|
|
* @return bool |
42
|
|
|
*/ |
43
|
|
|
public function isEmptyElement(): bool |
44
|
|
|
{ |
45
|
|
|
return empty($this->elements); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/* |
50
|
|
|
* Convert XML into an ReferenceProperties element |
51
|
|
|
* |
52
|
|
|
* @param \DOMElement $xml The XML element we should load |
53
|
|
|
* @return static |
54
|
|
|
* |
55
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
56
|
|
|
* If the qualified name of the supplied element is wrong |
57
|
|
|
*/ |
58
|
|
|
public static function fromXML(DOMElement $xml): static |
59
|
|
|
{ |
60
|
|
|
Assert::same($xml->localName, 'ReferenceProperties', InvalidDOMElementException::class); |
61
|
|
|
Assert::same($xml->namespaceURI, ReferenceProperties::NS, InvalidDOMElementException::class); |
62
|
|
|
|
63
|
|
|
$children = []; |
64
|
|
|
foreach ($xml->childNodes as $child) { |
65
|
|
|
if (!($child instanceof DOMElement)) { |
66
|
|
|
continue; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$children[] = new Chunk($child); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return new static($children); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Convert this ReferenceProperties to XML. |
78
|
|
|
* |
79
|
|
|
* @param \DOMElement|null $parent The element we should add this ReferenceProperties to. |
80
|
|
|
* @return \DOMElement This Header-element. |
81
|
|
|
*/ |
82
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
83
|
|
|
{ |
84
|
|
|
$e = $this->instantiateParentElement($parent); |
85
|
|
|
|
86
|
|
|
/** @psalm-var \SimpleSAML\XML\SerializableElementInterface $child */ |
87
|
|
|
foreach ($this->getElements() as $child) { |
88
|
|
|
if (!$child->isEmptyElement()) { |
89
|
|
|
$child->toXML($e); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
return $e; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|