1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML11\XML\saml; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\SAML11\Assert\Assert; |
9
|
|
|
use SimpleSAML\SAML11\Type\SAMLAnyURIValue; |
10
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
11
|
|
|
use SimpleSAML\XMLSchema\Type\QNameValue; |
12
|
|
|
|
13
|
|
|
use function strval; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* SAML AuthorityBindingType abstract data type. |
17
|
|
|
* |
18
|
|
|
* @package simplesamlphp/saml11 |
19
|
|
|
*/ |
20
|
|
|
abstract class AbstractAuthorityBindingType extends AbstractSamlElement |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Initialize a saml:AuthorityBindingType from scratch |
24
|
|
|
* |
25
|
|
|
* @param \SimpleSAML\XMLSchema\Type\QNameValue $AuthorityKind |
26
|
|
|
* @param \SimpleSAML\SAML11\Type\SAMLAnyURIValue $Location |
27
|
|
|
* @param \SimpleSAML\SAML11\Type\SAMLAnyURIValue $Binding |
28
|
|
|
*/ |
29
|
|
|
final public function __construct( |
30
|
|
|
protected QNameValue $AuthorityKind, |
31
|
|
|
protected SAMLAnyURIValue $Location, |
32
|
|
|
protected SAMLAnyURIValue $Binding, |
33
|
|
|
) { |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Collect the value of the AuthorityKind-property |
39
|
|
|
* |
40
|
|
|
* @return \SimpleSAML\XMLSchema\Type\QNameValue |
41
|
|
|
*/ |
42
|
|
|
public function getAuthorityKind(): QNameValue |
43
|
|
|
{ |
44
|
|
|
return $this->AuthorityKind; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Collect the value of the Location-property |
50
|
|
|
* |
51
|
|
|
* @return \SimpleSAML\SAML11\Type\SAMLAnyURIValue |
52
|
|
|
*/ |
53
|
|
|
public function getLocation(): SAMLAnyURIValue |
54
|
|
|
{ |
55
|
|
|
return $this->Location; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Collect the value of the Binding-property |
61
|
|
|
* |
62
|
|
|
* @return \SimpleSAML\SAML11\Type\SAMLAnyURIValue |
63
|
|
|
*/ |
64
|
|
|
public function getBinding(): SAMLAnyURIValue |
65
|
|
|
{ |
66
|
|
|
return $this->Binding; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Convert XML into an AuthorityBindingType |
72
|
|
|
* |
73
|
|
|
* @param \DOMElement $xml The XML element we should load |
74
|
|
|
* @return static |
75
|
|
|
* |
76
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
77
|
|
|
* if the qualified name of the supplied element is wrong |
78
|
|
|
*/ |
79
|
|
|
public static function fromXML(DOMElement $xml): static |
80
|
|
|
{ |
81
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
82
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
83
|
|
|
|
84
|
|
|
$AuthorityKind = self::getAttribute($xml, 'AuthorityKind', QNameValue::class); |
85
|
|
|
$Location = self::getAttribute($xml, 'Location', SAMLAnyURIValue::class); |
86
|
|
|
$Binding = self::getAttribute($xml, 'Binding', SAMLAnyURIValue::class); |
87
|
|
|
|
88
|
|
|
return new static($AuthorityKind, $Location, $Binding); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Convert this AuthorityBindingType to XML. |
94
|
|
|
* |
95
|
|
|
* @param \DOMElement $parent The element we are converting to XML. |
96
|
|
|
* @return \DOMElement The XML element after adding the data corresponding to this AuthorityBindingType. |
97
|
|
|
*/ |
98
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
99
|
|
|
{ |
100
|
|
|
$e = $this->instantiateParentElement($parent); |
101
|
|
|
|
102
|
|
|
if (!$e->lookupPrefix($this->getAuthorityKind()->getNamespaceURI()->getValue())) { |
103
|
|
|
$e->setAttributeNS( |
104
|
|
|
'http://www.w3.org/2000/xmlns/', |
105
|
|
|
'xmlns:' . $this->getAuthorityKind()->getNamespacePrefix()->getValue(), |
106
|
|
|
$this->getAuthorityKind()->getNamespaceURI()->getValue(), |
107
|
|
|
); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
$e->setAttribute('AuthorityKind', strval($this->getAuthorityKind())); |
111
|
|
|
$e->setAttribute('Location', strval($this->getLocation())); |
112
|
|
|
$e->setAttribute('Binding', strval($this->getBinding())); |
113
|
|
|
|
114
|
|
|
return $e; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|