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