diff options
-rw-r--r-- | lib/SAML2/Assertion.php | 4 | ||||
-rw-r--r-- | lib/SAML2/Utils.php | 15 | ||||
-rw-r--r-- | lib/SAML2/XML/md/AffiliationDescriptor.php | 2 | ||||
-rw-r--r-- | lib/SAML2/XML/md/AttributeAuthorityDescriptor.php | 4 | ||||
-rw-r--r-- | lib/SAML2/XML/md/AuthnAuthorityDescriptor.php | 2 | ||||
-rw-r--r-- | lib/SAML2/XML/md/IDPSSODescriptor.php | 2 | ||||
-rw-r--r-- | lib/SAML2/XML/md/PDPDescriptor.php | 2 | ||||
-rw-r--r-- | lib/SAML2/XML/md/SSODescriptorType.php | 2 |
8 files changed, 19 insertions, 14 deletions
diff --git a/lib/SAML2/Assertion.php b/lib/SAML2/Assertion.php index b35e5d6..d987fb0 100644 --- a/lib/SAML2/Assertion.php +++ b/lib/SAML2/Assertion.php @@ -321,7 +321,7 @@ class SAML2_Assertion implements SAML2_SignedElement { } switch ($node->localName) { case 'AudienceRestriction': - $audiences = SAML2_Utils::extractStrings($node, './saml_assertion:Audience'); + $audiences = SAML2_Utils::extractStrings($node, SAML2_Const::NS_SAML, 'Audience'); if ($this->validAudiences === NULL) { /* The first (and probably last) AudienceRestriction element. */ $this->validAudiences = $audiences; @@ -401,7 +401,7 @@ class SAML2_Assertion implements SAML2_SignedElement { $this->authnContext = trim($accr[0]->textContent); } - $this->AuthenticatingAuthority = SAML2_Utils::extractStrings($ac, './saml_assertion:AuthenticatingAuthority'); + $this->AuthenticatingAuthority = SAML2_Utils::extractStrings($ac, SAML2_Const::NS_SAML, 'AuthenticatingAuthority'); } diff --git a/lib/SAML2/Utils.php b/lib/SAML2/Utils.php index d952434..0e37acc 100644 --- a/lib/SAML2/Utils.php +++ b/lib/SAML2/Utils.php @@ -458,15 +458,20 @@ class SAML2_Utils { /** * Extract strings from a set of nodes. * - * @param DOMElement $parent The element we should rund the XPath query on. - * @param string $query The XPath query we should use to retrieve the nodes. + * @param DOMElement $parent The element that contains the localized strings. + * @param string $namespaceURI The namespace URI the string elements should have. + * @param string $localName The localName of the string elements. * @return array The string values of the various nodes. */ - public static function extractStrings(DOMElement $parent, $query) { - assert('is_string($query)'); + public static function extractStrings(DOMElement $parent, $namespaceURI, $localName) { + assert('is_string($namespaceURI)'); + assert('is_string($localName)'); $ret = array(); - foreach (self::xpQuery($parent, $query) as $node) { + for ($node = $parent->firstChild; $node !== NULL; $node = $node->nextSibling) { + if ($node->namespaceURI !== $namespaceURI || $node->localName !== $localName) { + continue; + } $ret[] = trim($node->textContent); } diff --git a/lib/SAML2/XML/md/AffiliationDescriptor.php b/lib/SAML2/XML/md/AffiliationDescriptor.php index ad33323..927ad1f 100644 --- a/lib/SAML2/XML/md/AffiliationDescriptor.php +++ b/lib/SAML2/XML/md/AffiliationDescriptor.php @@ -102,7 +102,7 @@ class SAML2_XML_md_AffiliationDescriptor extends SAML2_SignedElementHelper { $this->Extensions = SAML2_XML_md_Extensions::getList($xml); - $this->AffiliateMember = SAML2_Utils::extractStrings($xml, './saml_metadata:AffiliateMember'); + $this->AffiliateMember = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AffiliateMember'); if (empty($this->AffiliateMember)) { throw new Exception('Missing AffiliateMember in AffiliationDescriptor.'); } diff --git a/lib/SAML2/XML/md/AttributeAuthorityDescriptor.php b/lib/SAML2/XML/md/AttributeAuthorityDescriptor.php index bbf9507..8babb28 100644 --- a/lib/SAML2/XML/md/AttributeAuthorityDescriptor.php +++ b/lib/SAML2/XML/md/AttributeAuthorityDescriptor.php @@ -81,9 +81,9 @@ class SAML2_XML_md_AttributeAuthorityDescriptor extends SAML2_XML_md_RoleDescrip $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($airs); } - $this->NameIDFormat = SAML2_Utils::extractStrings($xml, './saml_metadata:NameIDFormat'); + $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat'); - $this->AttributeProfile = SAML2_Utils::extractStrings($xml, './saml_metadata:AttributeProfile'); + $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AttributeProfile'); foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) { $this->Attribute[] = new SAML2_XML_saml_Attribute($a); diff --git a/lib/SAML2/XML/md/AuthnAuthorityDescriptor.php b/lib/SAML2/XML/md/AuthnAuthorityDescriptor.php index 9a05982..8ab4c88 100644 --- a/lib/SAML2/XML/md/AuthnAuthorityDescriptor.php +++ b/lib/SAML2/XML/md/AuthnAuthorityDescriptor.php @@ -61,7 +61,7 @@ class SAML2_XML_md_AuthnAuthorityDescriptor extends SAML2_XML_md_RoleDescriptor $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($airs); } - $this->NameIDFormat = SAML2_Utils::extractStrings($xml, './saml_metadata:NameIDFormat'); + $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat'); } diff --git a/lib/SAML2/XML/md/IDPSSODescriptor.php b/lib/SAML2/XML/md/IDPSSODescriptor.php index 67116ce..99190fa 100644 --- a/lib/SAML2/XML/md/IDPSSODescriptor.php +++ b/lib/SAML2/XML/md/IDPSSODescriptor.php @@ -92,7 +92,7 @@ class SAML2_XML_md_IDPSSODescriptor extends SAML2_XML_md_SSODescriptorType { $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($airs); } - $this->AttributeProfile = SAML2_Utils::extractStrings($xml, './saml_metadata:AttributeProfile'); + $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AttributeProfile'); foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) { $this->Attribute[] = new SAML2_XML_saml_Attribute($a); diff --git a/lib/SAML2/XML/md/PDPDescriptor.php b/lib/SAML2/XML/md/PDPDescriptor.php index e2765fd..677d5f6 100644 --- a/lib/SAML2/XML/md/PDPDescriptor.php +++ b/lib/SAML2/XML/md/PDPDescriptor.php @@ -61,7 +61,7 @@ class SAML2_XML_md_PDPDescriptor extends SAML2_XML_md_RoleDescriptor { $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($airs); } - $this->NameIDFormat = SAML2_Utils::extractStrings($xml, './saml_metadata:NameIDFormat'); + $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat'); } diff --git a/lib/SAML2/XML/md/SSODescriptorType.php b/lib/SAML2/XML/md/SSODescriptorType.php index 4ba5f5a..bdb8e96 100644 --- a/lib/SAML2/XML/md/SSODescriptorType.php +++ b/lib/SAML2/XML/md/SSODescriptorType.php @@ -75,7 +75,7 @@ abstract class SAML2_XML_md_SSODescriptorType extends SAML2_XML_md_RoleDescripto $this->ManageNameIDService[] = new SAML2_XML_md_EndpointType($ep); } - $this->NameIDFormat = SAML2_Utils::extractStrings($xml, './saml_metadata:NameIDFormat'); + $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat'); } |