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\AnyURIListValue; |
10
|
|
|
use SimpleSAML\SAML2\Type\SAMLAnyURIValue; |
11
|
|
|
use SimpleSAML\SAML2\Type\SAMLDateTimeValue; |
12
|
|
|
use SimpleSAML\XML\Constants as C; |
13
|
|
|
use SimpleSAML\XML\SchemaValidatableElementInterface; |
14
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
15
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
16
|
|
|
use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
17
|
|
|
use SimpleSAML\XMLSchema\Type\DurationValue; |
18
|
|
|
use SimpleSAML\XMLSchema\Type\IDValue; |
19
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Signature; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class representing SAML 2 metadata AuthnAuthorityDescriptor. |
23
|
|
|
* |
24
|
|
|
* @package simplesamlphp/saml2 |
25
|
|
|
*/ |
26
|
|
|
final class AuthnAuthorityDescriptor extends AbstractRoleDescriptorType implements SchemaValidatableElementInterface |
27
|
|
|
{ |
28
|
|
|
use SchemaValidatableElementTrait; |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* AuthnAuthorityDescriptor constructor. |
33
|
|
|
* |
34
|
|
|
* @param array $authnQueryService |
35
|
|
|
* @param \SimpleSAML\SAML2\Type\AnyURIListValue $protocolSupportEnumeration |
36
|
|
|
* @param array $assertionIDRequestService |
37
|
|
|
* @param array $nameIDFormat |
38
|
|
|
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID |
39
|
|
|
* @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil |
40
|
|
|
* @param \SimpleSAML\XMLSchema\Type\DurationValue|null $cacheDuration |
41
|
|
|
* @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions |
42
|
|
|
* @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $errorURL |
43
|
|
|
* @param \SimpleSAML\SAML2\XML\md\Organization|null $organization |
44
|
|
|
* @param array $keyDescriptor |
45
|
|
|
* @param array $contact |
46
|
|
|
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes |
|
|
|
|
47
|
|
|
*/ |
48
|
|
|
public function __construct( |
49
|
|
|
protected array $authnQueryService, |
50
|
|
|
AnyURIListValue $protocolSupportEnumeration, |
51
|
|
|
protected array $assertionIDRequestService = [], |
52
|
|
|
protected array $nameIDFormat = [], |
53
|
|
|
?IDValue $ID = null, |
54
|
|
|
?SAMLDateTimeValue $validUntil = null, |
55
|
|
|
?DurationValue $cacheDuration = null, |
56
|
|
|
?Extensions $extensions = null, |
57
|
|
|
?SAMLAnyURIValue $errorURL = null, |
58
|
|
|
?Organization $organization = null, |
59
|
|
|
array $keyDescriptor = [], |
60
|
|
|
array $contact = [], |
61
|
|
|
array $namespacedAttributes = [], |
62
|
|
|
) { |
63
|
|
|
Assert::maxCount($authnQueryService, C::UNBOUNDED_LIMIT); |
64
|
|
|
Assert::minCount($authnQueryService, 1, 'Missing at least one AuthnQueryService in AuthnAuthorityDescriptor.'); |
65
|
|
|
Assert::allIsInstanceOf( |
66
|
|
|
$authnQueryService, |
67
|
|
|
AbstractEndpointType::class, |
68
|
|
|
'AuthnQueryService must be an instance of EndpointType', |
69
|
|
|
); |
70
|
|
|
Assert::maxCount($assertionIDRequestService, C::UNBOUNDED_LIMIT); |
71
|
|
|
Assert::allIsInstanceOf( |
72
|
|
|
$assertionIDRequestService, |
73
|
|
|
AbstractEndpointType::class, |
74
|
|
|
'AssertionIDRequestServices must be an instance of EndpointType', |
75
|
|
|
); |
76
|
|
|
Assert::maxCount($nameIDFormat, C::UNBOUNDED_LIMIT); |
77
|
|
|
Assert::allIsInstanceOf($nameIDFormat, NameIDFormat::class); |
78
|
|
|
|
79
|
|
|
parent::__construct( |
80
|
|
|
$protocolSupportEnumeration, |
81
|
|
|
$ID, |
82
|
|
|
$validUntil, |
83
|
|
|
$cacheDuration, |
84
|
|
|
$extensions, |
85
|
|
|
$errorURL, |
86
|
|
|
$keyDescriptor, |
87
|
|
|
$organization, |
88
|
|
|
$contact, |
89
|
|
|
$namespacedAttributes, |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Collect the AuthnQueryService endpoints |
96
|
|
|
* |
97
|
|
|
* @return \SimpleSAML\SAML2\XML\md\AbstractEndpointType[] |
98
|
|
|
*/ |
99
|
|
|
public function getAuthnQueryService(): array |
100
|
|
|
{ |
101
|
|
|
return $this->authnQueryService; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Collect the AssertionIDRequestService endpoints |
107
|
|
|
* |
108
|
|
|
* @return \SimpleSAML\SAML2\XML\md\AbstractEndpointType[] |
109
|
|
|
*/ |
110
|
|
|
public function getAssertionIDRequestService(): array |
111
|
|
|
{ |
112
|
|
|
return $this->assertionIDRequestService; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Collect the values of the NameIDFormat |
118
|
|
|
* |
119
|
|
|
* @return \SimpleSAML\SAML2\XML\md\NameIDFormat[] |
120
|
|
|
*/ |
121
|
|
|
public function getNameIDFormat(): array |
122
|
|
|
{ |
123
|
|
|
return $this->nameIDFormat; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Initialize an IDPSSODescriptor from an existing XML document. |
129
|
|
|
* |
130
|
|
|
* @param \DOMElement $xml The XML element we should load. |
131
|
|
|
* @return static |
132
|
|
|
* |
133
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
134
|
|
|
* if the qualified name of the supplied element is wrong |
135
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
136
|
|
|
* if the supplied element is missing one of the mandatory attributes |
137
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\TooManyElementsException |
138
|
|
|
* if too many child-elements of a type are specified |
139
|
|
|
*/ |
140
|
|
|
public static function fromXML(DOMElement $xml): static |
141
|
|
|
{ |
142
|
|
|
Assert::same($xml->localName, 'AuthnAuthorityDescriptor', InvalidDOMElementException::class); |
143
|
|
|
Assert::same($xml->namespaceURI, AuthnAuthorityDescriptor::NS, InvalidDOMElementException::class); |
144
|
|
|
|
145
|
|
|
$authnQueryServices = AuthnQueryService::getChildrenOfClass($xml); |
146
|
|
|
$assertionIDRequestServices = AssertionIDRequestService::getChildrenOfClass($xml); |
147
|
|
|
$nameIDFormats = NameIDFormat::getChildrenOfClass($xml); |
148
|
|
|
|
149
|
|
|
$orgs = Organization::getChildrenOfClass($xml); |
150
|
|
|
Assert::maxCount( |
151
|
|
|
$orgs, |
152
|
|
|
1, |
153
|
|
|
'More than one Organization found in this descriptor', |
154
|
|
|
TooManyElementsException::class, |
155
|
|
|
); |
156
|
|
|
|
157
|
|
|
$extensions = Extensions::getChildrenOfClass($xml); |
158
|
|
|
Assert::maxCount( |
159
|
|
|
$extensions, |
160
|
|
|
1, |
161
|
|
|
'Only one md:Extensions element is allowed.', |
162
|
|
|
TooManyElementsException::class, |
163
|
|
|
); |
164
|
|
|
|
165
|
|
|
$signature = Signature::getChildrenOfClass($xml); |
166
|
|
|
Assert::maxCount( |
167
|
|
|
$signature, |
168
|
|
|
1, |
169
|
|
|
'Only one ds:Signature element is allowed.', |
170
|
|
|
TooManyElementsException::class, |
171
|
|
|
); |
172
|
|
|
|
173
|
|
|
$authority = new static( |
174
|
|
|
$authnQueryServices, |
175
|
|
|
self::getAttribute($xml, 'protocolSupportEnumeration', AnyURIListValue::class), |
176
|
|
|
$assertionIDRequestServices, |
177
|
|
|
$nameIDFormats, |
178
|
|
|
self::getOptionalAttribute($xml, 'ID', IDValue::class, null), |
179
|
|
|
self::getOptionalAttribute($xml, 'validUntil', SAMLDateTimeValue::class, null), |
180
|
|
|
self::getOptionalAttribute($xml, 'cacheDuration', DurationValue::class, null), |
181
|
|
|
!empty($extensions) ? $extensions[0] : null, |
182
|
|
|
self::getOptionalAttribute($xml, 'errorURL', SAMLAnyURIValue::class, null), |
183
|
|
|
!empty($orgs) ? $orgs[0] : null, |
184
|
|
|
KeyDescriptor::getChildrenOfClass($xml), |
185
|
|
|
ContactPerson::getChildrenOfClass($xml), |
186
|
|
|
self::getAttributesNSFromXML($xml), |
187
|
|
|
); |
188
|
|
|
|
189
|
|
|
if (!empty($signature)) { |
190
|
|
|
$authority->setSignature($signature[0]); |
191
|
|
|
$authority->setXML($xml); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
return $authority; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Add this IDPSSODescriptor to an EntityDescriptor. |
200
|
|
|
* |
201
|
|
|
* @param \DOMElement|null $parent The EntityDescriptor we should append this AuthnAuthorityDescriptor to. |
202
|
|
|
* |
203
|
|
|
* @return \DOMElement |
204
|
|
|
* @throws \Exception |
205
|
|
|
*/ |
206
|
|
|
public function toUnsignedXML(?DOMElement $parent = null): DOMElement |
207
|
|
|
{ |
208
|
|
|
$e = parent::toUnsignedXML($parent); |
209
|
|
|
|
210
|
|
|
foreach ($this->getAuthnQueryService() as $ep) { |
211
|
|
|
$ep->toXML($e); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
foreach ($this->getAssertionIDRequestService() as $ep) { |
215
|
|
|
$ep->toXML($e); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
foreach ($this->getNameIDFormat() as $nidFormat) { |
219
|
|
|
$nidFormat->toXML($e); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
return $e; |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths