From acb1ef25747872de3bf9868e4f4f5b5053846c50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Fri, 1 Feb 2008 13:41:59 +0000
Subject: [PATCH] Using AssertionConsumerService instead of shire to better
 match saml2 metadata. also making audience optional, and make some error
 proofing.

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

diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
index 9eeae6137..9186ad580 100644
--- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
+++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php
@@ -271,9 +271,11 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 
 		$issuer = $idpentityid;
 
-		$shire = $spmd['shire'];
-		$audience = $spmd['audience'];
-		$base64 = $spmd['base64attributes'];
+		if (!array_key_exists('AssertionConsumerService', $spmd)) throw new Exception('Could not find [AssertionConsumerService] in Shib 1.3 Service Provider remote metadata.');
+		
+		$shire = $spmd['AssertionConsumerService'];
+		$audience = isset($spmd['audience']) ? $spmd['audience'] : $spentityid;
+		$base64 = isset($spmd['base64attributes']) ? $spmd['base64attributes'] : false;
 		
 		$encodedattributes = '';
 		
@@ -303,8 +305,7 @@ class SimpleSAML_XML_Shib13_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
     MajorVersion="1" MinorVersion="1"
     Recipient="' . htmlspecialchars($shire) . '"
     ResponseID="' . $id . '">
-
-<Status>
+	<Status>
         <StatusCode Value="samlp:Success">
             <StatusCode xmlns:code="urn:geant2:edugain:protocol" Value="code:Accepted"/>
         </StatusCode>
-- 
GitLab