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