diff --git a/lib/SimpleSAML/Bindings/Shib13/Artifact.php b/lib/SimpleSAML/Bindings/Shib13/Artifact.php index 23f43524bbb5b553a87a306463a2a290e7cb2721..0623bd175b98b24bf5e13517c3bf41cb9d19a5a3 100644 --- a/lib/SimpleSAML/Bindings/Shib13/Artifact.php +++ b/lib/SimpleSAML/Bindings/Shib13/Artifact.php @@ -84,14 +84,14 @@ class SimpleSAML_Bindings_Shib13_Artifact { throw new SimpleSAML_Error_Exception('Expected artifact response to contain a <soap:Envelope> element.'); } - $soapBody = SimpleSAML_Utilities::getDOMChildren($soapEnvelope, 'Body', 'http://schemas.xmlsoap.org/soap/envelope/'); + $soapBody = SimpleSAML\Utils\XML::getDOMChildren($soapEnvelope, 'Body', 'http://schemas.xmlsoap.org/soap/envelope/'); if (count($soapBody) === 0) { throw new SimpleSAML_Error_Exception('Couldn\'t find <soap:Body> in <soap:Envelope>.'); } $soapBody = $soapBody[0]; - $responseElement = SimpleSAML_Utilities::getDOMChildren($soapBody, 'Response', 'urn:oasis:names:tc:SAML:1.0:protocol'); + $responseElement = SimpleSAML\Utils\XML::getDOMChildren($soapBody, 'Response', 'urn:oasis:names:tc:SAML:1.0:protocol'); if (count($responseElement) === 0) { throw new SimpleSAML_Error_Exception('Couldn\'t find <saml1p:Response> in <soap:Body>.'); } diff --git a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php index 7cb87a8f75b567b7f74bcd5da437b779f63da7a6..b105225600bb4777228139cc5705de5cf9f9f77a 100644 --- a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php +++ b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php @@ -67,7 +67,7 @@ class SimpleSAML_Bindings_Shib13_HTTPPost { if ($signResponse) { /* Sign the response - this must be done after encrypting the assertion. */ /* We insert the signature before the saml2p:Status element. */ - $statusElements = SimpleSAML_Utilities::getDOMChildren($responseroot, 'Status', '@saml1p'); + $statusElements = SimpleSAML\Utils\XML::getDOMChildren($responseroot, 'Status', '@saml1p'); assert('count($statusElements) === 1'); $signer->sign($responseroot, $responseroot, $statusElements[0]); diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index 34e962fe16e7733471f6a0ccf817ae3705d3c02a..3b9be1191521aaddb0f71f70afa13d8fc219e0d7 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -1017,7 +1017,7 @@ class SimpleSAML_Metadata_SAMLParser { $name = $attribute->getAttribute('Name'); $values = array_map( array('SimpleSAML\Utils\XML', 'getDOMText'), - SimpleSAML_Utilities::getDOMChildren($attribute, 'AttributeValue', '@saml2') + SimpleSAML\Utils\XML::getDOMChildren($attribute, 'AttributeValue', '@saml2') ); if ($name === 'tags') { diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 10d3cec41b241accd6c06713ba56a8bd63af4e60..94c5fe56c01fe36f0e31d6d029e0a4edc4951913 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -661,37 +661,10 @@ class SimpleSAML_Utilities { /** - * 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. - * - * @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. - * @return array Array with the matching elements in the order they are found. An empty array is - * returned if no elements match. + * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::getDOMChildren() instead. */ public static function getDOMChildren(DOMElement $element, $localName, $namespaceURI) { - assert('is_string($localName)'); - assert('is_string($namespaceURI)'); - - $ret = array(); - - for($i = 0; $i < $element->childNodes->length; $i++) { - $child = $element->childNodes->item($i); - - /* Skip text nodes and comment elements. */ - if($child instanceof DOMText || $child instanceof DOMComment) { - continue; - } - - if(self::isDOMElementOfType($child, $localName, $namespaceURI) === TRUE) { - $ret[] = $child; - } - } - - return $ret; + return SimpleSAML\Utils\XML::getDOMChildren($element, $localName, $namespaceURI); } diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index 5a2b3da3583f46cc1f6a4c61c8817a95f5586aa8..e18d7ff74dfb45f1a61d99d152ecc0ae6e54ffba 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -130,6 +130,43 @@ 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. + * + * @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. + * + * @return array Array with the matching elements in the order they are found. An empty array is + * returned if no elements match. + */ + public static function getDOMChildren(\DOMElement $element, $localName, $namespaceURI) + { + assert('is_string($localName)'); + assert('is_string($namespaceURI)'); + + $ret = array(); + + for ($i = 0; $i < $element->childNodes->length; $i++) { + $child = $element->childNodes->item($i); + + // skip text nodes and comment elements + if ($child instanceof \DOMText || $child instanceof \DOMComment) { + continue; + } + + if (self::isDOMElementOfType($child, $localName, $namespaceURI) === true) { + $ret[] = $child; + } + } + + return $ret; + } + + /** * This function extracts the text from DOMElements which should contain only text content. *