Skip to content

Commit f7ec43f

Browse files
committed
Add ds:MgmtData element
1 parent 15949c9 commit f7ec43f

File tree

7 files changed

+91
-7
lines changed

7 files changed

+91
-7
lines changed

src/XML/ds/KeyInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function fromXML(DOMElement $xml): static
3939
$x509Data = X509Data::getChildrenOfClass($xml);
4040
//$pgpData = PGPData::getChildrenOfClass($xml);
4141
//$spkiData = SPKIData::getChildrenOfClass($xml);
42-
//$mgmtData = MgmtData::getChildrenOfClass($xml);
42+
$mgmtData = MgmtData::getChildrenOfClass($xml);
4343
$other = self::getChildElementsFromXML($xml);
4444

4545
$info = array_merge(
@@ -49,7 +49,7 @@ public static function fromXML(DOMElement $xml): static
4949
$x509Data,
5050
//$pgpdata,
5151
//$spkidata,
52-
//$mgmtdata,
52+
$mgmtdata,
5353
$other,
5454
);
5555

src/XML/ds/MgmtData.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\XML\ds;
6+
7+
use SimpleSAML\XML\StringElementTrait;
8+
9+
/**
10+
* Class representing a ds:MgmtData element.
11+
*
12+
* @package simplesamlphp/xml-security
13+
*/
14+
final class MgmtData extends AbstractDsElement
15+
{
16+
use StringElementTrait;
17+
18+
19+
/**
20+
* @param string $content
21+
*/
22+
public function __construct(string $content)
23+
{
24+
$this->setContent($content);
25+
}
26+
}

src/XML/element.registry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'KeyName' => '\SimpleSAML\XMLSecurity\XML\ds\KeyName',
1313
'KeyValue' => '\SimpleSAML\XMLSecurity\XML\ds\KeyValue',
1414
'Manifest' => '\SimpleSAML\XMLSecurity\XML\ds\Manifest',
15-
// 'MgmtData' => '\SimpleSAML\XMLSecurity\XML\ds\MgmtData',
15+
'MgmtData' => '\SimpleSAML\XMLSecurity\XML\ds\MgmtData',
1616
'Object' => '\SimpleSAML\XMLSecurity\XML\ds\DsObject',
1717
// 'PGPData' => '\SimpleSAML\XMLSecurity\XML\ds\PGPData',
1818
'Reference' => '\SimpleSAML\XMLSecurity\XML\ds\Reference',

src/XML/xenc/OriginatorKeyInfo.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use SimpleSAML\XMLSecurity\XML\ds\AbstractKeyInfoType;
1212
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
1313
use SimpleSAML\XMLSecurity\XML\ds\KeyValue;
14+
use SimpleSAML\XMLSecurity\XML\ds\MgmtData;
1415
use SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod;
1516
use SimpleSAML\XMLSecurity\XML\ds\X509Data;
1617

@@ -52,7 +53,7 @@ public static function fromXML(DOMElement $xml): static
5253
$x509Data = X509Data::getChildrenOfClass($xml);
5354
//$pgpData = PGPData::getChildrenOfClass($xml);
5455
//$spkiData = SPKIData::getChildrenOfClass($xml);
55-
//$mgmtData = MgmtData::getChildrenOfClass($xml);
56+
$mgmtData = MgmtData::getChildrenOfClass($xml);
5657
$other = self::getChildElementsFromXML($xml);
5758

5859
$info = array_merge(
@@ -62,7 +63,7 @@ public static function fromXML(DOMElement $xml): static
6263
$x509Data,
6364
//$pgpdata,
6465
//$spkidata,
65-
//$mgmtdata,
66+
$mgmtdata,
6667
$other,
6768
);
6869

src/XML/xenc/RecipientKeyInfo.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use SimpleSAML\XMLSecurity\XML\ds\AbstractKeyInfoType;
1212
use SimpleSAML\XMLSecurity\XML\ds\KeyName;
1313
use SimpleSAML\XMLSecurity\XML\ds\KeyValue;
14+
use SimpleSAML\XMLSecurity\XML\ds\MgmtData;
1415
use SimpleSAML\XMLSecurity\XML\ds\RetrievalMethod;
1516
use SimpleSAML\XMLSecurity\XML\ds\X509Data;
1617

@@ -52,7 +53,7 @@ public static function fromXML(DOMElement $xml): static
5253
$x509Data = X509Data::getChildrenOfClass($xml);
5354
//$pgpData = PGPData::getChildrenOfClass($xml);
5455
//$spkiData = SPKIData::getChildrenOfClass($xml);
55-
//$mgmtData = MgmtData::getChildrenOfClass($xml);
56+
$mgmtData = MgmtData::getChildrenOfClass($xml);
5657
$other = self::getChildElementsFromXML($xml);
5758

5859
$info = array_merge(
@@ -62,7 +63,7 @@ public static function fromXML(DOMElement $xml): static
6263
$x509Data,
6364
//$pgpdata,
6465
//$spkidata,
65-
//$mgmtdata,
66+
$mgmtdata,
6667
$other,
6768
);
6869

tests/XML/ds/MgmtDataTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\TestCase;
9+
use SimpleSAML\XML\DOMDocumentFactory;
10+
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
11+
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
12+
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
13+
use SimpleSAML\XMLSecurity\XML\ds\MgmtData;
14+
15+
use function dirname;
16+
use function strval;
17+
18+
/**
19+
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\MgmtDataTest
20+
*
21+
* @package simplesamlphp/xml-security
22+
*/
23+
#[CoversClass(AbstractDsElement::class)]
24+
#[CoversClass(MgmtData::class)]
25+
final class MgmtDataTest extends TestCase
26+
{
27+
use SchemaValidationTestTrait;
28+
use SerializableElementTestTrait;
29+
30+
/**
31+
*/
32+
public static function setUpBeforeClass(): void
33+
{
34+
self::$testedClass = MgmtData::class;
35+
36+
self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xmldsig1-schema.xsd';
37+
38+
self::$xmlRepresentation = DOMDocumentFactory::fromFile(
39+
dirname(__FILE__, 3) . '/resources/xml/ds_MgmtData.xml',
40+
);
41+
}
42+
43+
44+
/**
45+
*/
46+
public function testMarshalling(): void
47+
{
48+
$mgmtData = new MgmtData('ManagementData');
49+
50+
$this->assertEquals(
51+
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
52+
strval($mgmtData),
53+
);
54+
}
55+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ds:MgmtData xmlns:ds="http://www.w3.org/2000/09/xmldsig#">ManagementData</ds:MgmtData>

0 commit comments

Comments
 (0)