Resolve request signature.

@param  \Illuminate\Http\Request  $request
@return string

@throws \RuntimeException
346883
protected function resolveRequestSignature($request)
    {
        if ($user = $request->user()) {
            return sha1($user->getAuthIdentifier());
        }

        if ($route = $request->route()) {
            return sha1($route->getDomain().'|'.$request->ip());
        }

        throw new RuntimeException('Unable to generate the request signature. Route unavailable.');
    }
461109
public function execute(RequestInterface $request): RequestInterface
    {
        if ($request->getUri()->getPath() === self::ENDPOINT_INSTALLATION) {
            return $request;
        } else {
            $signature = $this->determineRequestSignature(
                $request->getUri(),
                $request->getMethod(),
                $request->getBody()->getContents(),
                $request->getHeaders()
            );

            return $request->withHeader(self::HEADER_CLIENT_SIGNATURE, $signature);
        }
    }
67620
public function getTokenFromRequest( RequestInterface $request ) {
		if ( $request->get( $this->key ) ) {
			return $request->get( $this->key );
		}

		if ( $request->post( $this->key ) ) {
			return $request->post( $this->key );
		}

		if ( $request->headers( $this->header ) ) {
			return $request->headers( $this->header );
		}

		return '';
	}
71422
public function detect(Request $request)
	{
		if ($request->isMethod('post')) {
			return $request->request->get($this->parameterName);
		}

		return $request->query->get($this->parameterName);
	}
1276654
protected function getRequestToken($request)
    {
        $name = $this->getName();
        $header = 'X-' . ucwords(strtolower($name));
        if ($token = $request->getHeader($header)) {
            return $token;
        }

        // Get from request var
        return $request->requestVar($name);
    }
1125711
protected function resolveDynamicFormRequestErrors(Request $request)
	{
		try {
			$config = app('itemconfig');
			$fieldFactory = app('admin_field_factory');
		} catch (\ReflectionException $e) {
			return null;
		}
		if (array_key_exists('form_request', $config->getOptions())) {
			try {
				$model = $config->getFilledDataModel($request, $fieldFactory->getEditFields(), $request->id);

				$request->merge($model->toArray());
				$formRequestClass = $config->getOption('form_request');
				app($formRequestClass);
			} catch (HttpResponseException $e) {
				//Parses the exceptions thrown by Illuminate\Foundation\Http\FormRequest
				$errorMessages = $e->getResponse()->getContent();
				$errorsArray = json_decode($errorMessages);
				if (!$errorsArray && is_string ( $errorMessages )) {
					return $errorMessages;
				}
				if ($errorsArray) {
					return implode(".", array_dot($errorsArray));
				}
			}
		}
		return null;
	}
680998
public function resolveRequest(Request $request)
    {
        $format = $request->attributes->get(
            'format',
            $request->attributes->get('_format', 'html')
        );
        
        switch ($format) {
            case 'html':
            case 'page':
                return new DefaultHtmlRenderer();
                break;
            case 'api':
            case 'json':
                return new JsonApiRenderer();
                break;
            default:
                throw new InvalidConfigurationException(sprintf("Unsupported response format %s", $format));
        }
    }
1171746
public function sign(Request $request)
  {
    if ($this->isAccessTokenExpired()) {
      $this->acquireAccessToken();
    }

    $this->client->getLogger()->debug('Compute engine service account authentication');

    $request->setRequestHeaders(
        array('Authorization' => 'Bearer ' . $this->token['access_token'])
    );

    return $request;
  }
72427
public function parse(\Request $request)
	{
		$uri = $request->uri->get();
		$method = $request->get_method();

		if ($uri === '' and $this->path === '_root_')
		{
			return $this->matched();
		}

		$result = $this->_parse_search($uri, null, $method);

		if ($result)
		{
			return $result;
		}

		return false;
	}
248902
protected function clientSignature(Request $request): string
    {
        $signature = '';
        foreach (static::SIGNATURE_HEADERS as $header) {
            $signature .= $request->getHeaderLine($header) . ';';
        }

        return hash('sha256', $signature);
    }
1374378
protected function resolveRequestData($request): array
    {
        $params = $request->all();

        if ($request instanceof Request) {
            $routeParams = $request->route()->parameters();
            $params = array_merge($params, $routeParams);
        }

        return $params;
    }
1199000
public function request(string $request): string
    {
        $request  = $this->preRequest($request);
        return $this->send($request);
    }
419093
public function cgetAction(Request $request)
    {
        $webspaceKey = $request->get('webspace');

        /** @var WebspaceManagerInterface $webspaceManager */
        $webspaceManager = $this->get('sulu_core.webspace.webspace_manager');

        $webspace = $webspaceManager->findWebspaceByKey($webspaceKey);

        if ($webspace) {
            $localizations = new CollectionRepresentation($webspace->getAllLocalizations(), 'localizations');
            $view = $this->view($localizations, 200);
        } else {
            $error = new RestException(sprintf('No webspace found for key \'%s\'', $webspaceKey));
            $view = $this->view($error->toArray(), 400);
        }

        return $this->handleView($view);
    }
1061223
protected function signRequest($request)
    {
        $url = $request->getUrl(true);
        $url->getQuery()->add('key', $this->key);

        $request->setUrl($url);
    }
202435
private function getDefaultName(Request $request)
    {
        if (!preg_match('/Bundle\\\\Controller\\\\([\w\\\\]+)Controller:/', $request->attributes->get('_controller'), $match)) {
            throw new \RuntimeException('Unable to determine controller name');
        }

        return strtolower(str_replace('\\', '_', $match[1]));
    }
493800
protected function _use($request) {
		$request->params['command'] = 'model';
		return $this->_namespace($request) . '\\' . $this->_model($request);
	}
787732
protected function getFormat(Request $request)
    {
        $format = $request->getQueryParam('format');
        if (!isset($format)) {
            $format = $this->defaultFormat;
        }

        return $format;
    }