Skip to content

Commit

Permalink
Add ds:SPKIData element
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Dec 3, 2024
1 parent 041bb05 commit 4fd66d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 6 additions & 9 deletions src/XML/ds/AbstractSPKIDataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class AbstractSPKIDataType extends AbstractDsElement
/**
* Initialize a SPKIData element.
*
* @param array<\SimpleSAML\XMLSecurity\XML\ds\SPKISexp, SimpleSAML\XML\SerializableElementInterface|null> $tuples
* @param array{array{\SimpleSAML\XMLSecurity\XML\ds\SPKISexp, \SimpleSAML\XML\SerializableElementInterface|null}} $tuples
*/
final public function __construct(
protected array $tuples,
Expand All @@ -32,17 +32,16 @@ final public function __construct(
Assert::allCount($tuples, 2);

foreach ($tuples as $tuple) {
list($spkisExp, $other) = $tuple;
Assert::isInstanceOf($spkisExp, SPKISexp::class, SchemaViolationException::class);
Assert::nullOrIsInstanceOf($other, SerializableElementInterface::class, SchemaViolationException::class);
Assert::isInstanceOf($tuple[0], SPKISexp::class, SchemaViolationException::class);
Assert::nullOrIsInstanceOf($tuple[1], SerializableElementInterface::class, SchemaViolationException::class);
}
}


/**
* Collect the value of the SPKISexp-property
*
* @return array<\SimpleSAML\XMLSecurity\XML\ds\SPKISexp, SimpleSAML\XML\SerializableElementInterface|null>
* @return array{array{\SimpleSAML\XMLSecurity\XML\ds\SPKISexp, \SimpleSAML\XML\SerializableElementInterface|null}}
*/
public function getTuples(): array
{
Expand Down Expand Up @@ -102,10 +101,8 @@ public function toXML(?DOMElement $parent = null): DOMElement
$e = $this->instantiateParentElement($parent);

foreach ($this->getTuples() as $tuple) {
list($spkisExp, $other) = $tuple;

$spkisExp->toXML($e);
$other?->toXML($e);
$tuple[0]->toXML($e);
$tuple[1]?->toXML($e);
}

return $e;
Expand Down
4 changes: 2 additions & 2 deletions tests/XML/ds/SPKIDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
use SimpleSAML\XMLSecurity\XML\ds\AbstractSPKIData;
use SimpleSAML\XMLSecurity\XML\ds\AbstractSPKIDataType;
use SimpleSAML\XMLSecurity\XML\ds\SPKIData;
use SimpleSAML\XMLSecurity\XML\ds\SPKISexp;
use SimpleSAML\XMLSecurity\XML\xenc\CarriedKeyName;
Expand All @@ -25,7 +25,7 @@
* @package simplesamlphp/xml-security
*/
#[CoversClass(AbstractDsElement::class)]
#[CoversClass(AbstractSPKIData::class)]
#[CoversClass(AbstractSPKIDataType::class)]
#[CoversClass(SPKIData::class)]
final class SPKIDataTest extends TestCase
{
Expand Down

0 comments on commit 4fd66d3

Please sign in to comment.