Generate the login headers

@param \Psr\Http\Message\ServerRequestInterface $request Request object.
@return array Headers for logging in.
548203
protected function loginHeaders(ServerRequestInterface $request)
    {
        $server = $request->getServerParams();
        $realm = $this->getConfig('realm') ?: $server['SERVER_NAME'];

        return ['WWW-Authenticate' => sprintf('Basic realm="%s"', $realm)];
    }
523494
private function userData(ServerRequestInterface $request): array
    {
        $data = [];

        foreach (self::DEFAULT_DATA as $key => $default) {
            $data[$key] = $request->getParsedBody()[$key] ?? $default;
        }

        return $data;
    }
1126436
public function toArray($request)
    {
        return [
            'code'       => $this->code,
            'i18n'       => $this->i18n,
            'is_enabled' => (bool) $this->is_enabled,
            'is_default' => (bool) $this->is_default,
        ];
    }
516728
public function getCredentials(Request $request)
    {
        $jwt = $request->query->get('jwt');
        if (!$jwt && $request->headers->has('authorization')) {
            $authorizationHeaderArray = \explode(' ', $request->headers->get('authorization'));
            if (\count($authorizationHeaderArray) > 1) {
                $jwt = $authorizationHeaderArray[1];
            }
        }

        if (!$jwt && $this->devTenant && ($this->kernel->getEnvironment() === 'dev')) {
            $tenant = $this->em->getRepository($this->tenantEntityClass)->find($this->devTenant);
            if ($tenant === null) {
                throw new \RuntimeException(\sprintf('Cant find tenant with id %s - please set atlassian_connect.dev_tenant to false to disable dedicated dev tenant OR add valid id', $this->devTenant));
            }

            $jwt = JWT::encode([
                'iss' => $tenant->getClientKey(),
                'iat' => \time(),
                'exp' => \strtotime('+1 day'),
                'qsh' => QSHGenerator::generate($request->getRequestUri(), 'GET'),
                'sub' => 'admin',
            ], $tenant->getSharedSecret());
        }

        if (!$jwt) {
            return null;
        }

        return ['jwt' => $jwt];
    }
154492
private function input(ServerRequestInterface $request): array
    {
        if (! is_null($this->parser)) {

            $input = ($this->parser)($request);

            if (is_array($input)) {

                return $input;

            }

            throw new InputTypeException($input);

        }

        return array_merge(
            $request->getAttributes(),
            $request->getQueryParams(),
            $request->getParsedBody(),
            $request->getUploadedFiles()
        );
    }
453265
public function loginHeaders(ServerRequest $request)
    {
        $realm = $this->getConfig('realm') ?: $request->getEnv('SERVER_NAME');

        return [
            'WWW-Authenticate' => sprintf('Basic realm="%s"', $realm)
        ];
    }
921050
protected function parseRequestServer($request)
    {
        $server = [];

        foreach (($request->server ?? []) as $name => $value) {
            $server[strtoupper($name)] = $value;
        }

        foreach (($request->header ?? []) as $name => $value) {
            $server['HTTP_'.strtoupper($name)] = $value;
        }

        return $server;
    }
738305
protected function createHeaders(RequestInterface $request, array $options)
	{
		$headers = [];
		$body = $request->getBody();
		$size = $body->getSize();

		foreach ($request->getHeaders() as $header => $values)
		{
			foreach ((array) $values as $value)
			{
				$headers[] = sprintf('%s: %s', $header, $value);
			}
		}

		if ( ! $request->hasHeader('Transfer-Encoding') && $size === null)
		{
			$headers[] = 'Transfer-Encoding: chunked';
		}

		if ( ! $request->hasHeader('Expect') && in_array($request->getMethod(), ['POST', 'PUT']))
		{
			if ($request->getProtocolVersion() < 2.0 && ! $body->isSeekable() || $size === null || $size > 1048576)
			{
				$headers[] = 'Expect: 100-Continue';
			}
			else
			{
				$headers[] = 'Expect: ';
			}
		}

		return $headers;
	}
1156285
protected function getParametersToSign(RequestInterface $request)
    {
        $params         = $this->getOAuthParameters($request);

        if ($request->getHeader('Content-Type') === 'application/x-www-form-urlencoded') {
            $params = array_merge($params, $this->getContentAsParameters($request));
        }

        return $params;
    }
687187
protected function parseRequest(ServerRequestInterface $request): array
    {
        $method = $request->getMethod();
        if (!\in_array($method, ['PUT', 'POST', 'PATCH'])) {
            throw new \RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
        }

        $body = $request->getParsedBody();
        $data = isset($body['data']) ? $this->decodeData($body['data']) : null;

        $flash = $this->getFlash();
        /*
        if (null !== $data) {
            $flash->setData($data);
            $flash->save();
        }
        */

        $blueprint = $this->getBlueprint();
        $includeOriginal = (bool)($blueprint->form()['images']['original'] ?? null);
        $files = $flash->getFilesByFields($includeOriginal);

        $data = $blueprint->processForm($data ?? [], $body['toggleable_data'] ?? []);

        return [
            $data,
            $files ?? []
        ];
    }
470720
protected function getRequestBody(ServerRequestInterface $request) : string
    {
        if ($decryptedBody = $request->getAttribute('ncryptf-decrypted-body', false)) {
            return $decryptedBody;
        }

        return $request->getBody()->getContents();
    }
293659
private function getAuthenticationHeaders(HttpRequest $request) {
		$timestamp = time();
		$version = '1';
		$path = $request->getPath();
		$securedData = $version . '|' . $this->userId . '|' . $timestamp . '|' . $request->getMethod() . '|' . $path;

		$headers = array();
		$headers['x-mac-version'] = $version;
		$headers['x-mac-userid'] = $this->userId;
		$headers['x-mac-timestamp'] = $timestamp;
		$headers['x-mac-value'] = $this->calculateHmac($securedData);
		return $headers;
	}
500355
public function cookies($request)
    {
        $headers = $response->headers();
        if (!isset($headers['Set-Cookie'])) {
            return [];
        }
        $setCookies = [];
        foreach ($headers['Set-Cookie'] as $setCookieHeader) {
            $setCookie = Cookie::fromString($setCookieHeader);
            if (!$setCookie->domain()) {
                $setCookie->domain($request->hostname());
            }
            if (strpos($setCookie->path(), '/') !== 0) {
                $setCookie->path($this->_pathFrom($request));
            }
            $setCookies[] = $setCookie;
        }
        return $setCookies;
    }
564062
protected function parseBody(ServerRequestInterface $request): array
    {
        $body = [];
        parse_str($request->getBody()->getContents(), $body);

        return $body;
    }
458003
private function getProxiedIp(ServerRequestInterface $request): ?string
    {
        foreach ($this->proxyHeaders as $name) {
            if ($request->hasHeader($name)) {
                $ip = self::getHeaderIp($request->getHeaderLine($name));
                if ($ip !== null) {
                    return $ip;
                }
            }
        }

        return null;
    }
787838
public static function createFromServerRequest(ServerRequestInterface $request)
    {
        $data = $request->getCookieParams();
        $cookies = [];
        foreach ($data as $name => $value) {
            $cookies[] = new Cookie($name, $value);
        }

        return new static($cookies);
    }
893384
public function generateToken(ServerRequest $request)
    {
        if ($request->is('requested')) {
            if ($this->session->check('_Token')) {
                $request = $request->withParam('_Token', $this->session->read('_Token'));
            }

            return $request;
        }
        $token = [
            'allowedControllers' => $this->_config['allowedControllers'],
            'allowedActions' => $this->_config['allowedActions'],
            'unlockedFields' => $this->_config['unlockedFields'],
        ];

        $this->session->write('_Token', $token);

        return $request->withParam('_Token', [
            'unlockedFields' => $token['unlockedFields']
        ]);
    }