From 012f3ddbff7df936daa0c3d069f179dd413a383c Mon Sep 17 00:00:00 2001 From: Date: Wed, 7 May 2008 10:06:41 +0200 Subject: [PATCH] add a &$code reference parameters to all methods for making a SOAP call it will contain the returned HTTP code, it is useful for FTNotification in ID-FF 1.2 --- include/lassospkit_helper.inc.php | 14 +++++++++----- include/lassospkit_saml_common.inc.php | 11 +++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/lassospkit_helper.inc.php b/include/lassospkit_helper.inc.php index f4d426f..5f5647a 100644 --- a/include/lassospkit_helper.inc.php +++ b/include/lassospkit_helper.inc.php @@ -104,7 +104,7 @@ class LassoSPKitHelper { return 1; } /** Post some datas to given host */ - static function postToHost($host, $path, $data_to_send, $ssl = false) { + static function postToHost($host, $path, $data_to_send, $ssl = false, &$code) { if ($ssl) { $fp = fsockopen('tls://' . $host, 443); } else { @@ -122,11 +122,15 @@ class LassoSPKitHelper { } fclose($fp); + preg_match('/HTTP\/[0-9]+\.[0-9]+ ([0-9]+) .*/', $res, $matches); + + $code = $matches[1]; + $res = substr(strstr($res, "\r\n\r\n"), 4); return $res; } - static public function soapCall($url, $msg) { + static public function soapCall($url, $msg, &$code) { if (strstr($url, 'http://') != $url) return ""; $short_url = substr($url, 7); @@ -136,15 +140,15 @@ class LassoSPKitHelper { $query = implode("/", $url_tokens); $query = "/" . $query; - $response = self::postToHost($host, $query, $msg); + $response = self::postToHost($host, $query, $msg, false, $code); return $response; } /** Make a SOAP call using parameters found in profile. */ - static public function SoapCallWithProfile(LassoProfile $profile) { - return self::soapCall($profile->msgUrl, $profile->msgBody); + static public function SoapCallWithProfile(LassoProfile $profile, &$code) { + return self::soapCall($profile->msgUrl, $profile->msgBody, $code); } static public function notImplemented() { LassoError::throw_on_rc(LASSO_PROFILE_ERROR_UNSUPPORTED_PROFILE); diff --git a/include/lassospkit_saml_common.inc.php b/include/lassospkit_saml_common.inc.php index b122826..c47f7e9 100644 --- a/include/lassospkit_saml_common.inc.php +++ b/include/lassospkit_saml_common.inc.php @@ -104,9 +104,10 @@ class LassoSPKitSAMLCommon { so can potentially take times. */ public function artifactResolve(LassoProfile $profile, $query, $method) { + $code = null; $retIR = $profile->initRequest($query, $method); $retBRM = $profile->buildRequestMsg(); - $content = @LassoSPKitHelper::SoapCallWithProfile($profile); + $content = @LassoSPKitHelper::SoapCallWithProfile($profile, $code); if ($content === FALSE) { lassospkit_errlog("artifactResolve: soapCall result empty"); $content = ""; @@ -131,8 +132,9 @@ class LassoSPKitSAMLCommon { $this->doRedirect($profile); } /** Finish a request with a SOAP transport */ - public function finishSOAPRequest(LassoProfile $profile, &$response) { - $response = LassoSPKitHelper::SoapCallWithProfile($profile); + public function finishSOAPRequest(LassoProfile $profile, &$response, &$code) { + $response = LassoSPKitHelper::SoapCallWithProfile($profile, $code); + lassospkit_errlog("code: $code"); } public function finishResponse(LassoProfile $profile) { @@ -259,6 +261,7 @@ class LassoSPKitSAMLCommon { /* SP initiated */ public function initiateSLO($method = LASSO_HTTP_METHOD_SOAP, $remoteID = null, $relayState = null) { + $code = null; if ($method == null) { $method = LASSO_HTTP_METHOD_SOAP; } @@ -276,7 +279,7 @@ class LassoSPKitSAMLCommon { $this->finishRedirectRequest($logout); break; case LASSO_HTTP_METHOD_SOAP: - $this->finishSOAPRequest($logout, $response); + $this->finishSOAPRequest($logout, $response, $code); $this->processResponseSLO($method, $response, $logout); break; case LASSO_HTTP_METHOD_ARTIFACT_GET: