|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\SOAP11\XML\env; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\Assert\Assert; |
|
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
|
10
|
|
|
use SimpleSAML\XML\Exception\MissingElementException; |
|
11
|
|
|
use SimpleSAML\XML\Exception\TooManyElementsException; |
|
12
|
|
|
use SimpleSAML\XML\ExtendableAttributesTrait; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class representing a env:Envelope element. |
|
16
|
|
|
* |
|
17
|
|
|
* @package simplesaml/xml-soap |
|
18
|
|
|
*/ |
|
19
|
|
|
final class Envelope extends AbstractSoapElement |
|
20
|
|
|
{ |
|
21
|
|
|
use ExtendableAttributesTrait; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* The Header element |
|
25
|
|
|
* |
|
26
|
|
|
* @var \SimpleSAML\SOAP\XML\env\Header|null |
|
|
|
|
|
|
27
|
|
|
*/ |
|
28
|
|
|
protected ?Header $header; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* The Body element |
|
32
|
|
|
* |
|
33
|
|
|
* @var \SimpleSAML\SOAP\XML\env\Body |
|
|
|
|
|
|
34
|
|
|
*/ |
|
35
|
|
|
protected Body $body; |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Initialize a env:Envelope |
|
40
|
|
|
* |
|
41
|
|
|
* @param \SimpleSAML\SOAP\XML\env\Body $body |
|
42
|
|
|
* @param \SimpleSAML\SOAP\XML\env\Header|null $header |
|
43
|
|
|
* @param \DOMAttr[] $namespacedAttributes |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct(Body $body, ?Header $header = null, array $namespacedAttributes = []) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->setBody($body); |
|
48
|
|
|
$this->setHeader($header); |
|
49
|
|
|
$this->setAttributesNS($namespacedAttributes); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return \SimpleSAML\SOAP\XML\env\Body |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getBody(): Body |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->body; |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param \SimpleSAML\SOAP\XML\env\Body $body |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function setBody(Body $body): void |
|
66
|
|
|
{ |
|
67
|
|
|
$this->body = $body; |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return \SimpleSAML\SOAP\XML\env\Header|null |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getHeader(): ?Header |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->header; |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param \SimpleSAML\SOAP\XML\env\Header|null $header |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function setHeader(?Header $header): void |
|
84
|
|
|
{ |
|
85
|
|
|
$this->header = $header; |
|
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Convert XML into an Envelope element |
|
91
|
|
|
* |
|
92
|
|
|
* @param \DOMElement $xml The XML element we should load |
|
93
|
|
|
* @return static |
|
94
|
|
|
* |
|
95
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
|
96
|
|
|
* If the qualified name of the supplied element is wrong |
|
97
|
|
|
*/ |
|
98
|
|
|
public static function fromXML(DOMElement $xml): static |
|
99
|
|
|
{ |
|
100
|
|
|
Assert::same($xml->localName, 'Envelope', InvalidDOMElementException::class); |
|
101
|
|
|
Assert::same($xml->namespaceURI, Envelope::NS, InvalidDOMElementException::class); |
|
102
|
|
|
|
|
103
|
|
|
$body = Body::getChildrenOfClass($xml); |
|
104
|
|
|
Assert::count($body, 1, 'Must contain exactly one Body', MissingElementException::class); |
|
105
|
|
|
|
|
106
|
|
|
$header = Header::getChildrenOfClass($xml); |
|
107
|
|
|
Assert::maxCount($header, 1, 'Cannot process more than one Header element.', TooManyElementsException::class); |
|
108
|
|
|
|
|
109
|
|
|
return new static( |
|
110
|
|
|
array_pop($body), |
|
111
|
|
|
empty($header) ? null : array_pop($header), |
|
112
|
|
|
self::getAttributesNSFromXML($xml) |
|
113
|
|
|
); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Convert this Envelope to XML. |
|
119
|
|
|
* |
|
120
|
|
|
* @param \DOMElement|null $parent The element we should add this envelope to. |
|
121
|
|
|
* @return \DOMElement This Envelope-element. |
|
122
|
|
|
*/ |
|
123
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
|
124
|
|
|
{ |
|
125
|
|
|
$e = $this->instantiateParentElement($parent); |
|
126
|
|
|
|
|
127
|
|
|
foreach ($this->getAttributesNS() as $attr) { |
|
128
|
|
|
$e->setAttributeNS($attr['namespaceURI'], $attr['qualifiedName'], $attr['value']); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
if ($this->getHeader() !== null && !$this->getHeader()->isEmptyElement()) { |
|
132
|
|
|
$this->getHeader()->toXML($e); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
$this->getBody()->toXML($e); |
|
136
|
|
|
|
|
137
|
|
|
return $e; |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
|
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