1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\XML\ds; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
10
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
11
|
|
|
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class representing a ds:Object element. |
15
|
|
|
* |
16
|
|
|
* @package simplesamlphp/xml-security |
17
|
|
|
*/ |
18
|
|
|
final class DsObject extends AbstractDsElement |
19
|
|
|
{ |
20
|
|
|
use ExtendableElementTrait; |
21
|
|
|
|
22
|
|
|
/** @var string */ |
23
|
|
|
public const LOCALNAME = 'Object'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The Id. |
27
|
|
|
* |
28
|
|
|
* @var string|null |
29
|
|
|
*/ |
30
|
|
|
protected ?string $Id; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The MIME type. |
34
|
|
|
* |
35
|
|
|
* @var string|null |
36
|
|
|
*/ |
37
|
|
|
protected ?string $MimeType; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The encoding. |
41
|
|
|
* |
42
|
|
|
* @var string|null |
43
|
|
|
*/ |
44
|
|
|
protected ?string $Encoding; |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Initialize a ds:Object element. |
49
|
|
|
* |
50
|
|
|
* @param string|null $Id |
51
|
|
|
* @param string|null $MimeType |
52
|
|
|
* @param string|null $Encoding |
53
|
|
|
* @param \SimpleSAML\XML\XMLElementInterface[] $elements |
54
|
|
|
*/ |
55
|
|
|
public function __construct( |
56
|
|
|
?string $Id = null, |
57
|
|
|
?string $MimeType = null, |
58
|
|
|
?string $Encoding = null, |
59
|
|
|
array $elements = [] |
60
|
|
|
) { |
61
|
|
|
$this->setId($Id); |
62
|
|
|
$this->setMimeType($MimeType); |
63
|
|
|
$this->setEncoding($Encoding); |
64
|
|
|
$this->setElements($elements); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Collect the value of the Id-property |
70
|
|
|
* |
71
|
|
|
* @return string|null |
72
|
|
|
*/ |
73
|
|
|
public function getId(): ?string |
74
|
|
|
{ |
75
|
|
|
return $this->Id; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Set the value of the Id-property |
81
|
|
|
* |
82
|
|
|
* @param string $Id |
83
|
|
|
*/ |
84
|
|
|
private function setId(?string $Id): void |
85
|
|
|
{ |
86
|
|
|
$this->Id = $Id; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Collect the value of the MimeType-property |
92
|
|
|
* |
93
|
|
|
* @return string|null |
94
|
|
|
*/ |
95
|
|
|
public function getMimeType(): ?string |
96
|
|
|
{ |
97
|
|
|
return $this->MimeType; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Set the value of the MimeType-property |
103
|
|
|
* |
104
|
|
|
* @param string|null $MimeType |
105
|
|
|
*/ |
106
|
|
|
private function setMimeType(?string $MimeType): void |
107
|
|
|
{ |
108
|
|
|
$this->MimeType = $MimeType; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Collect the value of the Encoding-property |
114
|
|
|
* |
115
|
|
|
* @return string|null |
116
|
|
|
*/ |
117
|
|
|
public function getEncoding(): ?string |
118
|
|
|
{ |
119
|
|
|
return $this->Encoding; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Set the value of the Encoding-property |
125
|
|
|
* |
126
|
|
|
* @param string|null $Encoding |
127
|
|
|
*/ |
128
|
|
|
private function setEncoding(?string $Encoding): void |
129
|
|
|
{ |
130
|
|
|
$this->Encoding = $Encoding; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
136
|
|
|
* |
137
|
|
|
* @return bool |
138
|
|
|
*/ |
139
|
|
|
public function isEmptyElement(): bool |
140
|
|
|
{ |
141
|
|
|
return ( |
142
|
|
|
empty($this->elements) |
143
|
|
|
&& empty($this->Id) |
144
|
|
|
&& empty($this->MimeType) |
145
|
|
|
&& empty($this->Encoding) |
146
|
|
|
); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Convert XML into a ds:Object |
152
|
|
|
* |
153
|
|
|
* @param \DOMElement $xml The XML element we should load |
154
|
|
|
* @return self |
155
|
|
|
* |
156
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
157
|
|
|
* If the qualified name of the supplied element is wrong |
158
|
|
|
*/ |
159
|
|
|
public static function fromXML(DOMElement $xml): object |
160
|
|
|
{ |
161
|
|
|
Assert::same($xml->localName, 'Object', InvalidDOMElementException::class); |
162
|
|
|
Assert::same($xml->namespaceURI, Object::NS, InvalidDOMElementException::class); |
|
|
|
|
163
|
|
|
|
164
|
|
|
$Id = Object::getAttribute($xml, 'Id'); |
165
|
|
|
$MimeType = Object::getAttribute($xml, 'MimeType'); |
166
|
|
|
$Encoding = Object::getAttribute($xml, 'Encoding'); |
167
|
|
|
|
168
|
|
|
$elements = []; |
169
|
|
|
foreach ($xml->childNodes as $elt) { |
170
|
|
|
if (!($elt instanceof DOMElement)) { |
171
|
|
|
continue; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
$elements[] = new Chunk($elt); |
|
|
|
|
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
return new self($Id, $MimeType, $Encoding, $elements); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Convert this ds:Object element to XML. |
183
|
|
|
* |
184
|
|
|
* @param \DOMElement|null $parent The element we should append this ds:Object element to. |
185
|
|
|
* @return \DOMElement |
186
|
|
|
*/ |
187
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
188
|
|
|
{ |
189
|
|
|
$e = $this->instantiateParentElement($parent); |
190
|
|
|
$e->setAttribute('Id', $this->Id); |
191
|
|
|
$e->setAttribute('MimeType', $this->MimeType); |
192
|
|
|
$e->setAttribute('Encoding', $this->Encoding); |
193
|
|
|
|
194
|
|
|
foreach ($this->elements as $elt) { |
195
|
|
|
$elt->toXML($e); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
return $e; |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|
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