<?php
|
|
namespace App\Http\Controllers\FakeResponder;
|
|
use App\Http\Controllers\Controller;
|
use App\Vola\Services\VolaFakeHTTPResponder\VolaFakeHTTPResponder;
|
use Illuminate\Http\Request;
|
use App\Vola\Classes\Utils;
|
|
class FakeResponder extends Controller
|
{
|
|
public string $cookieFakeSSOName = "CAuthCookie";
|
public string $cookieFakePicassoName = "SSOSESSIONID";
|
public array $headers;
|
public VolaFakeHTTPResponder $VolaFakeSSO;
|
|
function __construct()
|
{
|
$this->VolaFakeSSO = new VolaFakeHTTPResponder();
|
$this->headers = [
|
"Content-Type" => 'text/xml',
|
];
|
if (config('custom.compressed_responses',false) === TRUE) {
|
$this->headers['content-encoding'] = 'gzip';
|
}
|
}
|
|
public function manageLegacyRequest(Request $request)
|
{
|
$this->logReceivedRequest($request);
|
if (isset($_COOKIE[$this->cookieFakeSSOName])) {
|
$profile = intval(str_replace("xno:", "", $_COOKIE[$this->cookieFakeSSOName]));
|
$responseContent = $this->VolaFakeSSO->getResponses($request, $profile);
|
|
$this->logProcessedRequest($request, $responseContent, "SSO Legacy");
|
$responseContent = $this->compressIfRequested($request, $responseContent);
|
|
return response($responseContent, 200, $this->headers);
|
|
} else {
|
$this->logRejectedRequest($request);
|
return response('No cookie, no logged', 400, $this->headers);
|
}
|
}
|
|
public function managePicassoRequest(Request $request)
|
{
|
$this->logReceivedRequest($request);
|
if (isset($_COOKIE[$this->cookieFakePicassoName])) {
|
$profile = intval(str_replace("xno:", "", $_COOKIE[$this->cookieFakePicassoName]));
|
$responseContent = $this->VolaFakeSSO->getResponses($request, $profile, true);
|
|
$this->logProcessedRequest($request, $responseContent, "Picasso");
|
$responseContent = $this->compressIfRequested($request, $responseContent);
|
|
return response($responseContent, 200, $this->headers);
|
} else {
|
$this->logRejectedRequest($request);
|
return response('No cookie no logged', 400, $this->headers);
|
}
|
}
|
|
}
|