From db981bc52298f28f95526c88ba80dcc998ed6b39 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Tue, 16 Nov 2010 14:32:55 +0000
Subject: [PATCH] consent: Use $state['saml:sp:IdP'] instead of
 $session->getIdP().

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2652 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/consent/lib/Auth/Process/Consent.php | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php
index d497d4030..b3df73e8c 100644
--- a/modules/consent/lib/Auth/Process/Consent.php
+++ b/modules/consent/lib/Auth/Process/Consent.php
@@ -149,11 +149,15 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt
 		$session = SimpleSAML_Session::getInstance(); 
 		$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
-		/* If the consent module is active on a bridge $session->getIdP() will contain
-		 * an entry id for the remote IdP. If $session->getIdP() is NULL, then the
+		/* If the consent module is active on a bridge $state['saml:sp:IdP'] will contain
+		 * an entry id for the remote IdP. If not, then the
 		 * consent module is active on a local IdP and nothing needs to be done.
 		 */
-		if($session->getIdP() != null) {
+		if(isset($state['saml:sp:IdP'])) {
+			$idpmeta = $metadata->getMetaData($state['saml:sp:IdP'], 'saml20-idp-remote');
+			$state['Source'] = $idpmeta;
+		} elseif($session->getIdP() !== NULL) {
+			/* For backwards compatibility. TODO: Remove in version 1.8. */
 			$idpmeta = $metadata->getMetaData($session->getIdP(), 'saml20-idp-remote');
 			$state['Source'] = $idpmeta;
 		}
-- 
GitLab