-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\XML\xenc11; | ||
|
||
/** | ||
* Class representing <xenc11:AbstractMGFType>. | ||
* | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
abstract class AbstractMGFType extends AbstractAlgorithmIdentifierType | ||
{ | ||
/** | ||
* MGFType constructor. | ||
* | ||
* @param string $Algorithm | ||
*/ | ||
public function __construct( | ||
string $Algorithm, | ||
) { | ||
parent::__construct($Algorithm, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\XMLSecurity\XML\xenc11; | ||
|
||
use DOMElement; | ||
use SimpleSAML\Assert\Assert; | ||
use SimpleSAML\XML\Exception\InvalidDOMElementException; | ||
|
||
/** | ||
* A class implementing the xenc11:MGF element. | ||
* | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
final class MGF extends AbstractMGFType | ||
{ | ||
/** | ||
* @inheritDoc | ||
* | ||
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException | ||
* If the qualified name of the supplied element is wrong | ||
*/ | ||
public static function fromXML(DOMElement $xml): static | ||
{ | ||
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); | ||
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); | ||
|
||
return new static( | ||
self::getOptionalAttribute($xml, 'Algorithm', null), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\Test\SAML2\XML\xenc11; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleSAML\XML\DOMDocumentFactory; | ||
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
use SimpleSAML\XMLSecurity\XML\xenc11\AbstractAlgorithmIdentifierType; | ||
use SimpleSAML\XMLSecurity\XML\xenc11\AbstractMGFType; | ||
use SimpleSAML\XMLSecurity\XML\xenc11\AbstractXenc11Element; | ||
use SimpleSAML\XMLSecurity\XML\xenc11\MGF; | ||
|
||
use function dirname; | ||
use function strval; | ||
|
||
/** | ||
* Class \SimpleSAML\XMLSecurity\XML\xenc11\MGFTest | ||
* | ||
* @package simplesamlphp/xml-security | ||
*/ | ||
#[CoversClass(MGF::class)] | ||
#[CoversClass(AbstractMGFType::class)] | ||
#[CoversClass(AbstractAlgorithmIdentifierType::class)] | ||
#[CoversClass(AbstractXenc11Element::class)] | ||
final class MGFTest extends TestCase | ||
{ | ||
use SchemaValidationTestTrait; | ||
use SerializableElementTestTrait; | ||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$testedClass = MGF::class; | ||
|
||
self::$schemaFile = dirname(__FILE__, 4) . '/resources/schemas/xenc-schema-11.xsd'; | ||
|
||
self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
dirname(__FILE__, 3) . '/resources/xml/xenc11_MGF.xml', | ||
); | ||
} | ||
|
||
|
||
// marshalling | ||
|
||
|
||
/** | ||
*/ | ||
public function testMarshalling(): void | ||
{ | ||
$mgf = new MGF('urn:x-simplesamlphp:algorithm'); | ||
|
||
$this->assertEquals( | ||
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), | ||
strval($mgf), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<xenc11:MGF xmlns:xenc11="http://www.w3.org/2009/xmlenc11#" Algorithm="urn:x-simplesamlphp:algorithm" /> |