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