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
|
|
|
/** |
16
|
|
|
* Class representing a dsig11:FieldID element. |
17
|
|
|
* |
18
|
|
|
* @package simplesaml/xml-security |
19
|
|
|
*/ |
20
|
|
|
final class FieldID extends AbstractFieldIDType implements SchemaValidatableElementInterface |
21
|
|
|
{ |
22
|
|
|
use SchemaValidatableElementTrait; |
|
|
|
|
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Convert XML into a FieldID element |
26
|
|
|
* |
27
|
|
|
* @param \DOMElement $xml The XML element we should load |
28
|
|
|
* @return static |
29
|
|
|
* |
30
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
31
|
|
|
* If the qualified name of the supplied element is wrong |
32
|
|
|
*/ |
33
|
|
|
public static function fromXML(DOMElement $xml): static |
34
|
|
|
{ |
35
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
36
|
|
|
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); |
37
|
|
|
|
38
|
|
|
$prime = Prime::getChildrenOfClass($xml); |
39
|
|
|
Assert::minCount($prime, 1, MissingElementException::class); |
40
|
|
|
Assert::maxCount($prime, 1, TooManyElementsException::class); |
41
|
|
|
|
42
|
|
|
$tnb = TnB::getChildrenOfClass($xml); |
43
|
|
|
Assert::minCount($tnb, 1, MissingElementException::class); |
44
|
|
|
Assert::maxCount($tnb, 1, TooManyElementsException::class); |
45
|
|
|
|
46
|
|
|
$pnb = PnB::getChildrenOfClass($xml); |
47
|
|
|
Assert::minCount($pnb, 1, MissingElementException::class); |
48
|
|
|
Assert::maxCount($pnb, 1, TooManyElementsException::class); |
49
|
|
|
|
50
|
|
|
$gnb = GnB::getChildrenOfClass($xml); |
51
|
|
|
Assert::minCount($gnb, 1, MissingElementException::class); |
52
|
|
|
Assert::maxCount($gnb, 1, TooManyElementsException::class); |
53
|
|
|
|
54
|
|
|
return new static( |
55
|
|
|
array_pop($prime), |
56
|
|
|
array_pop($tnb), |
57
|
|
|
array_pop($pnb), |
58
|
|
|
array_pop($gnb), |
59
|
|
|
self::getChildElementsFromXML($xml), |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|