1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\wsx; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\WSSecurity\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
10
|
|
|
use SimpleSAML\XML\Exception\MissingElementException; |
11
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
12
|
|
|
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait}; |
13
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class defining the MetadataReference element |
17
|
|
|
* |
18
|
|
|
* @package simplesamlphp/ws-security |
19
|
|
|
*/ |
20
|
|
|
final class MetadataReference extends AbstractWsxElement implements SchemaValidatableElementInterface |
21
|
|
|
{ |
22
|
|
|
use ExtendableElementTrait; |
|
|
|
|
23
|
|
|
use SchemaValidatableElementTrait; |
|
|
|
|
24
|
|
|
|
25
|
|
|
/** The namespace-attribute for the xs:any element */ |
26
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::OTHER; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* MetadataReference constructor |
31
|
|
|
* |
32
|
|
|
* @param \SimpleSAML\XML\SerializableElementInterface[] $children |
33
|
|
|
*/ |
34
|
|
|
final public function __construct( |
35
|
|
|
array $children = [], |
36
|
|
|
) { |
37
|
|
|
Assert::minCount($children, 1, MissingElementException::class); |
38
|
|
|
$this->setElements($children); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Create an instance of this object from its XML representation. |
44
|
|
|
* |
45
|
|
|
* @param \DOMElement $xml |
46
|
|
|
* @return static |
47
|
|
|
* |
48
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
49
|
|
|
* if the qualified name of the supplied element is wrong |
50
|
|
|
*/ |
51
|
|
|
public static function fromXML(DOMElement $xml): static |
52
|
|
|
{ |
53
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
54
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
55
|
|
|
|
56
|
|
|
return new static( |
57
|
|
|
self::getChildElementsFromXML($xml), |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Add this MetadataReference to an XML element. |
64
|
|
|
* |
65
|
|
|
* @param \DOMElement|null $parent The element we should append this MetadataReference to. |
66
|
|
|
* @return \DOMElement |
67
|
|
|
*/ |
68
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
69
|
|
|
{ |
70
|
|
|
$e = parent::instantiateParentElement($parent); |
71
|
|
|
|
72
|
|
|
foreach ($this->getElements() as $child) { |
73
|
|
|
if (!$child->isEmptyElement()) { |
74
|
|
|
$child->toXML($e); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return $e; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|