Exemplo n.º 1
0
 /**
  * create authentication resource on ecs server
  *
  * @return bool
  * @throws ilECSConnectorException
  */
 public function createAuthResource($a_plain_realm)
 {
     global $ilLog;
     include_once './Services/WebServices/ECS/classes/class.ilECSAuth.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSConnector.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
     try {
         $server_id = ilECSImport::lookupServerId($this->getId());
         $import_info = new ilECSImport($server_id, $this->getId());
         $connector = new ilECSConnector(ilECSSetting::getInstanceByServerId($server_id));
         $auth = new ilECSAuth();
         $auth->setPid($import_info->getMID());
         // URL is deprecated
         $auth->setUrl($this->getRemoteLink());
         $realm = sha1($a_plain_realm);
         $GLOBALS['ilLog']->write(__METHOD__ . ': Using realm ' . $a_plain_realm);
         $auth->setRealm($realm);
         $GLOBALS['ilLog']->write(__METHOD__ . ' Mid is ' . $this->getMID());
         $this->auth_hash = $connector->addAuth(@json_encode($auth), $this->getMID());
         return $this->auth_hash;
     } catch (ilECSConnectorException $exc) {
         $ilLog->write(__METHOD__ . ': Caught error from ECS Auth resource: ' . $exc->getMessage());
         return false;
     }
 }