1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SOAP12\XML\env; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\SOAP\Constants as C; |
10
|
|
|
use SimpleSAML\SOAP\Exception\ProtocolViolationException; |
11
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
12
|
|
|
use SimpleSAML\XML\Exception\MissingElementException; |
13
|
|
|
use SimpleSAML\XML\Exception\TooManyElementsException; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class representing a env:Code element. |
17
|
|
|
* |
18
|
|
|
* @package simplesaml/xml-soap |
19
|
|
|
*/ |
20
|
|
|
final class Code extends AbstractSoapElement |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* The Value element |
24
|
|
|
* |
25
|
|
|
* @var \SimpleSAML\SOAP\XML\env\Value |
|
|
|
|
26
|
|
|
*/ |
27
|
|
|
protected Value $value; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The Subcode element |
31
|
|
|
* |
32
|
|
|
* @var \SimpleSAML\SOAP\XML\env\Subcode|null |
|
|
|
|
33
|
|
|
*/ |
34
|
|
|
protected ?Subcode $subcode; |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Initialize a soap:Code |
39
|
|
|
* |
40
|
|
|
* @param \SimpleSAML\SOAP\XML\env\Value $value |
41
|
|
|
* @param \SimpleSAML\SOAP\XML\env\Code|null $code |
|
|
|
|
42
|
|
|
*/ |
43
|
|
|
public function __construct(Value $value, ?Subcode $subcode) |
44
|
|
|
{ |
45
|
|
|
$this->setValue($value); |
46
|
|
|
$this->setSubcode($subcode); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return \SimpleSAML\SOAP\XML\env\Value |
52
|
|
|
*/ |
53
|
|
|
public function getValue(): Value |
54
|
|
|
{ |
55
|
|
|
return $this->value; |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param \SimpleSAML\SOAP\XML\env\Value $value |
61
|
|
|
*/ |
62
|
|
|
protected function setValue(Value $value): void |
63
|
|
|
{ |
64
|
|
|
@list($prefix, $localName) = preg_split('/:/', $value->getContent(), 2); |
65
|
|
|
if ($localName === null) { |
66
|
|
|
// We don't have a prefixed value here |
67
|
|
|
$localName = $prefix; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
Assert::oneOf( |
71
|
|
|
$localName, |
72
|
|
|
C::FAULT_CODES, |
73
|
|
|
'Invalid top-level Value', |
74
|
|
|
ProtocolViolationException::class |
75
|
|
|
); |
76
|
|
|
$this->value = $value; |
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return \SimpleSAML\SOAP\XML\env\Subcode|null |
82
|
|
|
*/ |
83
|
|
|
public function getSubcode(): ?Subcode |
84
|
|
|
{ |
85
|
|
|
return $this->subcode; |
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param \SimpleSAML\SOAP\XML\env\Subcode|null $subcode |
91
|
|
|
*/ |
92
|
|
|
protected function setSubcode(?Subcode $subcode): void |
93
|
|
|
{ |
94
|
|
|
$this->subcode = $subcode; |
|
|
|
|
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Convert XML into an Code element |
100
|
|
|
* |
101
|
|
|
* @param \DOMElement $xml The XML element we should load |
102
|
|
|
* @return static |
103
|
|
|
* |
104
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
105
|
|
|
* If the qualified name of the supplied element is wrong |
106
|
|
|
*/ |
107
|
|
|
public static function fromXML(DOMElement $xml): static |
108
|
|
|
{ |
109
|
|
|
Assert::same($xml->localName, 'Code', InvalidDOMElementException::class); |
110
|
|
|
Assert::same($xml->namespaceURI, Code::NS, InvalidDOMElementException::class); |
111
|
|
|
|
112
|
|
|
$value = Value::getChildrenOfClass($xml); |
113
|
|
|
Assert::count($value, 1, 'Must contain exactly one Value', MissingElementException::class); |
114
|
|
|
|
115
|
|
|
// Assert that the namespace of the value matches the SOAP-ENV namespace |
116
|
|
|
@list($prefix, $localName) = preg_split('/:/', $value[0]->getContent(), 2); |
117
|
|
|
$namespace = $xml->lookupNamespaceUri($prefix); |
118
|
|
|
Assert::same($namespace, C::NS_SOAP_ENV_12); |
119
|
|
|
|
120
|
|
|
$subcode = Subcode::getChildrenOfClass($xml); |
121
|
|
|
Assert::maxCount($subcode, 1, 'Cannot process more than one Subcode element.', TooManyElementsException::class); |
122
|
|
|
|
123
|
|
|
return new static( |
124
|
|
|
array_pop($value), |
125
|
|
|
empty($subcode) ? null : array_pop($subcode) |
126
|
|
|
); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Convert this Code to XML. |
132
|
|
|
* |
133
|
|
|
* @param \DOMElement|null $parent The element we should add this code to. |
134
|
|
|
* @return \DOMElement This Code-element. |
135
|
|
|
*/ |
136
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
137
|
|
|
{ |
138
|
|
|
$e = $this->instantiateParentElement($parent); |
139
|
|
|
|
140
|
|
|
$this->value->toXML($e); |
141
|
|
|
$this->subcode?->toXML($e); |
142
|
|
|
|
143
|
|
|
return $e; |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
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