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