1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace SimpleSAML\XMLSecurity\XML\ds; |
||
6 | |||
7 | use DOMElement; |
||
8 | use SimpleSAML\Assert\Assert; |
||
9 | use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait}; |
||
10 | use SimpleSAML\XMLSecurity\XML\dsig11\DEREncodedKeyValue; |
||
11 | use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
||
12 | use SimpleSAML\XMLSchema\Type\IDValue; |
||
13 | |||
14 | use function array_merge; |
||
15 | |||
16 | /** |
||
17 | * Class representing a ds:KeyInfo element. |
||
18 | * |
||
19 | * @package simplesamlphp/xml-security |
||
20 | */ |
||
21 | final class KeyInfo extends AbstractKeyInfoType implements SchemaValidatableElementInterface |
||
22 | { |
||
23 | use SchemaValidatableElementTrait; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
24 | |||
25 | /** |
||
26 | * Convert XML into a KeyInfo |
||
27 | * |
||
28 | * @param \DOMElement $xml The XML element we should load |
||
29 | * @return static |
||
30 | * |
||
31 | * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
||
32 | * If the qualified name of the supplied element is wrong |
||
33 | */ |
||
34 | public static function fromXML(DOMElement $xml): static |
||
35 | { |
||
36 | Assert::same($xml->localName, 'KeyInfo', InvalidDOMElementException::class); |
||
37 | Assert::same($xml->namespaceURI, KeyInfo::NS, InvalidDOMElementException::class); |
||
38 | |||
39 | $Id = self::getOptionalAttribute($xml, 'Id', IDValue::class, null); |
||
40 | |||
41 | $keyName = KeyName::getChildrenOfClass($xml); |
||
42 | $keyValue = KeyValue::getChildrenOfClass($xml); |
||
43 | $retrievalMethod = RetrievalMethod::getChildrenOfClass($xml); |
||
44 | $x509Data = X509Data::getChildrenOfClass($xml); |
||
45 | $pgpData = PGPData::getChildrenOfClass($xml); |
||
46 | $spkiData = SPKIData::getChildrenOfClass($xml); |
||
47 | $mgmtData = MgmtData::getChildrenOfClass($xml); |
||
48 | $derEncodedKeyValue = DEREncodedKeyValue::getChildrenOfClass($xml); |
||
49 | $other = self::getChildElementsFromXML($xml); |
||
50 | |||
51 | $info = array_merge( |
||
52 | $keyName, |
||
53 | $keyValue, |
||
54 | $retrievalMethod, |
||
55 | $x509Data, |
||
56 | $pgpData, |
||
57 | $spkiData, |
||
58 | $mgmtData, |
||
59 | $derEncodedKeyValue, |
||
60 | $other, |
||
61 | ); |
||
62 | |||
63 | return new static($info, $Id); |
||
64 | } |
||
65 | } |
||
66 |