1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\WSSecurity\XML\fed; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\WSSecurity\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
10
|
|
|
use SimpleSAML\XML\Exception\SchemaViolationException; |
11
|
|
|
use SimpleSAML\XML\ExtendableAttributesTrait; |
12
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class defining the IssuerNameType element |
16
|
|
|
* |
17
|
|
|
* @package simplesamlphp/ws-security |
18
|
|
|
*/ |
19
|
|
|
abstract class AbstractIssuerNameType extends AbstractFedElement |
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
|
|
|
* AbstractIssuerNameType constructor |
29
|
|
|
* |
30
|
|
|
* @param string $Uri |
31
|
|
|
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes |
32
|
|
|
*/ |
33
|
|
|
final public function __construct( |
34
|
|
|
protected string $Uri, |
35
|
|
|
array $namespacedAttributes = [], |
36
|
|
|
) { |
37
|
|
|
Assert::validURI($Uri, SchemaViolationException::class); |
38
|
|
|
|
39
|
|
|
$this->setAttributesNS($namespacedAttributes); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
|
|
public function getUri(): string |
47
|
|
|
{ |
48
|
|
|
return $this->Uri; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Create an instance of this object from its XML representation. |
54
|
|
|
* |
55
|
|
|
* @param \DOMElement $xml |
56
|
|
|
* @return static |
57
|
|
|
* |
58
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
59
|
|
|
* if the qualified name of the supplied element is wrong |
60
|
|
|
*/ |
61
|
|
|
public static function fromXML(DOMElement $xml): static |
62
|
|
|
{ |
63
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
64
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
65
|
|
|
|
66
|
|
|
return new static( |
67
|
|
|
self::getAttribute($xml, 'Uri'), |
68
|
|
|
self::getAttributesNSFromXML($xml), |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Add this IssuerNameType to an XML element. |
75
|
|
|
* |
76
|
|
|
* @param \DOMElement|null $parent The element we should append this issuer name to. |
77
|
|
|
* @return \DOMElement |
78
|
|
|
*/ |
79
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
80
|
|
|
{ |
81
|
|
|
$e = parent::instantiateParentElement($parent); |
82
|
|
|
$e->setAttribute('Uri', $this->getUri()); |
83
|
|
|
|
84
|
|
|
foreach ($this->getAttributesNS() as $attr) { |
85
|
|
|
$attr->toXML($e); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return $e; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|