From 288c91c40af8f6ffd7badec1c1ccdcf84f5910e1 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 31 Jan 2011 09:28:21 +0000
Subject: [PATCH] SAMLBuilder: Fix support for array NameIDFormat everywhere.

Thanks to Serdar Yigit for reporting this bug!

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2729 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Metadata/SAMLBuilder.php | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php
index bc06cd528..c15cbca1a 100644
--- a/lib/SimpleSAML/Metadata/SAMLBuilder.php
+++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php
@@ -316,9 +316,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 
 		$e->SingleLogoutService = self::createEndpoints($metadata->getEndpoints('SingleLogoutService'), FALSE);
 
-		if ($metadata->hasValue('NameIDFormat')) {
-			$e->NameIDFormat[] = $metadata->getString('NameIDFormat');
-		}
+		$e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
 
 		$endpoints = $metadata->getEndpoints('AssertionConsumerService');
 		foreach ($metadata->getArrayizeString('AssertionConsumerService.artifact', array()) as $acs) {
@@ -371,9 +369,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 
 		$e->SingleLogoutService = self::createEndpoints($metadata->getEndpoints('SingleLogoutService'), FALSE);
 
-		if ($metadata->hasValue('NameIDFormat')) {
-			$e->NameIDFormat[] = $metadata->getString('NameIDFormat');
-		}
+		$e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
 
 		$e->SingleSignOnService = self::createEndpoints($metadata->getEndpoints('SingleSignOnService'), FALSE);
 
@@ -405,9 +401,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 
 		$this->addCertificate($e, $metadata);
 
-		if ($metadata->hasValue('NameIDFormat')) {
-			$e->NameIDFormat[] = $metadata->getString('NameIDFormat');
-		}
+		$e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
 
 		$endpoints = $metadata->getEndpoints('AssertionConsumerService');
 		foreach ($metadata->getArrayizeString('AssertionConsumerService.artifact', array()) as $acs) {
@@ -442,9 +436,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 
 		$this->addCertificate($e, $metadata);
 
-		if ($metadata->hasValue('NameIDFormat')) {
-			$e->NameIDFormat[] = $metadata->getString('NameIDFormat');
-		}
+		$e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
 
 		$e->SingleSignOnService = self::createEndpoints($metadata->getEndpoints('SingleSignOnService'), FALSE);
 
@@ -473,9 +465,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 		$e->AttributeService = self::createEndpoints($metadata->getEndpoints('AttributeService'), FALSE);
 		$e->AssertionIDRequestService = self::createEndpoints($metadata->getEndpoints('AssertionIDRequestService'), FALSE);
 
-		foreach ($metadata->getArray('NameIDFormat', array()) as $format) {
-			$e->NameIDFormat[] = $metadata->getString('NameIDFormat');
-		}
+		$e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
 
 		$this->entityDescriptor->RoleDescriptor[] = $e;
 	}
-- 
GitLab