Get the server's "signature" in this moment with all useful debug data

@return array
@throws Convert\Exception
@throws Exception
549303
public static function signatureArray(): array
    {
        $numberOfIncludedFiles = count(get_included_files());
        $serverIP = static::ip();
        $domain = Application::getDomain();

        $signature = [];

        // add the server IP and domain
        $signature[] = "server: {$serverIP} ({$domain})";

        if (PHP_SAPI != 'cli') {
            // this is regular HTTP request
            $method = Request::method();
            $url = Application::getCurrentURL();

            // add info about the current request
            $signature[] = "URL: {$method}={$url}";

            // some end user IP and host stuff
            $endUserIp = Request::ip();
            $endUserHost = Request::host() ?? 'no host detected';
            $proxy = '';

            if ($endUserIp == $endUserHost) {
                $endUserHost = 'no host detected';
            }

            if (Request::hasProxy()) {
                $proxySignature = Request::proxySignature();
                $forwardedFor = Request::httpXForwardedFor();
                $proxy = " via {$proxySignature} for {$forwardedFor}";
            }

            $signature[] = "Origin: {$endUserIp} ({$endUserHost}){$proxy}";

            $uas = Request::userAgent() ?? 'no user agent set';
            $signature[] = "UAS: {$uas}";
        } else {
            $cliName = Application::getCliName();
            $cliScript = Application::getCliScriptPath();

            $signature[] = "CLI Name: {$cliName}";
            $signature[] = "CLI Script: {$cliScript}";

            $params = Cli::getParameters();
            if (count($params) > 0) {
                $signature[] = 'CLI Params: ' . print_r($params, true);
            }
        }

        $serverLoad = static::getServerLoad();
        $signature[] = "Server Load: {$serverLoad}";

        $memory = memory_get_usage();
        $peak = memory_get_peak_usage();
        $allocatedMemory = memory_get_peak_usage(true);
        $memoryLimit = ini_get('memory_limit') ?? -1;

        $memoryKb = round($memory / 1024, 2);
        $peakKb = round($peak / 1024, 2);
        $allocatedMemoryKb = round($allocatedMemory / 1024, 2);

        $limit = '';
        $peakSpent = '';

        if ($memoryLimit > 0) {
            $limitInt = Convert::stringToBytes($memoryLimit);
            $limit = ", limit: {$memoryLimit}";

            $spent = round($peak / $limitInt * 100, 2);
            $peakSpent = " ({$spent}% of limit)";
        }

        $signature[] = "Memory: current: {$memoryKb}kb, peak: {$peakKb}kb{$peakSpent}, allocated: {$allocatedMemoryKb}kb{$limit}";
        $signature[] = "No. of included files: {$numberOfIncludedFiles}";

        return $signature;
    }
381979
protected function convert(\Exception $exception)
    {
        $statusCode = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;
        $file = Path::makeRelative($exception->getFile(), $this->pathResolver->resolve('root'));

        $response = new JsonResponse([
            'success'   => false,
            'code'      => $statusCode,
            'error'     => [
                'type'    => $this->getErrorType($exception),
                'file'    => $file,
                'line'    => $exception->getLine(),
                'message' => $exception->getMessage(),
            ],
        ]);
        $response->setStatusCode($statusCode);

        return $response;
    }
900360
public function getSockName()
    {
        $ret = @socket_getsockname($this->resource, $address, $port);
        if ($ret === false) {
            throw Exception::createFromSocketResource($this->resource);
        }
        return $this->formatAddress($address, $port);
    }
490947
private function getSignatureMethod($request)
    {
        $signature_method = $request instanceof Request
            ? $request->getParameter("oauth_signature_method")
            : null;

        if (!$signature_method) {
            // According to chapter 7 ("Accessing Protected Ressources") the signature-method
            // parameter is required, and we can't just fallback to PLAINTEXT
            throw new Exception('No signature method parameter. This parameter is required');
        }

        if (!in_array(
            $signature_method,
            array_keys($this->signature_methods)
        )) {
            throw new Exception(
                "Signature method '$signature_method' not supported " .
                "try one of the following: " .
                implode(", ", array_keys($this->signature_methods))
            );
        }
        return $this->signature_methods[$signature_method];
    }
1080705
public function validated(): array
    {
        $config = $this->container->make('katsana.manager')->config('webhook');

        $signature = new Signature($config['signature']);
        $header = $this->header('X_SIGNATURE') ?? '';

        if (! $signature->verify($header, $this->getContent(), ($config['threshold'] ?? 3600))) {
            throw new HttpException(419, 'Unable to verify X-Signature.');
        }

        return $this->post();
    }
1278609
public function getRequestSignature()
    {
        if (empty($this->requestSignature)) {

            $string = $this->getApiId()
                . $this->getTimeStamp()
                . $this->getNonce()
                . $this->getDataString();

            $this->requestSignature = hash_hmac('sha1', $string, $this->getService()->getApiSecret());
        }

        return $this->requestSignature;
    }
1269479
public function GetHttpHeaderBasicKey()
    {
        if (is_null($this->_root->Config->ClientId) || strlen($this->_root->Config->ClientId) == 0) {
            throw new Exception('MangoPayApi.Config.ClientId is not set.');
        }
        
        if (is_null($this->_root->Config->ClientPassword) || strlen($this->_root->Config->ClientPassword) == 0) {
            throw new Exception('MangoPayApi.Config.ClientPassword is not set.');
        }
        
        $signature = $this->_root->Config->ClientId . ':' . $this->_root->Config->ClientPassword;
        return base64_encode($signature);
    }
768315
public function toHeader()
    {
        $out = 'Authorization: OAuth realm=""';
        foreach ($this->parameters as $k => $v) {
            if (substr($k, 0, 5) != "oauth") {
                continue;
            }
            if (is_array($v)) {
                throw new Exception('Arrays not supported in headers');
            }
            $out .= ',' .
                Util::urlencodeRfc3986($k) .
                '="' .
                Util::urlencodeRfc3986($v) .
                '"';
        }
        return $out;
    }
1214442
private function processOptions()
    {
        $options = $this->getOptions();

        if(empty($options)) {
            throw new \Exception('Options must be set');
        }

        foreach($options['servers'] as $server) {

            $serverData = explode(self::DELIMITER, $server);

            if (count($serverData) != 2) {
                continue;
            }
            $this->servers[] = array(
                'host'   => $serverData[0],
                'port'   => $serverData[1],
            );
            if(!empty($server['weight'])) {
                $this->servers['weight'] = $server['weight'];
            }
        }

        if(isset($options['compression'])) {
            $this->compression = $options['compression'];
        }

        return $this;
    }
802193
public function getSignatureBase() {
		$fields = array();

		if ($this->eetStatus !== null) {
			$fields[] = $this->eetStatus;
		}
		if ($this->data) {
			$fields[] = $this->data->getSignatureBase();
		}
		if ($this->verificationMode !== null) {
			$fields[] = $this->verificationMode ? 'true' : 'false';
		}
		if ($this->vatId) {
			$fields[] = $this->vatId;
		}
		if ($this->receiptNumber) {
			$fields[] = $this->receiptNumber;
		}
		if ($this->receiptTime) {
			if (isset($this->rawData['receiptTime']) and $this->rawData['receiptTime']) {
				$fields[] = $this->rawData['receiptTime'];
			} else {
				$fields[] = self::formatTime($this->receiptTime);
			}
		}
		if ($this->evidenceMode !== null) {
			$fields[] = $this->evidenceMode;
		}
		if ($this->uuid !== null) {
			$fields[] = $this->uuid;
		}
		if ($this->sendTime) {
			if (isset($this->rawData['sendTime']) and $this->rawData['sendTime']) {
				$fields[] = $this->rawData['sendTime'];
			} else {
				$fields[] = self::formatTime($this->sendTime);
			}
		}
		if ($this->acceptTime) {
			if (isset($this->rawData['acceptTime']) and $this->rawData['acceptTime']) {
				$fields[] = $this->rawData['acceptTime'];
			} else {
				$fields[] = self::formatTime($this->acceptTime);
			}
		}
		if ($this->bkp) {
			$fields[] = $this->bkp;
		}
		if ($this->pkp) {
			$fields[] = $this->pkp;
		}
		if ($this->fik) {
			$fields[] = $this->fik;
		}
		if ($this->rejectTime) {
			if (isset($this->rawData['rejectTime']) and $this->rawData['rejectTime']) {
				$fields[] = $this->rawData['rejectTime'];
			} else {
				$fields[] = self::formatTime($this->rejectTime);
			}
		}
		if ($this->error) {
			$fields[] = $this->error->getSignatureBase();
		}
		if ($this->warning) {
			foreach ($this->warning as $w) {
				$fields[] = $w->getSignatureBase();
			}
		}

		return implode('|', $fields);
	}
686005
public function get_signature_base_string() {
        $parts = array(
            $this->get_normalized_http_method(),
            $this->get_normalized_http_url(),
            $this->get_signable_parameters()
        );

        $parts = OAuthUtil::urlencode_rfc3986($parts);

        return implode('&', $parts);

    }
1361344
public function getException($exception)
    {
        return array(
          'type' => 'exception',
          'tid' => $this->tid,
          'action' => $this->action,
          'method' => $this->method,
          'message' => $exception->getMessage(),
          'where' => $exception->getTraceAsString()
        );
    }
627729
public function getData()
    {
        // The two signatures to compare.
        $signature = $this->getSignature();
        $VPSSignature = strtolower($this->httpRequest->request->get('VPSSignature'));

        if ($VPSSignature !== $signature) {
            throw new InvalidResponseException;
        }

        return $this->httpRequest->request->all();
    }
928950
public function debugLastSoapRequest(): array
    {
        $lastRequestInfo = $this->engine->collectLastRequestInfo();
        return [
            'request' => [
                'headers' => trim($this->soapClient->__getLastRequestHeaders()),
                'body'    => XmlFormatter::format($this->soapClient->__getLastRequest()),
            ],
            'response' => [
                'headers' => trim($this->soapClient->__getLastResponseHeaders()),
                'body'    => XmlFormatter::format($this->soapClient->__getLastResponse()),
            ]
        ];
    }
797461
public function getServerCredentials()
    {
        if (is_null($this->server)) {
            return [];
        }

        return isset($this->servers[$this->server]) ? $this->servers[$this->server] : [];
    }
1074247
public function reportException(\Exception $exception)
    {
        $data = [

            // Request info.
            'method'    => $this->request->getMethod(),
            'ip'        => $this->request->getClientIps(),
            'path'      => $this->request->path(),
            'query'     => array_except($this->request->all(), ['_pjax', '_token', '_method', '_previous_']),
            'body'      => $this->request->getContent(),
            'cookies'   => $this->request->cookies->all(),
            'headers'   => array_except($this->request->headers->all(), 'cookie'),

            // Exception info.
            'exception' => get_class($exception),
            'code'      => $exception->getCode(),
            'file'      => $exception->getFile(),
            'line'      => $exception->getLine(),
            'message'   => $exception->getMessage(),
            'trace'     => $exception->getTraceAsString(),
        ];

        $data = $this->stringify($data);

        try {
            $this->store($data);
        } catch (\Exception $e) {
//            $result = $this->reportException($e);
        }

//        return $result;
    }
1278216
public function getUid()
    {
        if (!array_key_exists(self::UID, $this->passwd)) {
            throw new \Exception('Could not get user id from passwd.');
        }
        return $this->passwd[self::UID];
    }