From 54f02a5b9f1b9cb1f1e77dddf2ee5513d19cf76d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Mon, 7 Jan 2008 07:11:55 +0000
Subject: [PATCH] base64 decoding of attributes in shib13 sp

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@134 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/XML/Shib13/AuthnResponse.php | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
index e56bd9396..143ba3a83 100644
--- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
+++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
@@ -193,6 +193,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 
 
 		$md = $this->metadata->getMetadata($this->getIssuer(), 'shib13-idp-remote');
+		$base64 = isset($md['base64attributes']) ? $md['base64attributes'] : false;
 		
 		//$base64 = isset($md['base64attributes']) ? $md['base64attributes'] : false;
 		
@@ -251,7 +252,18 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 						$values = array();
 						
 						// Traverse Values
-						foreach ($attribute->AttributeValue AS $val) {
+						foreach ($attribute->AttributeValue AS $newvalue) {
+						
+							if ($base64) {
+								$encodedvalues = explode('_', $newvalue);
+								foreach($encodedvalues AS $v) {
+									$values[] = base64_decode($v);
+								}
+							} else {
+
+								$values[] = $newvalue;
+							}
+						
 							$values[] = (string) $val;
 						}
 						
-- 
GitLab