diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index 54f1d906225cd7abc7445995d0c936259dc5c7fe..8654aac3c62f85566f221018c228ab4613849a8b 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -518,6 +518,9 @@ class SimpleSAML_Metadata_SAMLParser { if (array_key_exists('attributes', $spd)) { $ret['attributes'] = $spd['attributes']; } + if (array_key_exists('attributes.NameFormat', $spd)) { + $ret['attributes.NameFormat'] = $spd['attributes.NameFormat']; + } /* Add name & description. */ if (array_key_exists('name', $spd)) { @@ -667,6 +670,9 @@ class SimpleSAML_Metadata_SAMLParser { if (array_key_exists('attributes', $spd)) { $ret['attributes'] = $spd['attributes']; } + if (array_key_exists('attributes.NameFormat', $spd)) { + $ret['attributes.NameFormat'] = $spd['attributes.NameFormat']; + } /* Add name & description. */ if (array_key_exists('name', $spd)) { @@ -1083,12 +1089,39 @@ class SimpleSAML_Metadata_SAMLParser { $sp['description'][$language] = SimpleSAML_Utilities::getDOMText($child); } + + $format = NULL; $elements = SimpleSAML_Utilities::getDOMChildren($element, 'RequestedAttribute', '@md'); + $sp['attributes'] = array(); foreach($elements AS $child) { $attrname = $child->getAttribute('Name'); - if (!array_key_exists('attributes', $sp)) $sp['attributes'] = array(); $sp['attributes'][] = $attrname; - } + + if ($child->hasAttribute('NameFormat')) { + $attrformat = $child->getAttribute('NameFormat'); + } else { + $attrformat = SAML2_Const::NAMEFORMAT_UNSPECIFIED; + } + + if ($format === NULL) { + $format = $attrformat; + } elseif ($format !== $attrformat) { + $format = SAML2_Const::NAMEFORMAT_UNSPECIFIED; + } + + } + + if (empty($sp['attributes'])) { + /* + * Really an invalid configuration - all AttributeConsumingServices + * should have one or more attributes. + */ + unset($sp['attributes']); + } + + if ($format !== SAML2_Const::NAMEFORMAT_UNSPECIFIED && $format !== NULL) { + $sp['attributes.NameFormat'] = $format; + } }