Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"ext-dom": "*",

"simplesamlphp/assert": "~2.0",
"simplesamlphp/xml-common": "~2.8",
"simplesamlphp/xml-ws-addressing": "~1.3",
"simplesamlphp/xml-ws-policy": "~1.3",
"simplesamlphp/xml-wss-core": "~1.4"
"simplesamlphp/xml-common": "dev-feature/dom-migration-php84",
"simplesamlphp/xml-ws-addressing": "dev-feature/dom-migration-php84",
"simplesamlphp/xml-ws-policy": "dev-feature/dom-migration-php84",
"simplesamlphp/xml-wss-core": "dev-feature/dom-migration-php84"
},
"require-dev": {
"simplesamlphp/simplesamlphp-test-framework": "~1.11"
Expand Down
9 changes: 5 additions & 4 deletions src/TestUtils/sp_200507/NestedPolicyTypeTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ public function testMarshalling(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\AbstractNestedPolicyType $np */
$np = new static::$testedClass([static::$policy, static::$some], [static::$attr]);

$this->assertEquals(
static::$xmlRepresentation->saveXML(static::$xmlRepresentation->documentElement),
strval($np),
);
$expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
$this->assertNotFalse($expectedXml);
$actualXml = strval($np);

$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
47 changes: 26 additions & 21 deletions src/TestUtils/sp_200702/NestedPolicyTypeTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public function testMarshalling(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $np */
$np = new static::$testedClass([static::$chunk], [static::$attr]);

$this->assertEquals(
static::$xmlRepresentation->saveXML(static::$xmlRepresentation->documentElement),
strval($np),
);
$expectedXml = static::$xmlRepresentation->saveXml(static::$xmlRepresentation->documentElement);
$this->assertNotFalse($expectedXml);
$actualXml = strval($np);

$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}


Expand All @@ -55,10 +56,11 @@ public function testMarshallingWithoutNSAttr(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $np */
$np = new static::$testedClass([static::$chunk]);

$this->assertEquals(
$xmlRepresentation->saveXML($xmlRepresentation->documentElement),
strval($np),
);
$expectedXml = $xmlRepresentation->saveXml($xmlRepresentation->documentElement);
$this->assertNotFalse($expectedXml);
$actualXml = strval($np);

$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}


Expand All @@ -75,12 +77,13 @@ public function testMarshallingWithoutChildren(): void
$xmlRepresentation = DOMDocumentFactory::fromString($xml);

/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $qns */
$qns = new static::$testedClass([], [static::$attr]);
$np = new static::$testedClass([], [static::$attr]);

$this->assertEquals(
$xmlRepresentation->saveXML($xmlRepresentation->documentElement),
strval($qns),
);
$expectedXml = $xmlRepresentation->saveXml($xmlRepresentation->documentElement);
$this->assertNotFalse($expectedXml);
$actualXml = strval($np);

$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}


Expand Down Expand Up @@ -127,10 +130,11 @@ public function testUnmarshallingWithoutNSAttr(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $np */
$np = static::$testedClass::fromXML($xmlRepresentation->documentElement);

$this->assertEquals(
$xmlRepresentation->saveXML($xmlRepresentation->documentElement),
strval($np),
);
$expectedXml = $xmlRepresentation->saveXml($xmlRepresentation->documentElement);
$this->assertNotFalse($expectedXml);
$actualXml = strval($np);

$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}


Expand All @@ -150,9 +154,10 @@ public function testUnmarshallingWithoutChildren(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $np */
$np = static::$testedClass::fromXML($xmlRepresentation->documentElement);

$this->assertEquals(
$xmlRepresentation->saveXML($xmlRepresentation->documentElement),
strval($np),
);
$expectedXml = $xmlRepresentation->saveXml($xmlRepresentation->documentElement);
$this->assertNotFalse($expectedXml);
$actualXml = strval($np);

$this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
11 changes: 5 additions & 6 deletions src/Utils/XPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace SimpleSAML\WebServices\SecurityPolicy\Utils;

use DOMNode;
use DOMXPath;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Constants as C;

/**
Expand All @@ -16,15 +15,15 @@
class XPath extends \SimpleSAML\XPath\XPath
{
/*
* Get a DOMXPath object that can be used to search for WS Security elements.
* Get a Dom\XPath object that can be used to search for WS Security elements.
*
* @param \DOMNode $node The document to associate to the DOMXPath object.
* @param \Dom\Node $node The document to associate to the Dom\XPath object.
* @param bool $autoregister Whether to auto-register all namespaces used in the document
*
* @return \DOMXPath A DOMXPath object ready to use in the given document, with several
* @return \Dom\XPath A Dom\XPath object ready to use in the given document, with several
* ws-related namespaces already registered.
*/
public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath
public static function getXPath(Dom\Node $node, bool $autoregister = false): Dom\XPath
{
$xp = parent::getXPath($node, $autoregister);

Expand Down
8 changes: 4 additions & 4 deletions src/XML/sp_200507/AbstractEmptyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;

use DOMElement;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;

Expand All @@ -30,12 +30,12 @@ final public function __construct()
*
* Note: this method cannot be used when extending this class, if the constructor has a different signature.
*
* @param \DOMElement $xml The XML element we should load.
* @param \Dom\Element $xml The XML element we should load.
*
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
Expand All @@ -53,7 +53,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
return $this->instantiateParentElement($parent);
}
Expand Down
11 changes: 6 additions & 5 deletions src/XML/sp_200507/AbstractHeaderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;

use DOMElement;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
Expand Down Expand Up @@ -77,12 +77,12 @@ public function getNamespace(): AnyURIValue
*
* Note: this method cannot be used when extending this class, if the constructor has a different signature.
*
* @param \DOMElement $xml The XML element we should load.
* @param \Dom\Element $xml The XML element we should load.
*
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
Expand All @@ -95,9 +95,10 @@ public static function fromXML(DOMElement $xml): static
$namespacedAttributes = self::getAttributesNSFromXML($xml);
$namespace = self::getAttribute($xml, 'Namespace', AnyURIValue::class);

$name = $xml->getAttribute('Name');
return new static(
$namespace,
$xml->hasAttribute('Name') ? QNameValue::fromString($xml->getAttribute('Name')) : null,
($name !== null) ? QNameValue::fromString($name) : null,
$namespacedAttributes,
);
}
Expand All @@ -106,7 +107,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
8 changes: 4 additions & 4 deletions src/XML/sp_200507/AbstractHttpsTokenType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;

use DOMElement;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
Expand Down Expand Up @@ -68,12 +68,12 @@ public function getRequireClientCertificate(): BooleanValue
/**
* Initialize an HttpsTokenType.
*
* @param \DOMElement $xml The XML element we should load.
* @param \Dom\Element $xml The XML element we should load.
*
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
Expand All @@ -94,7 +94,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
7 changes: 3 additions & 4 deletions src/XML/sp_200507/AbstractIssuedTokenType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;

use DOMElement;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\Type\IncludeTokenValue;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
Expand Down Expand Up @@ -88,7 +87,7 @@ public function getRequestSecurityTokenTemplate(): RequestSecurityTokenTemplate
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
Expand Down Expand Up @@ -116,7 +115,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
6 changes: 3 additions & 3 deletions src/XML/sp_200507/AbstractNestedPolicyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;

use DOMElement;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
Expand Down Expand Up @@ -50,7 +50,7 @@ final public function __construct(
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
Expand All @@ -65,7 +65,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this AbstractNestedPolicyType to XML.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
6 changes: 3 additions & 3 deletions src/XML/sp_200507/AbstractQNameAssertionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;

use DOMElement;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
Expand Down Expand Up @@ -46,7 +46,7 @@ final public function __construct(
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
Expand All @@ -64,7 +64,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;

use DOMElement;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function isEmptyElement(): bool
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
Expand All @@ -107,10 +107,9 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*
* @param \DOMElement|null $parent The element we should append this element to.
* @return \DOMElement
* @param \Dom\Element|null $parent The element we should append this element to.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
6 changes: 3 additions & 3 deletions src/XML/sp_200507/AbstractSePartsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;

use DOMElement;
use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
Expand Down Expand Up @@ -94,7 +94,7 @@ public function isEmptyElement(): bool
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
Expand All @@ -121,7 +121,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
Loading
Loading