Пример #1
0
 /**
  * Initialize FBS service.
  */
 protected function initService()
 {
     $httpclient = $this->getHttpClient();
     if ($this->useService) {
         $client = new FBSGuzzleHttpClient();
         $client = new FBSAuthenticationHandler($this->serviceUsername, $this->servicePassword, $client, new FBSCacheMemory(), new FBSLogStdout());
         $this->fbs = fbs_service($this->serviceAgency, $this->serviceEndpoint, $client, NULL, TRUE);
     } else {
         $this->fbs = fbs_service('1234', '', $httpclient, NULL, TRUE);
     }
 }
Пример #2
0
 /**
  * Authenticate with FBS and get a session id.
  *
  * @return bool
  *   Whether the attempt was successful.
  */
 protected function authenticate()
 {
     $this->cache->delete(self::SESSION_KEY);
     $this->sessionId = NULL;
     $login = new FBS\Model\Login();
     $login->username = $this->username;
     $login->password = $this->password;
     $res = fbs_service()->Authentication->login(fbs_service()->agencyId, $login);
     if (isset($res->sessionKey)) {
         $this->sessionId = $res->sessionKey;
         $this->cache->set(self::SESSION_KEY, $this->sessionId);
         return TRUE;
     } else {
         $this->log->critical('Error athentication with FBS. Check endpoint, agency id, username and password.');
     }
     return FALSE;
 }