|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSecurity\XML\dsig11; |
|
6
|
|
|
|
|
7
|
|
|
use DOMElement; |
|
8
|
|
|
use SimpleSAML\Assert\Assert; |
|
9
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
|
10
|
|
|
use SimpleSAML\XML\Exception\MissingElementException; |
|
11
|
|
|
use SimpleSAML\XML\Exception\TooManyElementsException; |
|
12
|
|
|
|
|
13
|
|
|
use function array_pop; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class representing a dsig11:ECParameters element. |
|
17
|
|
|
* |
|
18
|
|
|
* @package simplesaml/xml-security |
|
19
|
|
|
*/ |
|
20
|
|
|
final class ECParameters extends AbstractECParametersType |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Convert XML into a ECParameters element |
|
24
|
|
|
* |
|
25
|
|
|
* @param \DOMElement $xml The XML element we should load |
|
26
|
|
|
* @return static |
|
27
|
|
|
* |
|
28
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
|
29
|
|
|
* If the qualified name of the supplied element is wrong |
|
30
|
|
|
*/ |
|
31
|
|
|
public static function fromXML(DOMElement $xml): static |
|
32
|
|
|
{ |
|
33
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
|
34
|
|
|
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); |
|
35
|
|
|
|
|
36
|
|
|
$fieldId = FieldID::getChildrenOfClass($xml); |
|
37
|
|
|
Assert::minCount($fieldId, 1, MissingElementException::class); |
|
38
|
|
|
Assert::maxCount($fieldId, 1, TooManyElementsException::class); |
|
39
|
|
|
|
|
40
|
|
|
$curve = Curve::getChildrenOfClass($xml); |
|
41
|
|
|
Assert::minCount($curve, 1, MissingElementException::class); |
|
42
|
|
|
Assert::maxCount($curve, 1, TooManyElementsException::class); |
|
43
|
|
|
|
|
44
|
|
|
$base = Base::getChildrenOfClass($xml); |
|
45
|
|
|
Assert::minCount($base, 1, MissingElementException::class); |
|
46
|
|
|
Assert::maxCount($base, 1, TooManyElementsException::class); |
|
47
|
|
|
|
|
48
|
|
|
$order = Order::getChildrenOfClass($xml); |
|
49
|
|
|
Assert::minCount($order, 1, MissingElementException::class); |
|
50
|
|
|
Assert::maxCount($order, 1, TooManyElementsException::class); |
|
51
|
|
|
|
|
52
|
|
|
$coFactor = CoFactor::getChildrenOfClass($xml); |
|
53
|
|
|
Assert::maxCount($coFactor, 1, TooManyElementsException::class); |
|
54
|
|
|
|
|
55
|
|
|
$validationData = ValidationData::getChildrenOfClass($xml); |
|
56
|
|
|
Assert::maxCount($validationData, 1, TooManyElementsException::class); |
|
57
|
|
|
|
|
58
|
|
|
return new static( |
|
59
|
|
|
array_pop($fieldId), |
|
60
|
|
|
array_pop($curve), |
|
61
|
|
|
array_pop($base), |
|
62
|
|
|
array_pop($order), |
|
63
|
|
|
array_pop($coFactor), |
|
64
|
|
|
array_pop($validationData), |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|