From 8fcaa27a5f46bb6568a69838dc0b694478265d8f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Tue, 29 Jan 2008 19:05:49 +0000
Subject: [PATCH] Adding support for multivalued attributes in the Shib 1.3 IdP

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@217 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/XML/Shib13/AuthnResponse.php | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
index 3be04c8ee..138ce35e2 100644
--- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
+++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
@@ -311,7 +311,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 				</Subject>';
 				
 			foreach ($attributes AS $name => $value) {
-				$encodedattributes .= $this->enc_attribute($name, $value[0], $base64);
+				$encodedattributes .= $this->enc_attribute($name, $value, $base64);
 			}
 			
 			$encodedattributes .= '</AttributeStatement>';
@@ -364,11 +364,14 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 	
 
 
-	private function enc_attribute($name, $value, $base64 = false) {
-		return '<Attribute AttributeName="' . htmlspecialchars($name) . '"
-			AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri">
-		<AttributeValue>' . ($base64 ? base64_encode($value) : htmlspecialchars($value) ) . '</AttributeValue>
-	</Attribute>';
+	private function enc_attribute($name, $values, $base64 = false) {
+		$attr = '<Attribute AttributeName="' . htmlspecialchars($name) . '" AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri">';
+		foreach ($values AS $value) {
+			$attr .= '<AttributeValue>' . ($base64 ? base64_encode($value) : htmlspecialchars($value) ) . '</AttributeValue>';
+		}
+		$attr .= '</Attribute>';
+		
+		return $attr;
 	}	
 	
 }
-- 
GitLab