/**
  * {@inheritdoc}
  */
 public function prepareResponse($redirect_uri, array $data, ResponseInterface &$response)
 {
     $params = empty($data) ? [] : [$this->getName() => $data];
     if (!array_key_exists('fragment', $params)) {
         $params['fragment'] = [];
     }
     $response = $response->withStatus(302)->withHeader('Location', Uri::buildURI($redirect_uri, $params));
 }
 public function getResponseHeaders()
 {
     $data = $this->errorData;
     if (array_key_exists('error_uri', $data)) {
         $data['error_uri'] = urldecode($data['error_uri']);
     }
     $params = [$this->transport_mode => $data];
     return ['Location' => Uri::buildURI($this->redirect_uri, $params)];
 }
 /**
  * @param string $request_uri
  *
  * @throws \OAuth2\Exception\BadRequestExceptionInterface
  */
 private function checkRequestUriPathTraversal($request_uri)
 {
     if (false === Uri::checkUrl($request_uri, false)) {
         throw $this->getExceptionManager()->getBadRequestException(ExceptionManagerInterface::ERROR_INVALID_CLIENT, 'The request Uri must not contain path traversal.');
     }
 }
 /**
  * @param \OAuth2\Endpoint\Authorization $authorization An array with mixed values
  *
  * @throws \OAuth2\Exception\BaseExceptionInterface
  *
  * @return string
  */
 protected function checkRedirectUri(Authorization $authorization)
 {
     $this->checkRedirectUriIfRequired($authorization);
     $redirect_uri = $authorization->getRedirectUri();
     $redirect_uris = $this->getClientRedirectUris($authorization);
     if (empty($redirect_uri) && empty($redirect_uris)) {
         throw $this->getExceptionManager()->getException(ExceptionManagerInterface::BAD_REQUEST, ExceptionManagerInterface::INVALID_REQUEST, 'The "redirect_uri" parameter is missing. Add "redirect_uri" parameter or store redirect URIs to your client');
     }
     if (!empty($redirect_uri) && !empty($redirect_uris) && false === Uri::isRedirectUriAllowed($redirect_uri, $redirect_uris)) {
         throw $this->getExceptionManager()->getException(ExceptionManagerInterface::BAD_REQUEST, ExceptionManagerInterface::INVALID_REQUEST, 'The specified redirect URI is not valid');
     }
     if (!empty($redirect_uri)) {
         return $redirect_uri;
     }
     return $redirect_uris[0];
 }
 /**
  * {@inheritdoc}
  */
 public function prepareResponse($redirect_uri, array $data, ResponseInterface &$response)
 {
     $params = empty($data) ? [] : [$this->getName() => $data];
     $response = $response->withStatus(302)->withHeader('Location', Uri::buildUri($redirect_uri, $params));
 }
 /**
  * @param \OAuth2\Client\ClientInterface $client
  * @param string                         $redirect_uri
  * @param array                          $parameters
  */
 public function checkRedirectUriForTheClient(ClientInterface $client, $redirect_uri, array $parameters)
 {
     $client_redirect_uris = $this->getClientRedirectUris($client, $parameters);
     Assertion::false(!empty($client_redirect_uris) && false === Uri::isRedirectUriAllowed($redirect_uri, $client_redirect_uris), 'The specified redirect URI is not valid.');
 }