|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\XML\xenc; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\Assert\Assert; |
|
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
|
10
|
|
|
use SimpleSAML\XML\Chunk; |
|
11
|
|
|
use SimpleSAML\XML\XMLElementInterface; |
|
12
|
|
|
use SimpleSAML\XMLSecurity\XML\ds\Transforms; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Abstract class representing references. No custom elements are allowed. |
|
16
|
|
|
* |
|
17
|
|
|
* @package simplesamlphp/xml-security |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class AbstractReference extends AbstractXencElement |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var string */ |
|
22
|
|
|
protected string $uri; |
|
23
|
|
|
|
|
24
|
|
|
/** @var \SimpleSAML\XML\XMLElementInterface[] */ |
|
25
|
|
|
protected array $elements; |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* AbstractReference constructor. |
|
30
|
|
|
* |
|
31
|
|
|
* @param string $uri |
|
32
|
|
|
* @param \SimpleSAML\XML\XMLElementInterface[] $elements |
|
33
|
|
|
*/ |
|
34
|
|
|
protected function __construct(string $uri, array $elements = []) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->setURI($uri); |
|
37
|
|
|
$this->setElements($elements); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Get the value of the URI attribute of this reference. |
|
43
|
|
|
* |
|
44
|
|
|
* @return string |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getURI(): string |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->uri; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param string $uri |
|
54
|
|
|
*/ |
|
55
|
|
|
protected function setURI(string $uri): void |
|
56
|
|
|
{ |
|
57
|
|
|
Assert::notEmpty($uri, 'The URI attribute of a reference cannot be empty.'); |
|
58
|
|
|
$this->uri = $uri; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Collect the embedded elements |
|
64
|
|
|
* |
|
65
|
|
|
* @return \SimpleSAML\XML\XMLElementInterface[] |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getElements(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->elements; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Set the value of the elements-property |
|
75
|
|
|
* |
|
76
|
|
|
* @param \SimpleSAML\XML\XMLElementInterface[] $elements |
|
77
|
|
|
* @throws \SimpleSAML\Assert\AssertionFailedException |
|
78
|
|
|
* if the supplied array contains anything other than XMLElementInterface objects |
|
79
|
|
|
*/ |
|
80
|
|
|
private function setElements(array $elements): void |
|
81
|
|
|
{ |
|
82
|
|
|
Assert::allIsInstanceOf($elements, XMLElementInterface::class); |
|
83
|
|
|
$this->elements = $elements; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @inheritDoc |
|
89
|
|
|
* |
|
90
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
|
91
|
|
|
* if the qualified name of the supplied element is wrong |
|
92
|
|
|
* @throws \SimpleSAML\XML\Exception\MissingAttributeException |
|
93
|
|
|
* if the supplied element is missing one of the mandatory attributes |
|
94
|
|
|
*/ |
|
95
|
|
|
public static function fromXML(DOMElement $xml): object |
|
96
|
|
|
{ |
|
97
|
|
|
Assert::same($xml->localName, static::getClassName(static::class), InvalidDOMElementException::class); |
|
98
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
|
99
|
|
|
|
|
100
|
|
|
$URI = self::getAttribute($xml, 'URI'); |
|
101
|
|
|
|
|
102
|
|
|
$elements = []; |
|
103
|
|
|
foreach ($xml->childNodes as $element) { |
|
104
|
|
|
if (!($element instanceof DOMElement)) { |
|
105
|
|
|
continue; |
|
106
|
|
|
} elseif ($element->namespaceURI === Transforms::NS && $element->localName === 'Transforms') { |
|
107
|
|
|
$elements[] = new Transforms($element); |
|
108
|
|
|
} else { |
|
109
|
|
|
$elements[] = new Chunk($element); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
return new static($URI, $elements); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @inheritDoc |
|
119
|
|
|
*/ |
|
120
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
|
121
|
|
|
{ |
|
122
|
|
|
$e = $this->instantiateParentElement($parent); |
|
123
|
|
|
$e->setAttribute('URI', $this->uri); |
|
124
|
|
|
|
|
125
|
|
|
foreach ($this->elements as $element) { |
|
126
|
|
|
$element->toXML($e); |
|
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