1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\wsaw; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Attribute as XMLAttribute; |
10
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
11
|
|
|
use SimpleSAML\XML\ExtendableAttributesTrait; |
12
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class defining the UsingAddressing element |
16
|
|
|
* |
17
|
|
|
* @package simplesamlphp/ws-security |
18
|
|
|
*/ |
19
|
|
|
final class UsingAddressing extends AbstractWsawElement |
20
|
|
|
{ |
21
|
|
|
use ExtendableAttributesTrait; |
22
|
|
|
|
23
|
|
|
/** The namespace-attribute for the xs:anyAttribute element */ |
24
|
|
|
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* UsingAddressing constructor |
29
|
|
|
* |
30
|
|
|
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes |
31
|
|
|
*/ |
32
|
|
|
final public function __construct( |
33
|
|
|
array $namespacedAttributes = [], |
34
|
|
|
) { |
35
|
|
|
$this->setAttributesNS($namespacedAttributes); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Create an instance of this object from its XML representation. |
41
|
|
|
* |
42
|
|
|
* @param \DOMElement $xml |
43
|
|
|
* @return static |
44
|
|
|
* |
45
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
46
|
|
|
* if the qualified name of the supplied element is wrong |
47
|
|
|
*/ |
48
|
|
|
public static function fromXML(DOMElement $xml): static |
49
|
|
|
{ |
50
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
51
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
52
|
|
|
|
53
|
|
|
return new static(self::getAttributesNSFromXML($xml)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Convert this UsingAddressing to XML. |
59
|
|
|
* |
60
|
|
|
* @param \DOMElement|null $parent The element we should append this class to. |
61
|
|
|
* @return \DOMElement The XML element after adding the data corresponding to this UsingAddressing. |
62
|
|
|
*/ |
63
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
64
|
|
|
{ |
65
|
|
|
$e = $this->instantiateParentElement($parent); |
66
|
|
|
|
67
|
|
|
foreach ($this->getAttributesNS() as $attr) { |
68
|
|
|
$attr->toXML($e); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return $e; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|