/**
  * @return bool
  */
 public function isValid()
 {
     if (!$this->getAccessToken()) {
         //			return true;
     }
     if ((int) $this->getValidThrough() <= time() and $this->getValidThrough() !== NULL) {
         $exodLog = exodLog::getInstance();
         $exodLog->write('Token no longer valid...');
         return false;
     }
     return true;
 }
示例#2
0
 protected function debug()
 {
     $exodLog = exodLog::getInstance();
     $exodLog->write('execute *************************************************');
     $log = $this->getUrl();
     $log .= "\n";
     $log .= print_r($this->getHeaders(), self::DEBUG);
     $log .= "\n";
     foreach (debug_backtrace() as $b) {
         $log .= $b['file'] . ': ' . $b["function"] . "\n";
     }
     $log .= "\n\n\n\n";
     $exodLog->write($log);
 }
示例#3
0
 /**
  * @param exodBearerToken $exodBearerToken
  *
  * @return bool
  */
 public function refreshToken(exodBearerToken &$exodBearerToken)
 {
     //		throw new ilCloudException(-1, 'failed');
     $exodLog = exodLog::getInstance();
     $exodLog->write('refreshing-Token...');
     $this->exod_app->buildURLs();
     $exodCurl = new exodCurl();
     $exodCurl->setUrl($this->exod_app->getTokenUrl());
     $exodCurl->addHeader("Content-Type: application/x-www-form-urlencoded");
     $exodCurl->addPostField('client_secret', $this->getExodApp()->getClientSecret());
     $exodCurl->addPostField('client_id', $this->exod_app->getClientId());
     $exodCurl->addPostField('grant_type', 'refresh_token');
     $exodCurl->addPostField('refresh_token', $exodBearerToken->getRefreshToken());
     $exodCurl->addPostField('resource', $this->exod_app->getRessourceUri());
     $exodCurl->addPostField('redirect_uri', $this->exod_app->getRedirectUri());
     $exodCurl->post();
     $this->response->loadFromResponse($exodCurl->getResponseBody());
     $exodBearerToken->setRefreshToken($this->response->getRefreshToken());
     $exodBearerToken->setAccessToken($this->response->getAccessToken());
     $exodBearerToken->setValidThrough($this->response->getExpiresOn());
     $this->setExodBearerToken($exodBearerToken);
 }