1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\XML\xenc11; |
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\ExtendableElementTrait; |
12
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class representing <xenc11:KeyDerivationMethodType>. |
16
|
|
|
* |
17
|
|
|
* @package simplesamlphp/xml-security |
18
|
|
|
*/ |
19
|
|
|
abstract class AbstractKeyDerivationMethodType extends AbstractXenc11Element |
20
|
|
|
{ |
21
|
|
|
use ExtendableElementTrait; |
22
|
|
|
|
23
|
|
|
/** The namespace-attribute for the xs:any element */ |
24
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::ANY; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* KeyDerivationMethod constructor. |
29
|
|
|
* |
30
|
|
|
* @param string $Algorithm |
31
|
|
|
* @param \SimpleSAML\XML\SerializableElementInterface[] $children |
32
|
|
|
*/ |
33
|
|
|
final public function __construct( |
34
|
|
|
protected string $Algorithm, |
35
|
|
|
array $children, |
36
|
|
|
) { |
37
|
|
|
Assert::validURI($Algorithm, SchemaViolationException::class); |
38
|
|
|
|
39
|
|
|
$this->setElements($children); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get the value of the $Algorithm property. |
45
|
|
|
* |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getAlgorithm(): string |
49
|
|
|
{ |
50
|
|
|
return $this->Algorithm; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @inheritDoc |
56
|
|
|
* |
57
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
58
|
|
|
* If the qualified name of the supplied element is wrong |
59
|
|
|
*/ |
60
|
|
|
public static function fromXML(DOMElement $xml): static |
61
|
|
|
{ |
62
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
63
|
|
|
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); |
64
|
|
|
|
65
|
|
|
return new static( |
66
|
|
|
self::getOptionalAttribute($xml, 'Algorithm', null), |
|
|
|
|
67
|
|
|
self::getChildElementsFromXML($xml), |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @inheritDoc |
74
|
|
|
*/ |
75
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
76
|
|
|
{ |
77
|
|
|
$e = $this->instantiateParentElement($parent); |
78
|
|
|
$e->setAttribute('Algorithm', $this->getAlgorithm()); |
79
|
|
|
|
80
|
|
|
foreach ($this->getElements() as $child) { |
81
|
|
|
if (!$child->isEmptyElement()) { |
82
|
|
|
$child->toXML($e); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return $e; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|