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\Exception\SchemaViolationException; |
11
|
|
|
use SimpleSAML\XML\Exception\TooManyElementsException; |
12
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
13
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
14
|
|
|
use SimpleSAML\XMLSecurity\Constants as C; |
15
|
|
|
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException; |
16
|
|
|
|
17
|
|
|
use function array_keys; |
18
|
|
|
use function array_merge; |
19
|
|
|
use function array_pop; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class representing a ds:SignatureMethod element. |
23
|
|
|
* |
24
|
|
|
* @package simplesamlphp/xml-security |
25
|
|
|
*/ |
26
|
|
|
final class SignatureMethod extends AbstractDsElement |
27
|
|
|
{ |
28
|
|
|
use ExtendableElementTrait; |
29
|
|
|
|
30
|
|
|
/** The namespace-attribute for the xs:any element */ |
31
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::OTHER; |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Initialize a SignatureMethod element. |
36
|
|
|
* |
37
|
|
|
* @param string $Algorithm |
38
|
|
|
* @param \SimpleSAML\XMLSecurity\ds\HMACOutputLength|null $hmacOutputLength |
|
|
|
|
39
|
|
|
* @param array<\SimpleSAML\XML\SerializableElementInterface> $children |
40
|
|
|
*/ |
41
|
|
|
public function __construct( |
42
|
|
|
protected string $Algorithm, |
43
|
|
|
protected ?HMACOutputLength $hmacOutputLength = null, |
44
|
|
|
array $children = [], |
45
|
|
|
) { |
46
|
|
|
Assert::validURI($Algorithm, SchemaViolationException::class); |
47
|
|
|
Assert::oneOf( |
48
|
|
|
$Algorithm, |
49
|
|
|
array_merge( |
50
|
|
|
array_keys(C::$RSA_DIGESTS), |
51
|
|
|
array_keys(C::$HMAC_DIGESTS), |
52
|
|
|
), |
53
|
|
|
'Invalid signature method: %s', |
54
|
|
|
InvalidArgumentException::class, |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
$this->setElements($children); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Collect the value of the Algorithm-property |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getAlgorithm(): string |
67
|
|
|
{ |
68
|
|
|
return $this->Algorithm; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Collect the value of the hmacOutputLength-property |
74
|
|
|
* |
75
|
|
|
* @return \SimpleSAML\XMLSecurity\ds\HMACOutputLength|null |
76
|
|
|
*/ |
77
|
|
|
public function getHMACOutputLength(): ?HMACOutputLength |
78
|
|
|
{ |
79
|
|
|
return $this->hmacOutputLength; |
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Convert XML into a SignatureMethod |
85
|
|
|
* |
86
|
|
|
* @param \DOMElement $xml The XML element we should load |
87
|
|
|
* @return static |
88
|
|
|
* |
89
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
90
|
|
|
* If the qualified name of the supplied element is wrong |
91
|
|
|
*/ |
92
|
|
|
public static function fromXML(DOMElement $xml): static |
93
|
|
|
{ |
94
|
|
|
Assert::same($xml->localName, 'SignatureMethod', InvalidDOMElementException::class); |
95
|
|
|
Assert::same($xml->namespaceURI, SignatureMethod::NS, InvalidDOMElementException::class); |
96
|
|
|
|
97
|
|
|
$Algorithm = SignatureMethod::getAttribute($xml, 'Algorithm'); |
98
|
|
|
|
99
|
|
|
$hmacOutputLength = HMACOutputLength::getChildrenOfClass($xml); |
100
|
|
|
Assert::maxCount($hmacOutputLength, 1, TooManyElementsException::class); |
101
|
|
|
|
102
|
|
|
return new static($Algorithm, array_pop($hmacOutputLength), self::getChildElementsFromXML($xml)); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Convert this SignatureMethod element to XML. |
108
|
|
|
* |
109
|
|
|
* @param \DOMElement|null $parent The element we should append this SignatureMethod element to. |
110
|
|
|
* @return \DOMElement |
111
|
|
|
*/ |
112
|
|
|
public function toXML(DOMElement $parent = null): DOMElement |
113
|
|
|
{ |
114
|
|
|
$e = $this->instantiateParentElement($parent); |
115
|
|
|
$e->setAttribute('Algorithm', $this->getAlgorithm()); |
116
|
|
|
|
117
|
|
|
$this->getHMACOutputLength()?->toXML($e); |
118
|
|
|
|
119
|
|
|
foreach ($this->getElements() as $elt) { |
120
|
|
|
$elt->toXML($e); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
return $e; |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
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