/** * @return exodLog */ public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self(ILIAS_LOG_DIR, self::OD_LOG); } return self::$instance; }
/** * @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; }
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); }
/** * @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); }