From 9437553f5e0bccc3756903fdac349108ba316527 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 20 Oct 2008 08:30:06 +0000
Subject: [PATCH] {SAML20,Shib13}/HTTPPost: Use
 SimpleSAML_Utilities::load{Private,Public}Key

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@932 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Bindings/SAML20/HTTPPost.php | 20 ++++--------------
 lib/SimpleSAML/Bindings/Shib13/HTTPPost.php | 23 ++++-----------------
 2 files changed, 8 insertions(+), 35 deletions(-)

diff --git a/lib/SimpleSAML/Bindings/SAML20/HTTPPost.php b/lib/SimpleSAML/Bindings/SAML20/HTTPPost.php
index 6b1b22b62..83680fa8e 100644
--- a/lib/SimpleSAML/Bindings/SAML20/HTTPPost.php
+++ b/lib/SimpleSAML/Bindings/SAML20/HTTPPost.php
@@ -64,24 +64,12 @@ class SimpleSAML_Bindings_SAML20_HTTPPost {
 		
 		$destination = $spmd['AssertionConsumerService'];
 
-		if(!array_key_exists('privatekey', $idpmd)) {
-			throw new Exception('Missing \'privatekey\' option from metadata for idp: ' . $idpmetaindex);
-		}
-
-		if(!array_key_exists('certificate', $idpmd)) {
-			throw new Exception('Missing \'certificate\' option from metadata for idp: ' . $idpmetaindex);
-		}
-
-		if(array_key_exists('privatekey_pass', $idpmd)) {
-			$passphrase = $idpmd['privatekey_pass'];
-		} else {
-			$passphrase = NULL;
-		}
+		$privatekey = SimpleSAML_Utilities::loadPrivateKey($idpmd, TRUE);
+		$publickey = SimpleSAML_Utilities::loadPublicKey($idpmd, TRUE);
 
 		$signer = new SimpleSAML_XML_Signer(array(
-			'privatekey' => $idpmd['privatekey'],
-			'privatekey_pass' => $passphrase,
-			'certificate' => $idpmd['certificate'],
+			'privatekey_array' => $privatekey,
+			'publickey_array' => $publickey,
 			'id' => 'ID',
 			));
 
diff --git a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php
index ef2f97eb9..9290a6703 100644
--- a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php
+++ b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php
@@ -82,23 +82,9 @@ class SimpleSAML_Bindings_Shib13_HTTPPost {
 			throw new Exception('Claimed ACS (shire) and ACS in SP Metadata do not match. [' . $claimedacs. '] [' . $destination . ']');
 		}
 
+		$privatekey = SimpleSAML_Utilities::loadPrivateKey($idpmd, TRUE);
+		$publickey = SimpleSAML_Utilities::loadPublicKey($idpmd, TRUE);
 
-		if(!array_key_exists('privatekey', $idpmd)) {
-			throw new Exception('Missing \'privatekey\' option from metadata for idp: ' . $idpmetaindex);
-		}
-
-		if(!array_key_exists('certificate', $idpmd)) {
-			throw new Exception('Missing \'certificate\' option from metadata for idp: ' . $idpmetaindex);
-		}
-
-		if(array_key_exists('privatekey_pass', $idpmd)) {
-			$passphrase = $idpmd['privatekey_pass'];
-		} else {
-			$passphrase = NULL;
-		}
-
-
-		
 		$responsedom = new DOMDocument();
 		$responsedom->loadXML(str_replace ("\r", "", $response));
 		
@@ -130,9 +116,8 @@ class SimpleSAML_Bindings_Shib13_HTTPPost {
 		
 		
 		$signer = new SimpleSAML_XML_Signer(array(
-			'privatekey' => $idpmd['privatekey'],
-			'privatekey_pass' => $passphrase,
-			'certificate' => $idpmd['certificate'],
+			'privatekey_array' => $privatekey,
+			'publickey_array' => $publickey,
 			'id' => ($signResponse ? 'ResponseID' : 'AssertionID') ,
 			));
 
-- 
GitLab