From ae3743be543430b0afbe7accf48375dd8ae75d27 Mon Sep 17 00:00:00 2001 From: Jaime Perez <jaime.perez@uninett.no> Date: Wed, 18 Jun 2014 16:49:27 +0200 Subject: [PATCH] Give absolute priority to mdui:DisplayName for the 'name' field when parsing XML metadata. Solves #54. --- lib/SimpleSAML/Metadata/SAMLParser.php | 11 ++++++++++- templates/selectidp-dropdown.php | 4 ++++ templates/selectidp-links.php | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index e7a50d517..5545dc912 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -384,7 +384,6 @@ class SimpleSAML_Metadata_SAMLParser { * Add organizational metadata */ if (!empty($this->organizationName)) { - $ret['name'] = $this->organizationName; $ret['description'] = $this->organizationName; $ret['OrganizationName'] = $this->organizationName; } @@ -636,6 +635,11 @@ class SimpleSAML_Metadata_SAMLParser { /* Add extensions. */ $this->addExtensions($ret, $spd); + // prioritize mdui:DisplayName as the name if available + if (isset($ret['UIInfo']) && isset($ret['UIInfo']['DisplayName'])) { + $ret['name'] = $ret['UIInfo']['DisplayName']; + } + return $ret; } @@ -700,6 +704,11 @@ class SimpleSAML_Metadata_SAMLParser { /* Add extensions. */ $this->addExtensions($ret, $idp); + // prioritize mdui:DisplayName as the name if available + if (isset($ret['UIInfo']) && isset($ret['UIInfo']['DisplayName'])) { + $ret['name'] = $ret['UIInfo']['DisplayName']; + } + return $ret; } diff --git a/templates/selectidp-dropdown.php b/templates/selectidp-dropdown.php index 6f54bbf52..2ac0ef87b 100644 --- a/templates/selectidp-dropdown.php +++ b/templates/selectidp-dropdown.php @@ -11,6 +11,10 @@ $this->includeAtTemplateBase('includes/header.php'); foreach ($this->data['idplist'] AS $idpentry) { if (isset($idpentry['UIInfo']['DisplayName'])) { + /* TODO: remove this branch, If ['UIInfo']['DisplayName'] is available, it will get through to 'name' in the + * metadata parsed with SSP >= 1.13.0, so this code is no longer necessary. Keep it now to avoid breaking + * metadata parsed with previous versions. + */ $this->includeInlineTranslation('idpname_' . $idpentry['entityid'], $idpentry['UIInfo']['DisplayName']); } elseif (isset($idpentry['name'])) { $this->includeInlineTranslation('idpname_' . $idpentry['entityid'], $idpentry['name']); diff --git a/templates/selectidp-links.php b/templates/selectidp-links.php index 076352512..83a99379f 100644 --- a/templates/selectidp-links.php +++ b/templates/selectidp-links.php @@ -11,6 +11,10 @@ $this->includeAtTemplateBase('includes/header.php'); foreach ($this->data['idplist'] AS $idpentry) { if (isset($idpentry['UIInfo']['DisplayName'])) { + /* TODO: remove this branch, If ['UIInfo']['DisplayName'] is available, it will get through to 'name' in the + * metadata parsed with SSP >= 1.13.0, so this code is no longer necessary. Keep it now to avoid breaking + * metadata parsed with previous versions. + */ $this->includeInlineTranslation('idpname_' . $idpentry['entityid'], $idpentry['UIInfo']['DisplayName']); } elseif (isset($idpentry['name'])) { $this->includeInlineTranslation('idpname_' . $idpentry['entityid'], $idpentry['name']); -- GitLab