|
9 | 9 | use SimpleSAML\XML\Chunk; |
10 | 10 | use SimpleSAML\XML\Exception\InvalidDOMElementException; |
11 | 11 | use SimpleSAML\XML\Exception\SchemaViolationException; |
| 12 | +use SimpleSAML\XML\ExtendableElementTrait; |
12 | 13 | use SimpleSAML\XMLSecurity\Constants as C; |
13 | 14 | use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException; |
14 | 15 |
|
|
19 | 20 | */ |
20 | 21 | final class DigestMethod extends AbstractDsElement |
21 | 22 | { |
| 23 | + use ExtendableElementTrait; |
| 24 | + |
| 25 | + public const NAMESPACE = C::XS_ANY_NS_OTHER; |
| 26 | + |
22 | 27 | /** |
23 | 28 | * The algorithm. |
24 | 29 | * |
25 | 30 | * @var string |
26 | 31 | */ |
27 | 32 | protected string $Algorithm; |
28 | 33 |
|
29 | | - /** |
30 | | - * @var \SimpleSAML\XML\Chunk[] |
31 | | - */ |
32 | | - protected array $elements; |
33 | | - |
34 | 34 |
|
35 | 35 | /** |
36 | 36 | * Initialize a DigestMethod element. |
@@ -75,32 +75,6 @@ private function setAlgorithm(string $algorithm): void |
75 | 75 | } |
76 | 76 |
|
77 | 77 |
|
78 | | - /** |
79 | | - * Collect the embedded elements |
80 | | - * |
81 | | - * @return \SimpleSAML\XML\Chunk[] |
82 | | - */ |
83 | | - public function getElements(): array |
84 | | - { |
85 | | - return $this->elements; |
86 | | - } |
87 | | - |
88 | | - |
89 | | - /** |
90 | | - * Set the value of the elements-property |
91 | | - * |
92 | | - * @param \SimpleSAML\XML\Chunk[] $elements |
93 | | - * @throws \SimpleSAML\Assert\AssertionFailedException |
94 | | - * if the supplied array contains anything other than Chunk objects |
95 | | - */ |
96 | | - private function setElements(array $elements): void |
97 | | - { |
98 | | - Assert::allIsInstanceOf($elements, Chunk::class, InvalidArgumentException::class); |
99 | | - |
100 | | - $this->elements = $elements; |
101 | | - } |
102 | | - |
103 | | - |
104 | 78 | /** |
105 | 79 | * Convert XML into a DigestMethod |
106 | 80 | * |
@@ -140,10 +114,13 @@ public static function fromXML(DOMElement $xml): static |
140 | 114 | public function toXML(DOMElement $parent = null): DOMElement |
141 | 115 | { |
142 | 116 | $e = $this->instantiateParentElement($parent); |
143 | | - $e->setAttribute('Algorithm', $this->Algorithm); |
| 117 | + $e->setAttribute('Algorithm', $this->getAlgorithm()); |
144 | 118 |
|
| 119 | + /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $elt */ |
145 | 120 | foreach ($this->elements as $elt) { |
146 | | - $e->appendChild($e->ownerDocument->importNode($elt->getXML(), true)); |
| 121 | + if (!$elt->isEmptyElement()) { |
| 122 | + $elt->toXML($e); |
| 123 | + } |
147 | 124 | } |
148 | 125 |
|
149 | 126 | return $e; |
|
0 commit comments