From d316beeb70efef40916659b9563f9763e27eb660 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaime=20P=C3=A9rez=20Crespo?= <jaime.perez@uninett.no>
Date: Tue, 9 Oct 2012 10:31:13 +0000
Subject: [PATCH] Fixed a bug on ArtifactResolutionService introduced by a
 previous commit on new SHA signatures support.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3186 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/saml/lib/Message.php                | 4 ++--
 www/saml2/idp/ArtifactResolutionService.php | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/saml/lib/Message.php b/modules/saml/lib/Message.php
index 64c06da13..3e0c7b51c 100644
--- a/modules/saml/lib/Message.php
+++ b/modules/saml/lib/Message.php
@@ -11,13 +11,13 @@
 class sspmod_saml_Message {
 
 	/**
-	 * Add signature key and and senders certificate to an element (Message or Assertion).
+	 * Add signature key and sender certificate to an element (Message or Assertion).
 	 *
 	 * @param SimpleSAML_Configuration $srcMetadata  The metadata of the sender.
 	 * @param SimpleSAML_Configuration $dstMetadata  The metadata of the recipient.
 	 * @param SAML2_Message $element  The element we should add the data to.
 	 */
-	public static function addSign(SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata = NULL, SAML2_SignedElement $element) {
+	public static function addSign(SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata, SAML2_SignedElement $element) {
 
 		$keyArray = SimpleSAML_Utilities::loadPrivateKey($srcMetadata, TRUE);
 		$certArray = SimpleSAML_Utilities::loadPublicKey($srcMetadata, FALSE);
diff --git a/www/saml2/idp/ArtifactResolutionService.php b/www/saml2/idp/ArtifactResolutionService.php
index 3b674b315..cf3439251 100644
--- a/www/saml2/idp/ArtifactResolutionService.php
+++ b/www/saml2/idp/ArtifactResolutionService.php
@@ -34,6 +34,10 @@ $request = $binding->receive();
 if (!($request instanceof SAML2_ArtifactResolve)) {
 	throw new Exception('Message received on ArtifactResolutionService wasn\'t a ArtifactResolve request.');
 }
+
+$issuer = $request->getIssuer();
+$spMetadata = $metadata->getMetadataConfig($issuer, 'saml20-sp-remote');
+
 $artifact = $request->getArtifact();
 
 $responseData = $store->get('artifact', $artifact);
@@ -51,5 +55,5 @@ $artifactResponse = new SAML2_ArtifactResponse();
 $artifactResponse->setIssuer($idpEntityId);
 $artifactResponse->setInResponseTo($request->getId());
 $artifactResponse->setAny($responseXML);
-sspmod_saml_Message::addSign($idpMetadata, NULL, $artifactResponse);
+sspmod_saml_Message::addSign($idpMetadata, $spMetadata, $artifactResponse);
 $binding->send($artifactResponse);
-- 
GitLab