diff --git a/lib/SimpleSAML/Bindings/Shib13/Artifact.php b/lib/SimpleSAML/Bindings/Shib13/Artifact.php index 9691dc4ebac6a47fcfe682944bb5cdc3e103148f..df23ffd9caa7dc218e07701ba0eae9fd70fa2836 100644 --- a/lib/SimpleSAML/Bindings/Shib13/Artifact.php +++ b/lib/SimpleSAML/Bindings/Shib13/Artifact.php @@ -96,7 +96,7 @@ class Artifact } $soapEnvelope = $doc->firstChild; - if (!XML::isDOMElementOfType($soapEnvelope, 'Envelope', 'http://schemas.xmlsoap.org/soap/envelope/')) { + if (!XML::isDOMNodeOfType($soapEnvelope, 'Envelope', 'http://schemas.xmlsoap.org/soap/envelope/')) { throw new \SimpleSAML_Error_Exception('Expected artifact response to contain a <soap:Envelope> element.'); } diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index 7acccd27b25f4a915c784f62aa4755cbeaa89cc4..bd8886e6808a84d4178c4bbead984d2ed170ca3d 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -362,11 +362,9 @@ class SimpleSAML_Metadata_SAMLParser throw new Exception('Document was empty.'); } - assert('$element instanceof DOMElement'); - - if (SimpleSAML\Utils\XML::isDOMElementOfType($element, 'EntityDescriptor', '@md') === true) { + if (SimpleSAML\Utils\XML::isDOMNodeOfType($element, 'EntityDescriptor', '@md') === true) { return self::processDescriptorsElement(new \SAML2\XML\md\EntityDescriptor($element)); - } elseif (SimpleSAML\Utils\XML::isDOMElementOfType($element, 'EntitiesDescriptor', '@md') === true) { + } elseif (SimpleSAML\Utils\XML::isDOMNodeOfType($element, 'EntitiesDescriptor', '@md') === true) { return self::processDescriptorsElement(new \SAML2\XML\md\EntitiesDescriptor($element)); } else { throw new Exception('Unexpected root node: ['.$element->namespaceURI.']:'.$element->localName); @@ -1420,7 +1418,7 @@ class SimpleSAML_Metadata_SAMLParser throw new Exception('Failed to load SAML metadata from empty XML document.'); } - if (SimpleSAML\Utils\XML::isDOMElementOfType($ed, 'EntityDescriptor', '@md') === false) { + if (SimpleSAML\Utils\XML::isDOMNodeOfType($ed, 'EntityDescriptor', '@md') === false) { throw new Exception('Expected first element in the metadata document to be an EntityDescriptor element.'); } diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index fd8f04e78b52b3f361a2cf42703357fd822c81eb..46be6ca60e86bb1280f3c06ccee38ee3cb346db2 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -297,12 +297,12 @@ class SimpleSAML_Utilities /** - * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::isDOMElementOfType() + * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::isDOMNodeOfType() * instead. */ public static function isDOMElementOfType(DOMNode $element, $name, $nsURI) { - return SimpleSAML\Utils\XML::isDOMElementOfType($element, $name, $nsURI); + return SimpleSAML\Utils\XML::isDOMNodeOfType($element, $name, $nsURI); } diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index 8a8acd7daf5bd0051157fa3b7b92c39f1301acde..d3c6dd77347bffd35ad0267fa93fdca7c30ebc9e 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -259,20 +259,20 @@ class XML * This function finds direct descendants of a DOM element with the specified * localName and namespace. They are returned in an array. * - * This function accepts the same shortcuts for namespaces as the isDOMElementOfType function. + * This function accepts the same shortcuts for namespaces as the isDOMNodeOfType function. * - * @param \DOMElement $element The element we should look in. - * @param string $localName The name the element should have. - * @param string $namespaceURI The namespace the element should have. + * @param \DOMNode $element The element we should look in. + * @param string $localName The name the element should have. + * @param string $namespaceURI The namespace the element should have. * - * @return array Array with the matching elements in the order they are found. An empty array is + * @return array Array with the matching elements in the order they are found. An empty array is * returned if no elements match. * @throws \InvalidArgumentException If $element is not an instance of DOMElement, $localName is not a string or * $namespaceURI is not a string. */ - public static function getDOMChildren(\DOMElement $element, $localName, $namespaceURI) + public static function getDOMChildren(\DOMNode $element, $localName, $namespaceURI) { - if (!($element instanceof \DOMElement) || !is_string($localName) || !is_string($namespaceURI)) { + if (!is_string($localName) || !is_string($namespaceURI)) { throw new \InvalidArgumentException('Invalid input parameters.'); } @@ -286,7 +286,7 @@ class XML continue; } - if (self::isDOMElementOfType($child, $localName, $namespaceURI) === true) { + if (self::isDOMNodeOfType($child, $localName, $namespaceURI) === true) { $ret[] = $child; } } @@ -350,9 +350,9 @@ class XML * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function isDOMElementOfType(\DOMNode $element, $name, $nsURI) + public static function isDOMNodeOfType(\DOMNode $element, $name, $nsURI) { - if (!($element instanceof \DOMElement) || !is_string($name) || !is_string($nsURI) || strlen($nsURI) === 0) { + if (!is_string($name) || !is_string($nsURI) || strlen($nsURI) === 0) { // most likely a comment-node return false; }