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
|
|
|
use SimpleSAML\XML\SchemaValidatableElementInterface; |
13
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
14
|
|
|
|
15
|
|
|
use function array_pop; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class representing a dsig11:ValidationData element. |
19
|
|
|
* |
20
|
|
|
* @package simplesaml/xml-security |
21
|
|
|
*/ |
22
|
|
|
final class ValidationData extends AbstractECValidationDataType implements SchemaValidatableElementInterface |
23
|
|
|
{ |
24
|
|
|
use SchemaValidatableElementTrait; |
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Convert XML into a ValidationData element |
28
|
|
|
* |
29
|
|
|
* @param \DOMElement $xml The XML element we should load |
30
|
|
|
* @return static |
31
|
|
|
* |
32
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
33
|
|
|
* If the qualified name of the supplied element is wrong |
34
|
|
|
*/ |
35
|
|
|
public static function fromXML(DOMElement $xml): static |
36
|
|
|
{ |
37
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
38
|
|
|
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); |
39
|
|
|
|
40
|
|
|
$seed = Seed::getChildrenOfClass($xml); |
41
|
|
|
Assert::minCount($seed, 1, MissingElementException::class); |
42
|
|
|
Assert::maxCount($seed, 1, TooManyElementsException::class); |
43
|
|
|
|
44
|
|
|
return new static( |
45
|
|
|
array_pop($seed), |
46
|
|
|
self::getAttribute($xml, 'hashAlgorithm'), |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|