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