From e0cb427676f32ca61067146ed5c6f29a16628860 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Tue, 23 Oct 2007 10:57:58 +0000
Subject: [PATCH] Added support for attribute release policy and attributename
 mapping on Shibboleth IdP

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@46 44740490-163a-0410-bde0-09ae8108e29a
---
 www/shib13/idp/SSOService.php | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/www/shib13/idp/SSOService.php b/www/shib13/idp/SSOService.php
index 5a8d2ae46..d3b0986b8 100644
--- a/www/shib13/idp/SSOService.php
+++ b/www/shib13/idp/SSOService.php
@@ -7,6 +7,7 @@ require_once('../../../www/_include.php');
 require_once('SimpleSAML/Utilities.php');
 require_once('SimpleSAML/Session.php');
 require_once('SimpleSAML/XML/MetaDataStore.php');
+require_once('SimpleSAML/XML/AttributeFilter.php');
 require_once('SimpleSAML/XML/Shib13/AuthnRequest.php');
 require_once('SimpleSAML/XML/Shib13/AuthnResponse.php');
 require_once('SimpleSAML/Bindings/Shib13/HTTPPost.php');
@@ -117,9 +118,28 @@ if (!$session->isAuthenticated() ) {
 
 		//$session->setAttribute('eduPersonAffiliation', array('student'));
 
+
+
+		/*
+		 * Filtering attributes.
+		 */
+		$afilter = new SimpleSAML_XML_AttributeFilter($config, $session->getAttributes());
+		if (isset($spmetadata['attributemap'])) {
+			$afilter->namemap($spmetadata['attributemap']);
+		}
+		if (isset($spmetadata['attributes'])) {
+			$afilter->filter($spmetadata['attributes']);
+		}
+		$filteredattributes = $afilter->getAttributes();
+		
+
+
+
+		// Generating a Shibboleth 1.3 Response.
 		$ar = new SimpleSAML_XML_Shib13_AuthnResponse($config, $metadata);
 		$authnResponseXML = $ar->generate($idpentityid, $authnrequest->getIssuer(), 
-			$requestid, null, $session->getAttributes());
+			$requestid, null, $filteredattributes);
+		
 		
 		#echo $authnResponseXML;
 		#print_r($authnResponseXML);
-- 
GitLab