/**
  * Destroy the given global session
  *
  * @param \Flowpack\SingleSignOn\Client\Domain\Model\SsoClient $ssoClient
  * @param $sessionId
  * @return void
  */
 public function destroySession(SsoClient $ssoClient, $sessionId)
 {
     $serviceUri = new Uri($this->serviceBaseUri . '/session/' . urlencode($sessionId) . '/destroy');
     $serviceUri->setQuery(http_build_query(array('clientIdentifier' => $ssoClient->getServiceBaseUri())));
     $request = \TYPO3\Flow\Http\Request::create($serviceUri, 'DELETE');
     $request->setContent('');
     $signedRequest = $this->requestSigner->signRequest($request, $ssoClient->getPublicKeyFingerprint(), $ssoClient->getPublicKeyFingerprint());
     // TODO Send request asynchronously
     $response = $this->requestEngine->sendRequest($signedRequest);
     if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 404) {
         throw new Exception('Unexpected status code for destroy session when calling "' . (string) $serviceUri . '": "' . $response->getStatus() . '"', 1354132939);
     }
 }
 /**
  * @param string $grantType One of this' interface GRANT_TYPE_* constants
  * @param array $additionalParameters Additional parameters for the request
  * @return mixed
  * @throws \Flowpack\OAuth2\Client\Exception
  * @see http://tools.ietf.org/html/rfc6749#section-4.1.3
  */
 protected function requestAccessToken($grantType, $additionalParameters = array())
 {
     $parameters = array('grant_type' => $grantType, 'client_id' => $this->clientIdentifier, 'client_secret' => $this->clientSecret);
     $parameters = Arrays::arrayMergeRecursiveOverrule($parameters, $additionalParameters, FALSE, FALSE);
     $request = Request::create(new Uri($this->endpointUri), 'POST', $parameters);
     $request->setHeader('Content-Type', 'application/x-www-form-urlencoded');
     $response = $this->requestEngine->sendRequest($request);
     if ($response->getStatusCode() !== 200) {
         throw new OAuth2Exception(sprintf('The response when requesting the access token was not as expected, code and message was: %d %s', $response->getStatusCode(), $response->getContent()), 1383749757);
     }
     parse_str($response->getContent(), $responseComponents);
     return $responseComponents['access_token'];
 }
 /**
  * @return void
  */
 public function initializeObject()
 {
     $requestEngine = new CurlEngine();
     $requestEngine->setOption(CURLOPT_TIMEOUT, $this->settings['transfer']['connectionTimeout']);
     $this->browser->setRequestEngine($requestEngine);
 }
Example #4
0
 /**
  * @return void
  */
 public function initializeObject()
 {
     $this->browserRequestEngine->setOption(CURLOPT_SSL_VERIFYPEER, FALSE);
     $this->browserRequestEngine->setOption(CURLOPT_SSL_VERIFYHOST, FALSE);
     $this->browser->setRequestEngine($this->browserRequestEngine);
 }
 /**
  * @param string $url
  * @return string
  */
 public function checkUrlAction($url)
 {
     $request = Request::create(new Uri($url));
     $request->setHeader('X-Cache-Debug', '1');
     $engine = new CurlEngine();
     $engine->setOption(CURLOPT_SSL_VERIFYPEER, FALSE);
     $engine->setOption(CURLOPT_SSL_VERIFYHOST, FALSE);
     $response = $engine->sendRequest($request);
     $this->view->assign('value', array('statusCode' => $response->getStatusCode(), 'host' => parse_url($url, PHP_URL_HOST), 'url' => $url, 'headers' => array_map(function ($value) {
         return array_pop($value);
     }, $response->getHeaders()->getAll())));
 }