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

This commit is contained in:
<bdauvergne@entrouvert.com> 1210147601 +0200 0001-01-01 00:00:00 +00:00
parent b92945e62c
commit 012f3ddbff
2 changed files with 16 additions and 9 deletions

View File

@ -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);

View File

@ -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: