|
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\Constants as C; |
|
10
|
|
|
use SimpleSAML\SAML2\Type\EntityIDValue; |
|
11
|
|
|
use SimpleSAML\SAML2\Type\SAMLDateTimeValue; |
|
12
|
|
|
use SimpleSAML\XML\ExtendableAttributesTrait; |
|
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\XMLSchema\XML\Constants\NS; |
|
20
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Signature; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class representing SAML 2 AffiliationDescriptor element. |
|
24
|
|
|
* |
|
25
|
|
|
* @package simplesamlphp/saml2 |
|
26
|
|
|
*/ |
|
27
|
|
|
final class AffiliationDescriptor extends AbstractMetadataDocument implements SchemaValidatableElementInterface |
|
28
|
|
|
{ |
|
29
|
|
|
use ExtendableAttributesTrait; |
|
30
|
|
|
use SchemaValidatableElementTrait; |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
/** The namespace-attribute for the xs:anyAttribute element */ |
|
34
|
|
|
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Generic constructor for SAML metadata documents. |
|
39
|
|
|
* |
|
40
|
|
|
* @param \SimpleSAML\SAML2\Type\EntityIDValue $affiliationOwnerId The ID of the owner of this affiliation. |
|
41
|
|
|
* @param \SimpleSAML\SAML2\XML\md\AffiliateMember[] $affiliateMember |
|
42
|
|
|
* A non-empty array of members of this affiliation. |
|
43
|
|
|
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID The ID for this document. Defaults to null. |
|
44
|
|
|
* @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil Unix time of validity for this document. |
|
45
|
|
|
* Defaults to null. |
|
46
|
|
|
* @param \SimpleSAML\XMLSchema\Type\DurationValue|null $cacheDuration Maximum time this document can be cached. |
|
47
|
|
|
* Defaults to null. |
|
48
|
|
|
* @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions An array of extensions. Defaults to an empty array. |
|
49
|
|
|
* @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptor |
|
50
|
|
|
* An optional array of KeyDescriptors. Defaults to an empty array. |
|
51
|
|
|
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttribute |
|
|
|
|
|
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct( |
|
54
|
|
|
protected EntityIDValue $affiliationOwnerId, |
|
55
|
|
|
protected array $affiliateMember, |
|
56
|
|
|
?IDValue $ID = null, |
|
57
|
|
|
?SAMLDateTimeValue $validUntil = null, |
|
58
|
|
|
?DurationValue $cacheDuration = null, |
|
59
|
|
|
?Extensions $extensions = null, |
|
60
|
|
|
protected array $keyDescriptor = [], |
|
61
|
|
|
array $namespacedAttribute = [], |
|
62
|
|
|
) { |
|
63
|
|
|
Assert::notEmpty($affiliateMember, 'List of affiliated members must not be empty.'); |
|
64
|
|
|
Assert::maxCount($affiliateMember, C::UNBOUNDED_LIMIT); |
|
65
|
|
|
Assert::allIsInstanceOf($affiliateMember, AffiliateMember::class); |
|
66
|
|
|
Assert::maxCount($keyDescriptor, C::UNBOUNDED_LIMIT); |
|
67
|
|
|
Assert::allIsInstanceOf($keyDescriptor, KeyDescriptor::class); |
|
68
|
|
|
|
|
69
|
|
|
parent::__construct($ID, $validUntil, $cacheDuration, $extensions); |
|
70
|
|
|
|
|
71
|
|
|
$this->setAttributesNS($namespacedAttribute); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Collect the value of the affiliationOwnerId-property |
|
77
|
|
|
* |
|
78
|
|
|
* @return \SimpleSAML\SAML2\Type\EntityIDValue |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getAffiliationOwnerId(): EntityIDValue |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->affiliationOwnerId; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Collect the value of the AffiliateMember-property |
|
88
|
|
|
* |
|
89
|
|
|
* @return \SimpleSAML\SAML2\XML\md\AffiliateMember[] |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getAffiliateMember(): array |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->affiliateMember; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Collect the value of the KeyDescriptor-property |
|
99
|
|
|
* |
|
100
|
|
|
* @return \SimpleSAML\SAML2\XML\md\KeyDescriptor[] |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getKeyDescriptor(): array |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->keyDescriptor; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Initialize a AffiliationDescriptor. |
|
110
|
|
|
* |
|
111
|
|
|
* @param \DOMElement $xml The XML element we should load. |
|
112
|
|
|
* @return static |
|
113
|
|
|
* |
|
114
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
|
115
|
|
|
* if the qualified name of the supplied element is wrong |
|
116
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
|
117
|
|
|
* if the supplied element is missing one of the mandatory attributes |
|
118
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\TooManyElementsException |
|
119
|
|
|
* if too many child-elements of a type are specified |
|
120
|
|
|
*/ |
|
121
|
|
|
public static function fromXML(DOMElement $xml): static |
|
122
|
|
|
{ |
|
123
|
|
|
Assert::same($xml->localName, 'AffiliationDescriptor', InvalidDOMElementException::class); |
|
124
|
|
|
Assert::same($xml->namespaceURI, AffiliationDescriptor::NS, InvalidDOMElementException::class); |
|
125
|
|
|
|
|
126
|
|
|
$owner = self::getAttribute($xml, 'affiliationOwnerID', EntityIDValue::class); |
|
127
|
|
|
$members = AffiliateMember::getChildrenOfClass($xml); |
|
128
|
|
|
$keyDescriptors = KeyDescriptor::getChildrenOfClass($xml); |
|
129
|
|
|
|
|
130
|
|
|
$orgs = Organization::getChildrenOfClass($xml); |
|
131
|
|
|
Assert::maxCount( |
|
132
|
|
|
$orgs, |
|
133
|
|
|
1, |
|
134
|
|
|
'More than one Organization found in this descriptor', |
|
135
|
|
|
TooManyElementsException::class, |
|
136
|
|
|
); |
|
137
|
|
|
|
|
138
|
|
|
$extensions = Extensions::getChildrenOfClass($xml); |
|
139
|
|
|
Assert::maxCount( |
|
140
|
|
|
$extensions, |
|
141
|
|
|
1, |
|
142
|
|
|
'Only one md:Extensions element is allowed.', |
|
143
|
|
|
TooManyElementsException::class, |
|
144
|
|
|
); |
|
145
|
|
|
|
|
146
|
|
|
$signature = Signature::getChildrenOfClass($xml); |
|
147
|
|
|
Assert::maxCount( |
|
148
|
|
|
$signature, |
|
149
|
|
|
1, |
|
150
|
|
|
'Only one ds:Signature element is allowed.', |
|
151
|
|
|
TooManyElementsException::class, |
|
152
|
|
|
); |
|
153
|
|
|
|
|
154
|
|
|
$afd = new static( |
|
155
|
|
|
$owner, |
|
156
|
|
|
$members, |
|
157
|
|
|
self::getOptionalAttribute($xml, 'ID', IDValue::class, null), |
|
158
|
|
|
self::getOptionalAttribute($xml, 'validUntil', SAMLDateTimeValue::class, null), |
|
159
|
|
|
self::getOptionalAttribute($xml, 'cacheDuration', DurationValue::class, null), |
|
160
|
|
|
!empty($extensions) ? $extensions[0] : null, |
|
161
|
|
|
$keyDescriptors, |
|
162
|
|
|
self::getAttributesNSFromXML($xml), |
|
163
|
|
|
); |
|
164
|
|
|
|
|
165
|
|
|
if (!empty($signature)) { |
|
166
|
|
|
$afd->setSignature($signature[0]); |
|
167
|
|
|
$afd->setXML($xml); |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
return $afd; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* Convert this assertion to an unsigned XML document. |
|
176
|
|
|
* This method does not sign the resulting XML document. |
|
177
|
|
|
* |
|
178
|
|
|
* @return \DOMElement The root element of the DOM tree |
|
179
|
|
|
*/ |
|
180
|
|
|
public function toUnsignedXML(?DOMElement $parent = null): DOMElement |
|
181
|
|
|
{ |
|
182
|
|
|
$e = parent::toUnsignedXML($parent); |
|
183
|
|
|
$e->setAttribute('affiliationOwnerID', $this->getAffiliationOwnerId()->getValue()); |
|
184
|
|
|
|
|
185
|
|
|
foreach ($this->getAttributesNS() as $attr) { |
|
186
|
|
|
$attr->toXML($e); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
foreach ($this->getAffiliateMember() as $am) { |
|
190
|
|
|
$am->toXML($e); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
foreach ($this->getKeyDescriptor() as $kd) { |
|
194
|
|
|
$kd->toXML($e); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
return $e; |
|
198
|
|
|
} |
|
199
|
|
|
} |
|
200
|
|
|
|
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