1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\XML\md; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\SAML2\Assert\Assert; |
9
|
|
|
use SimpleSAML\SAML2\Type\SAMLAnyURIValue; |
10
|
|
|
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait}; |
11
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class representing SAML 2 metadata AdditionalMetadataLocation element. |
15
|
|
|
* |
16
|
|
|
* @package simplesamlphp/saml2 |
17
|
|
|
*/ |
18
|
|
|
final class AdditionalMetadataLocation extends AbstractMdElement implements SchemaValidatableElementInterface |
19
|
|
|
{ |
20
|
|
|
use SchemaValidatableElementTrait; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Create a new instance of AdditionalMetadataLocation |
25
|
|
|
* |
26
|
|
|
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $namespace |
27
|
|
|
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $location |
28
|
|
|
*/ |
29
|
|
|
public function __construct( |
30
|
|
|
protected SAMLAnyURIValue $namespace, |
31
|
|
|
protected SAMLAnyURIValue $location, |
32
|
|
|
) { |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Collect the value of the namespace-property |
38
|
|
|
* |
39
|
|
|
* @return \SimpleSAML\SAML2\Type\SAMLAnyURIValue |
40
|
|
|
*/ |
41
|
|
|
public function getNamespace(): SAMLAnyURIValue |
42
|
|
|
{ |
43
|
|
|
return $this->namespace; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Collect the value of the location-property |
49
|
|
|
* |
50
|
|
|
* @return \SimpleSAML\SAML2\Type\SAMLAnyURIValue |
51
|
|
|
*/ |
52
|
|
|
public function getLocation(): SAMLAnyURIValue |
53
|
|
|
{ |
54
|
|
|
return $this->location; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Initialize an AdditionalMetadataLocation element. |
60
|
|
|
* |
61
|
|
|
* @param \DOMElement $xml The XML element we should load. |
62
|
|
|
* @return static |
63
|
|
|
* |
64
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
65
|
|
|
* if the qualified name of the supplied element is wrong |
66
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
67
|
|
|
* if the supplied element is missing any of the mandatory attributes |
68
|
|
|
*/ |
69
|
|
|
public static function fromXML(DOMElement $xml): static |
70
|
|
|
{ |
71
|
|
|
Assert::same($xml->localName, 'AdditionalMetadataLocation', InvalidDOMElementException::class); |
72
|
|
|
Assert::same($xml->namespaceURI, AdditionalMetadataLocation::NS, InvalidDOMElementException::class); |
73
|
|
|
|
74
|
|
|
return new static( |
75
|
|
|
self::getAttribute($xml, 'namespace', SAMLAnyURIValue::class), |
76
|
|
|
SAMLAnyURIValue::fromString($xml->textContent), |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Convert this AdditionalMetadataLocation to XML. |
83
|
|
|
* |
84
|
|
|
* @param \DOMElement|null $parent The element we should append to. |
85
|
|
|
* @return \DOMElement This AdditionalMetadataLocation-element. |
86
|
|
|
*/ |
87
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
88
|
|
|
{ |
89
|
|
|
$e = $this->instantiateParentElement($parent); |
90
|
|
|
$e->textContent = $this->getLocation()->getValue(); |
91
|
|
|
$e->setAttribute('namespace', $this->getNamespace()->getValue()); |
92
|
|
|
|
93
|
|
|
return $e; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|