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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"psr/http-message": "~2.0",
"psr/log": "~3.0",
"simplesamlphp/assert": "~2.0",
"simplesamlphp/xml-common": "~2.8",
"simplesamlphp/xml-security": "~2.3",
"simplesamlphp/xml-soap": "~2.3"
"simplesamlphp/xml-common": "dev-feature/dom-migration-php84",
"simplesamlphp/xml-security": "dev-feature/dom-migration-php84",
"simplesamlphp/xml-soap": "dev-feature/dom-migration-php84"
},
"require-dev": {
"ext-intl": "*",
Expand Down
6 changes: 0 additions & 6 deletions phpstan-baseline-dev.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ parameters:
count: 1
path: tests/SAML2/Assertion/Validation/AssertionValidatorTest.php

-
message: '#^Parameter \#1 \$xml of static method SimpleSAML\\SAML2\\XML\\saml\\Assertion\:\:fromXML\(\) expects DOMElement, DOMNode\|null given\.$#'
identifier: argument.type
count: 2
path: tests/SAML2/Assertion/Validation/AssertionValidatorTest.php

-
message: '#^Result of method SimpleSAML\\SAML2\\Assertion\\Processor\:\:validateAssertion\(\) \(void\) is used\.$#'
identifier: method.void
Expand Down
4 changes: 3 additions & 1 deletion src/Binding/HTTPArtifact.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public function getRedirectURL(AbstractMessage $message): string
}
$artifact = base64_encode("\x00\x04\x00\x00" . sha1($issuer->getContent(), true) . $generatedId);
$artifactData = $message->toXML();
$artifactDataString = $artifactData->ownerDocument?->saveXML($artifactData);
/** @var \Dom\XMLDocument $ownerDocument */
$ownerDocument = $artifactData->ownerDocument;
$artifactDataString = $ownerDocument->saveXML($artifactData);

$clock = Utils::getContainer()->getClock();
$store->set('artifact', $artifact, $artifactDataString, $clock->now()->add(new DateInterval('PT15M')));
Expand Down
4 changes: 3 additions & 1 deletion src/Binding/HTTPPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public function send(AbstractMessage $message): ResponseInterface
$msgStr = $message->toXML();

Utils::getContainer()->debugMessage($msgStr, 'out');
$msgStr = $msgStr->ownerDocument?->saveXML($msgStr);
/** @var \Dom\XMLDocument $ownerDocument */
$ownerDocument = $msgStr->ownerDocument;
$msgStr = $ownerDocument?->saveXML($msgStr);

$msgStr = base64_encode($msgStr);

Expand Down
4 changes: 3 additions & 1 deletion src/Binding/HTTPRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function getRedirectURL(AbstractMessage $message): string
$msgStr = $message->toXML();

Utils::getContainer()->debugMessage($msgStr, 'out');
$msgStr = $msgStr->ownerDocument?->saveXML($msgStr);
/** @var \Dom\XMLDocument $ownerDocument */
$ownerDocument = $msgStr->ownerDocument;
$msgStr = $ownerDocument->saveXML($msgStr);

$msgStr = gzdeflate($msgStr);
$msgStr = base64_encode($msgStr);
Expand Down
8 changes: 5 additions & 3 deletions src/Binding/SOAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public function getOutputToSend(AbstractMessage $message): string|false
new Body([$message]),
$header,
);
return $env->toXML()->ownerDocument?->saveXML();
/** @var \Dom\XMLDocument $ownerDocument */
$ownerDocument = $env->toXML()->ownerDocument;
return $ownerDocument->saveXML();
}


Expand Down Expand Up @@ -99,12 +101,12 @@ public function receive(/** @scrutinizer ignore-unused */ServerRequestInterface
}

$document = DOMDocumentFactory::fromString($postText);
/** @var \DOMNode $xml */
/** @var \Dom\Node $xml */
$xml = $document->firstChild;
Utils::getContainer()->debugMessage($document->documentElement, 'in');

$xpCache = XPath::getXPath($document->documentElement);
/** @var \DOMElement[] $results */
/** @var \Dom\Element[] $results */
$results = XPath::xpQuery($xml, '/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]', $xpCache);

return MessageFactory::fromXML($results[0]);
Expand Down
2 changes: 1 addition & 1 deletion src/Compat/AbstractContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ abstract public function getLogger(): LoggerInterface;
* - **encrypt** XML that is about to be encrypted
* - **decrypt** XML that was just decrypted
*
* @param \DOMElement|string $message
* @param \Dom\Element|string $message
*/
abstract public function debugMessage($message, string $type): void;

Expand Down
2 changes: 1 addition & 1 deletion src/Compat/MockContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getLogger(): LoggerInterface
* - **encrypt** XML that is about to be encrypted
* - **decrypt** XML that was just decrypted
*
* @param \DOMElement|string $message
* @param \Dom\Element|string $message
*/
public function debugMessage($message, string $type): void
{
Expand Down
8 changes: 6 additions & 2 deletions src/SOAPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ public function send(

// Add soap-envelopes
$env = (new Envelope(new Body([new Chunk($msg->toXML())])))->toXML();
$request = $env->ownerDocument?->saveXML();
/** @var \Dom\XMLDocument $ownerDocument */
$ownerDocument = $env->ownerDocument;
$request = $ownerDocument->saveXML();

$container->debugMessage($request, 'out');

Expand All @@ -158,7 +160,9 @@ public function send(

$dom = DOMDocumentFactory::fromString($soapresponsexml);
$env = Envelope::fromXML($dom->documentElement);
$container->debugMessage($env->toXML()->ownerDocument?->saveXML(), 'in');
/** @var \Dom\XMLDocument $ownerDocument */
$ownerDocument = $env->toXML()->ownerDocument;
$container->debugMessage($ownerDocument->saveXML(), 'in');

$soapfault = $this->getSOAPFault($dom);
if ($soapfault !== null) {
Expand Down
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\SAML2\Utils;

use DOMNode;
use DOMXPath;
use Dom;
use SimpleSAML\SAML2\Constants as C;

/**
Expand All @@ -16,15 +15,15 @@
class XPath extends \SimpleSAML\XMLSecurity\Utils\XPath
{
/**
* Get a DOMXPath object that can be used to search for SAML elements.
* Get a Dom\XPath object that can be used to search for SAML 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
* saml-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
6 changes: 3 additions & 3 deletions src/XML/CanonicalizableElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\SAML2\XML;

use DOMElement;
use Dom;
use SimpleSAML\XMLSecurity\Assert\Assert;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\Exception\CanonicalizationFailedException;
Expand All @@ -26,15 +26,15 @@ trait CanonicalizableElementTrait
* Process all transforms specified by a given Reference element.
*
* @param \SimpleSAML\XMLSecurity\XML\ds\Transforms $transforms The transforms to apply.
* @param \DOMElement $data The data referenced.
* @param \Dom\Element $data The data referenced.
*
* @return string The canonicalized data after applying all transforms specified by $ref.
*
* @see http://www.w3.org/TR/xmldsig-core/#sec-ReferenceProcessingModel
*/
public function processTransforms(
Transforms $transforms,
DOMElement $data,
Dom\Element $data,
): string {
Assert::maxCount(
$transforms->getTransform(),
Expand Down
4 changes: 3 additions & 1 deletion src/XML/EncryptableElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ public function encrypt(EncryptionAlgorithmInterface $encryptor): EncryptedData
}

$xmlRepresentation = $this->toXML();
/** @var \Dom\XMLDocument $ownerDocument */
$ownerDocument = $xmlRepresentation->ownerDocument;

return new EncryptedData(
new CipherData(
new CipherValue(
Base64BinaryValue::fromString(
base64_encode($encryptor->encrypt(
$xmlRepresentation->ownerDocument->saveXML($xmlRepresentation),
$ownerDocument->saveXML($xmlRepresentation),
)),
),
),
Expand Down
6 changes: 3 additions & 3 deletions src/XML/EncryptedElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\SAML2\XML;

use DOMElement;
use Dom;
use SimpleSAML\SAML2\Assert\Assert;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
Expand Down Expand Up @@ -92,7 +92,7 @@ public function getDecryptionKeys(): array
* @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,
Expand Down Expand Up @@ -120,7 +120,7 @@ public static function fromXML(DOMElement $xml): static
/**
* @inheritDoc
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

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

namespace SimpleSAML\SAML2\XML;

use DOMElement;
use Dom;
use SimpleSAML\XML\ExtendableElementTrait;

/**
Expand Down Expand Up @@ -49,10 +49,10 @@ public function isEmptyElement(): bool
/**
* Convert this object into its md:Extensions XML representation.
*
* @param \DOMElement|null $parent The element we should add this Extensions element to.
* @return \DOMElement The new md:Extensions XML element.
* @param \Dom\Element|null $parent The element we should add this Extensions element to.
* @return \Dom\Element The new md:Extensions XML element.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand All @@ -70,5 +70,5 @@ public function toXML(?DOMElement $parent = null): DOMElement

/**
*/
abstract public function instantiateParentElement(?DOMElement $parent = null): DOMElement;
abstract public function instantiateParentElement(?Dom\Element $parent = null): Dom\Element;
}
4 changes: 2 additions & 2 deletions src/XML/IdentifierTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\SAML2\XML;

use DOMElement;
use Dom;
use SimpleSAML\SAML2\Assert\Assert;
use SimpleSAML\SAML2\XML\saml\AbstractBaseID;
use SimpleSAML\SAML2\XML\saml\EncryptedID;
Expand Down Expand Up @@ -58,7 +58,7 @@ protected function setIdentifier(?IdentifierInterface $identifier): void
* @throws \SimpleSAML\XMLSchema\Exception\TooManyElementsException
* if too many child-elements of a type are specified
*/
protected static function getIdentifierFromXML(DOMElement $xml): ?IdentifierInterface
protected static function getIdentifierFromXML(Dom\Element $xml): ?IdentifierInterface
{
$class = static::NS_PREFIX . ':' . self::getClassName(static::class);

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

namespace SimpleSAML\SAML2\XML;

use DOMElement;
use Dom;
use SimpleSAML\SAML2\Assert\Assert;
use SimpleSAML\SAML2\Compat\ContainerSingleton;
use SimpleSAML\XML\DOMDocumentFactory;
Expand Down Expand Up @@ -75,20 +75,20 @@ public function sign(
/**
* Do the actual signing of the document.
*
* Note that this method does not insert the signature in the returned \DOMElement. The signature will be available
* Note that this method does not insert the signature in the returned \Dom\Element. The signature will be available
* in $this->signature as a \SimpleSAML\XMLSecurity\XML\ds\Signature object, which can then be converted to XML
* calling toXML() on it, passing the \DOMElement value returned here as a parameter. The resulting \DOMElement
* calling toXML() on it, passing the \Dom\Element value returned here as a parameter. The resulting \Dom\Element
* can then be inserted in the position desired.
*
* E.g.:
* $xml = // our XML to sign
* $signedXML = $this->doSign($xml);
* $signedXML->appendChild($this->signature->toXML($signedXML));
*
* @param \DOMElement $xml The element to sign.
* @return \DOMElement The signed element, without the signature attached to it just yet.
* @param \Dom\Element $xml The element to sign.
* @return \Dom\Element The signed element, without the signature attached to it just yet.
*/
protected function doSign(DOMElement $xml): DOMElement
protected function doSign(Dom\Element $xml): Dom\Element
{
Assert::notNull(
$this->signer,
Expand Down
10 changes: 5 additions & 5 deletions src/XML/alg/DigestMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\SAML2\XML\alg;

use DOMElement;
use Dom;
use SimpleSAML\SAML2\Assert\Assert;
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
use SimpleSAML\XML\ExtendableElementTrait;
Expand Down Expand Up @@ -58,14 +58,14 @@ public function getAlgorithm(): SAMLAnyURIValue
/**
* Convert XML into a DigestMethod
*
* @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
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
* if the mandatory Algorithm-attribute is missing
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
Assert::same($xml->localName, 'DigestMethod', InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, DigestMethod::NS, InvalidDOMElementException::class);
Expand All @@ -80,9 +80,9 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*
* @param \DOMElement|null $parent The element we should append to.
* @param \Dom\Element|null $parent The element we should append to.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
$e->setAttribute('Algorithm', $this->getAlgorithm()->getValue());
Expand Down
10 changes: 5 additions & 5 deletions src/XML/alg/SigningMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\SAML2\XML\alg;

use DOMElement;
use Dom;
use SimpleSAML\SAML2\Assert\Assert;
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
use SimpleSAML\XML\ExtendableElementTrait;
Expand Down Expand Up @@ -84,14 +84,14 @@ public function getMaxKeySize(): ?PositiveIntegerValue
/**
* Convert XML into a SigningMethod
*
* @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
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
* if the supplied argument is missing the Algorithm attribute
*/
public static function fromXML(DOMElement $xml): static
public static function fromXML(Dom\Element $xml): static
{
Assert::same($xml->localName, 'SigningMethod', InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, SigningMethod::NS, InvalidDOMElementException::class);
Expand All @@ -108,9 +108,9 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*
* @param \DOMElement|null $parent The element we should append to.
* @param \Dom\Element|null $parent The element we should append to.
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
Loading
Loading