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