public function onBeforeClientRequestEvent(BeforeClientRequestEvent $event)
 {
     if ($event->isSecured()) {
         if (null === $this->session->getAuthToken()) {
             $this->authenticateEntryPoint->login();
         }
     }
 }
 /**
  * @param string $path
  * @param array $queryParams
  *
  * @return string
  */
 protected function applyApiBaseUrl($path, array $queryParams)
 {
     if (count($queryParams) > 0) {
         return sprintf('%s%s?%s', $this->session->getApiUrl(), $path, http_build_query($queryParams));
     }
     return sprintf('%s%s', $this->session->getApiUrl(), $path);
 }
 /**
  * @test
  */
 public function onBehalfOfCanBeSetAfterUnset()
 {
     $this->session->setOnBehalfOf('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa');
     $this->assertEquals('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', $this->session->getOnBehalfOf());
     $this->session->clearOnBehalfOf();
     $this->assertNull($this->session->getOnBehalfOf());
     $this->session->setOnBehalfOf('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab');
     $this->assertEquals('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab', $this->session->getOnBehalfOf());
 }
 /**
  *
  */
 public function close()
 {
     $this->request('POST', 'authenticate/close_session');
     $this->session->setAuthToken(null);
 }