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\ExtendableElementTrait; |
||
10 | use SimpleSAML\XMLSchema\Exception\{InvalidDOMElementException, SchemaViolationException, TooManyElementsException}; |
||
11 | use SimpleSAML\XMLSchema\Type\AnyURIValue; |
||
12 | use SimpleSAML\XMLSchema\XML\Enumeration\NamespaceEnum; |
||
13 | |||
14 | use function array_pop; |
||
15 | use function strval; |
||
16 | |||
17 | /** |
||
18 | * A class implementing the xenc:AbstractEncryptionMethod element. |
||
19 | * |
||
20 | * @package simplesamlphp/xml-security |
||
21 | */ |
||
22 | abstract class AbstractEncryptionMethod extends AbstractXencElement |
||
23 | { |
||
24 | use ExtendableElementTrait; |
||
25 | |||
26 | /** The namespace-attribute for the xs:any element */ |
||
27 | public const XS_ANY_ELT_NAMESPACE = NamespaceEnum::Other; |
||
28 | |||
29 | |||
30 | /** |
||
31 | * EncryptionMethod constructor. |
||
32 | * |
||
33 | * @param \SimpleSAML\XMLSchema\Type\AnyURIValue $algorithm |
||
34 | * @param \SimpleSAML\XMLSecurity\XML\xenc\KeySize|null $keySize |
||
35 | * @param \SimpleSAML\XMLSecurity\XML\xenc\OAEPparams|null $oaepParams |
||
36 | * @param list<\SimpleSAML\XML\SerializableElementInterface> $children |
||
0 ignored issues
–
show
|
|||
37 | */ |
||
38 | final public function __construct( |
||
39 | protected AnyURIValue $algorithm, |
||
40 | protected ?KeySize $keySize = null, |
||
41 | protected ?OAEPparams $oaepParams = null, |
||
42 | array $children = [], |
||
43 | ) { |
||
44 | $this->setElements($children); |
||
45 | } |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Get the URI identifying the algorithm used by this encryption method. |
||
50 | * |
||
51 | * @return \SimpleSAML\XMLSchema\Type\AnyURIValue |
||
52 | */ |
||
53 | public function getAlgorithm(): AnyURIValue |
||
54 | { |
||
55 | return $this->algorithm; |
||
56 | } |
||
57 | |||
58 | |||
59 | /** |
||
60 | * Get the size of the key used by this encryption method. |
||
61 | * |
||
62 | * @return \SimpleSAML\XMLSecurity\XML\xenc\KeySize|null |
||
63 | */ |
||
64 | public function getKeySize(): ?KeySize |
||
65 | { |
||
66 | return $this->keySize; |
||
67 | } |
||
68 | |||
69 | |||
70 | /** |
||
71 | * Get the OAEP parameters. |
||
72 | * |
||
73 | * @return \SimpleSAML\XMLSecurity\XML\xenc\OAEPparams|null |
||
74 | */ |
||
75 | public function getOAEPParams(): ?OAEPparams |
||
76 | { |
||
77 | return $this->oaepParams; |
||
78 | } |
||
79 | |||
80 | |||
81 | /** |
||
82 | * Initialize an EncryptionMethod object from an existing XML. |
||
83 | * |
||
84 | * @param \DOMElement $xml |
||
85 | * @return static |
||
86 | * |
||
87 | * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
||
88 | * if the qualified name of the supplied element is wrong |
||
89 | * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException |
||
90 | * if the supplied element is missing one of the mandatory attributes |
||
91 | * @throws \SimpleSAML\XMLSchema\Exception\TooManyElementsException |
||
92 | * if too many child-elements of a type are specified |
||
93 | */ |
||
94 | public static function fromXML(DOMElement $xml): static |
||
95 | { |
||
96 | Assert::same($xml->localName, 'EncryptionMethod', InvalidDOMElementException::class); |
||
97 | Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
||
98 | |||
99 | $keySize = KeySize::getChildrenOfClass($xml); |
||
100 | Assert::maxCount($keySize, 1, TooManyElementsException::class); |
||
101 | |||
102 | $oaepParams = OAEPparams::getChildrenOfClass($xml); |
||
103 | Assert::maxCount($oaepParams, 1, TooManyElementsException::class); |
||
104 | |||
105 | return new static( |
||
106 | self::getAttribute($xml, 'Algorithm', AnyURIValue::class), |
||
107 | array_pop($keySize), |
||
108 | array_pop($oaepParams), |
||
109 | self::getChildElementsFromXML($xml), |
||
110 | ); |
||
111 | } |
||
112 | |||
113 | |||
114 | /** |
||
115 | * Convert this EncryptionMethod object to XML. |
||
116 | * |
||
117 | * @param \DOMElement|null $parent The element we should append this EncryptionMethod to. |
||
118 | * @return \DOMElement |
||
119 | */ |
||
120 | public function toXML(?DOMElement $parent = null): DOMElement |
||
121 | { |
||
122 | $e = $this->instantiateParentElement($parent); |
||
123 | $e->setAttribute('Algorithm', strval($this->getAlgorithm())); |
||
124 | |||
125 | $this->getKeySize()?->toXML($e); |
||
126 | $this->getOAEPparams()?->toXML($e); |
||
127 | |||
128 | foreach ($this->getElements() as $child) { |
||
129 | $child->toXML($e); |
||
130 | } |
||
131 | |||
132 | return $e; |
||
133 | } |
||
134 | } |
||
135 |
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