From f7ec43f088733ac520486d28cc9c56ca45444130 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sat, 30 Nov 2024 00:41:47 +0100 Subject: [PATCH] Add ds:MgmtData element --- src/XML/ds/KeyInfo.php | 4 +-- src/XML/ds/MgmtData.php | 26 ++++++++++++++ src/XML/element.registry.php | 2 +- src/XML/xenc/OriginatorKeyInfo.php | 5 +-- src/XML/xenc/RecipientKeyInfo.php | 5 +-- tests/XML/ds/MgmtDataTest.php | 55 +++++++++++++++++++++++++++++ tests/resources/xml/ds_MgmtData.xml | 1 + 7 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 src/XML/ds/MgmtData.php create mode 100644 tests/XML/ds/MgmtDataTest.php create mode 100644 tests/resources/xml/ds_MgmtData.xml diff --git a/src/XML/ds/KeyInfo.php b/src/XML/ds/KeyInfo.php index 5f499345..ea5bc9ec 100644 --- a/src/XML/ds/KeyInfo.php +++ b/src/XML/ds/KeyInfo.php @@ -39,7 +39,7 @@ public static function fromXML(DOMElement $xml): static $x509Data = X509Data::getChildrenOfClass($xml); //$pgpData = PGPData::getChildrenOfClass($xml); //$spkiData = SPKIData::getChildrenOfClass($xml); - //$mgmtData = MgmtData::getChildrenOfClass($xml); + $mgmtData = MgmtData::getChildrenOfClass($xml); $other = self::getChildElementsFromXML($xml); $info = array_merge( @@ -49,7 +49,7 @@ public static function fromXML(DOMElement $xml): static $x509Data, //$pgpdata, //$spkidata, - //$mgmtdata, + $mgmtdata, $other, ); diff --git a/src/XML/ds/MgmtData.php b/src/XML/ds/MgmtData.php new file mode 100644 index 00000000..23a1d7de --- /dev/null +++ b/src/XML/ds/MgmtData.php @@ -0,0 +1,26 @@ +setContent($content); + } +} diff --git a/src/XML/element.registry.php b/src/XML/element.registry.php index 9a55180d..441e0cee 100644 --- a/src/XML/element.registry.php +++ b/src/XML/element.registry.php @@ -12,7 +12,7 @@ 'KeyName' => '\SimpleSAML\XMLSecurity\XML\ds\KeyName', 'KeyValue' => '\SimpleSAML\XMLSecurity\XML\ds\KeyValue', 'Manifest' => '\SimpleSAML\XMLSecurity\XML\ds\Manifest', -// 'MgmtData' => '\SimpleSAML\XMLSecurity\XML\ds\MgmtData', + 'MgmtData' => '\SimpleSAML\XMLSecurity\XML\ds\MgmtData', 'Object' => '\SimpleSAML\XMLSecurity\XML\ds\DsObject', // 'PGPData' => '\SimpleSAML\XMLSecurity\XML\ds\PGPData', 'Reference' => '\SimpleSAML\XMLSecurity\XML\ds\Reference', diff --git a/src/XML/xenc/OriginatorKeyInfo.php b/src/XML/xenc/OriginatorKeyInfo.php index 2f7db9a1..9b35d2f8 100644 --- a/src/XML/xenc/OriginatorKeyInfo.php +++ b/src/XML/xenc/OriginatorKeyInfo.php @@ -11,6 +11,7 @@ use SimpleSAML\XMLSecurity\XML\ds\AbstractKeyInfoType; use SimpleSAML\XMLSecurity\XML\ds\KeyName; use SimpleSAML\XMLSecurity\XML\ds\KeyValue; +use SimpleSAML\XMLSecurity\XML\ds\MgmtData; use SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod; use SimpleSAML\XMLSecurity\XML\ds\X509Data; @@ -52,7 +53,7 @@ public static function fromXML(DOMElement $xml): static $x509Data = X509Data::getChildrenOfClass($xml); //$pgpData = PGPData::getChildrenOfClass($xml); //$spkiData = SPKIData::getChildrenOfClass($xml); - //$mgmtData = MgmtData::getChildrenOfClass($xml); + $mgmtData = MgmtData::getChildrenOfClass($xml); $other = self::getChildElementsFromXML($xml); $info = array_merge( @@ -62,7 +63,7 @@ public static function fromXML(DOMElement $xml): static $x509Data, //$pgpdata, //$spkidata, - //$mgmtdata, + $mgmtdata, $other, ); diff --git a/src/XML/xenc/RecipientKeyInfo.php b/src/XML/xenc/RecipientKeyInfo.php index c5eb61b9..41cc7ce9 100644 --- a/src/XML/xenc/RecipientKeyInfo.php +++ b/src/XML/xenc/RecipientKeyInfo.php @@ -11,6 +11,7 @@ use SimpleSAML\XMLSecurity\XML\ds\AbstractKeyInfoType; use SimpleSAML\XMLSecurity\XML\ds\KeyName; use SimpleSAML\XMLSecurity\XML\ds\KeyValue; +use SimpleSAML\XMLSecurity\XML\ds\MgmtData; use SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod; use SimpleSAML\XMLSecurity\XML\ds\X509Data; @@ -52,7 +53,7 @@ public static function fromXML(DOMElement $xml): static $x509Data = X509Data::getChildrenOfClass($xml); //$pgpData = PGPData::getChildrenOfClass($xml); //$spkiData = SPKIData::getChildrenOfClass($xml); - //$mgmtData = MgmtData::getChildrenOfClass($xml); + $mgmtData = MgmtData::getChildrenOfClass($xml); $other = self::getChildElementsFromXML($xml); $info = array_merge( @@ -62,7 +63,7 @@ public static function fromXML(DOMElement $xml): static $x509Data, //$pgpdata, //$spkidata, - //$mgmtdata, + $mgmtdata, $other, ); diff --git a/tests/XML/ds/MgmtDataTest.php b/tests/XML/ds/MgmtDataTest.php new file mode 100644 index 00000000..935b87ce --- /dev/null +++ b/tests/XML/ds/MgmtDataTest.php @@ -0,0 +1,55 @@ +assertEquals( + self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), + strval($mgmtData), + ); + } +} diff --git a/tests/resources/xml/ds_MgmtData.xml b/tests/resources/xml/ds_MgmtData.xml new file mode 100644 index 00000000..a0e1e1d2 --- /dev/null +++ b/tests/resources/xml/ds_MgmtData.xml @@ -0,0 +1 @@ +ManagementData