|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\SAML2\XML\saml; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\Assert\AssertionFailedException; |
|
9
|
|
|
use SimpleSAML\SAML2\Assert\Assert; |
|
10
|
|
|
use SimpleSAML\SAML2\Type\EntityIDValue; |
|
11
|
|
|
use SimpleSAML\SAML2\Type\SAMLDateTimeValue; |
|
12
|
|
|
use SimpleSAML\SAML2\Type\SAMLStringValue; |
|
13
|
|
|
use SimpleSAML\SAML2\Utils; |
|
14
|
|
|
use SimpleSAML\XML\ExtendableAttributesTrait; |
|
15
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
|
16
|
|
|
use SimpleSAML\XML\SchemaValidatableElementInterface; |
|
17
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
|
18
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
|
19
|
|
|
use SimpleSAML\XMLSchema\Type\NCNameValue; |
|
20
|
|
|
use SimpleSAML\XMLSchema\XML\Constants\NS; |
|
21
|
|
|
|
|
22
|
|
|
use function strval; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class representing SAML 2 SubjectConfirmationData element. |
|
26
|
|
|
* |
|
27
|
|
|
* @package simplesamlphp/saml2 |
|
28
|
|
|
*/ |
|
29
|
|
|
final class SubjectConfirmationData extends AbstractSamlElement implements SchemaValidatableElementInterface |
|
30
|
|
|
{ |
|
31
|
|
|
use ExtendableAttributesTrait; |
|
32
|
|
|
use ExtendableElementTrait; |
|
33
|
|
|
use SchemaValidatableElementTrait; |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
/** The namespace-attribute for the xs:any element */ |
|
37
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::ANY; |
|
38
|
|
|
|
|
39
|
|
|
/** The namespace-attribute for the xs:anyAttribute element */ |
|
40
|
|
|
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Initialize (and parse) a SubjectConfirmationData element. |
|
45
|
|
|
* |
|
46
|
|
|
* @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $notBefore |
|
47
|
|
|
* @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $notOnOrAfter |
|
48
|
|
|
* @param \SimpleSAML\SAML2\Type\EntityIDValue|null $recipient |
|
49
|
|
|
* @param \SimpleSAML\XMLSchema\Type\NCNameValue|null $inResponseTo |
|
50
|
|
|
* @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $address |
|
51
|
|
|
* @param \SimpleSAML\XML\SerializableElementInterface[] $children |
|
52
|
|
|
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes |
|
|
|
|
|
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct( |
|
55
|
|
|
protected ?SAMLDateTimeValue $notBefore = null, |
|
56
|
|
|
protected ?SAMLDateTimeValue $notOnOrAfter = null, |
|
57
|
|
|
protected ?EntityIDValue $recipient = null, |
|
58
|
|
|
protected ?NCNameValue $inResponseTo = null, |
|
59
|
|
|
protected ?SAMLStringValue $address = null, |
|
60
|
|
|
array $children = [], |
|
61
|
|
|
array $namespacedAttributes = [], |
|
62
|
|
|
) { |
|
63
|
|
|
if ($address !== null) { |
|
64
|
|
|
try { |
|
65
|
|
|
/** |
|
66
|
|
|
* IPv4 addresses SHOULD be represented in the usual dotted-decimal format (e.g., "1.2.3.4"). |
|
67
|
|
|
* IPv6 addresses SHOULD be represented as defined by Section 2.2 of IETF RFC 3513 [RFC 3513] |
|
68
|
|
|
* (e.g., "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210"). |
|
69
|
|
|
*/ |
|
70
|
|
|
Assert::ip($address->getValue()); |
|
71
|
|
|
} catch (AssertionFailedException) { |
|
72
|
|
|
Utils::getContainer()->getLogger()->warning( |
|
73
|
|
|
sprintf('Provided address (%s) is not a valid IPv4 or IPv6 address.', $address->getValue()), |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
$this->setElements($children); |
|
79
|
|
|
$this->setAttributesNS($namespacedAttributes); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Collect the value of the NotBefore-property |
|
85
|
|
|
* |
|
86
|
|
|
* @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getNotBefore(): ?SAMLDateTimeValue |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->notBefore; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Collect the value of the NotOnOrAfter-property |
|
96
|
|
|
* |
|
97
|
|
|
* @return \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getNotOnOrAfter(): ?SAMLDateTimeValue |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->notOnOrAfter; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Collect the value of the Recipient-property |
|
107
|
|
|
* |
|
108
|
|
|
* @return \SimpleSAML\SAML2\Type\EntityIDValue|null |
|
109
|
|
|
*/ |
|
110
|
|
|
public function getRecipient(): ?EntityIDValue |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->recipient; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Collect the value of the InResponseTo-property |
|
118
|
|
|
* |
|
119
|
|
|
* @return \SimpleSAML\XMLSchema\Type\NCNameValue|null |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getInResponseTo(): ?NCNameValue |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->inResponseTo; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Collect the value of the Address-property |
|
129
|
|
|
* |
|
130
|
|
|
* @return \SimpleSAML\SAML2\Type\SAMLStringValue|null |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getAddress(): ?SAMLStringValue |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->address; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
|
140
|
|
|
* |
|
141
|
|
|
* @return bool |
|
142
|
|
|
*/ |
|
143
|
|
|
public function isEmptyElement(): bool |
|
144
|
|
|
{ |
|
145
|
|
|
return empty($this->getNotBefore()) |
|
146
|
|
|
&& empty($this->getNotOnOrAfter()) |
|
147
|
|
|
&& empty($this->getRecipient()) |
|
148
|
|
|
&& empty($this->getInResponseTo()) |
|
149
|
|
|
&& empty($this->getAddress()) |
|
150
|
|
|
&& empty($this->getElements()) |
|
151
|
|
|
&& empty($this->getAttributesNS()); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Convert XML into a SubjectConfirmationData |
|
157
|
|
|
* |
|
158
|
|
|
* @param \DOMElement $xml The XML element we should load |
|
159
|
|
|
* @return static |
|
160
|
|
|
* |
|
161
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
|
162
|
|
|
* if the qualified name of the supplied element is wrong |
|
163
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
|
164
|
|
|
* if the supplied element is missing any of the mandatory attributes |
|
165
|
|
|
* @throws \SimpleSAML\Assert\AssertionFailedException |
|
166
|
|
|
* if NotBefore or NotOnOrAfter contain an invalid date. |
|
167
|
|
|
*/ |
|
168
|
|
|
public static function fromXML(DOMElement $xml): static |
|
169
|
|
|
{ |
|
170
|
|
|
Assert::same($xml->localName, 'SubjectConfirmationData', InvalidDOMElementException::class); |
|
171
|
|
|
Assert::same($xml->namespaceURI, SubjectConfirmationData::NS, InvalidDOMElementException::class); |
|
172
|
|
|
|
|
173
|
|
|
return new static( |
|
174
|
|
|
self::getOptionalAttribute($xml, 'NotBefore', SAMLDateTimeValue::class, null), |
|
175
|
|
|
self::getOptionalAttribute($xml, 'NotOnOrAfter', SAMLDateTimeValue::class, null), |
|
176
|
|
|
self::getOptionalAttribute($xml, 'Recipient', EntityIDValue::class, null), |
|
177
|
|
|
self::getOptionalAttribute($xml, 'InResponseTo', NCNameValue::class, null), |
|
178
|
|
|
self::getOptionalAttribute($xml, 'Address', SAMLStringValue::class, null), |
|
179
|
|
|
self::getChildElementsFromXML($xml), |
|
180
|
|
|
self::getAttributesNSFromXML($xml), |
|
181
|
|
|
); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* Convert this element to XML. |
|
187
|
|
|
* |
|
188
|
|
|
* @param \DOMElement|null $parent The parent element we should append this element to. |
|
189
|
|
|
* @return \DOMElement This element, as XML. |
|
190
|
|
|
*/ |
|
191
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
|
192
|
|
|
{ |
|
193
|
|
|
$e = $this->instantiateParentElement($parent); |
|
194
|
|
|
|
|
195
|
|
|
if ($this->getNotBefore() !== null) { |
|
196
|
|
|
$e->setAttribute('NotBefore', strval($this->getNotBefore())); |
|
197
|
|
|
} |
|
198
|
|
|
if ($this->getNotOnOrAfter() !== null) { |
|
199
|
|
|
$e->setAttribute('NotOnOrAfter', strval($this->getNotOnOrAfter())); |
|
200
|
|
|
} |
|
201
|
|
|
if ($this->getRecipient() !== null) { |
|
202
|
|
|
$e->setAttribute('Recipient', strval($this->getRecipient())); |
|
203
|
|
|
} |
|
204
|
|
|
if ($this->getInResponseTo() !== null) { |
|
205
|
|
|
$e->setAttribute('InResponseTo', strval($this->getInResponseTo())); |
|
206
|
|
|
} |
|
207
|
|
|
if ($this->getAddress() !== null) { |
|
208
|
|
|
$e->setAttribute('Address', strval($this->getAddress())); |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
foreach ($this->getAttributesNS() as $attr) { |
|
212
|
|
|
$attr->toXML($e); |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
foreach ($this->getElements() as $n) { |
|
216
|
|
|
$n->toXML($e); |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
return $e; |
|
220
|
|
|
} |
|
221
|
|
|
} |
|
222
|
|
|
|
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