/** * Validate ECS hash * * @access public * @param string username * @param string pass * */ public function validateHash() { global $ilLog; // fetch hash if (isset($_GET['ecs_hash']) and strlen($_GET['ecs_hash'])) { $hash = $_GET['ecs_hash']; } if (isset($_GET['ecs_hash_url'])) { $hashurl = urldecode($_GET['ecs_hash_url']); $hash = basename(parse_url($hashurl, PHP_URL_PATH)); //$hash = urldecode($_GET['ecs_hash_url']); } $GLOBALS['ilLog']->write(__METHOD__ . ': Using ecs hash ' . $hash); // Check if hash is valid ... try { include_once './Services/WebServices/ECS/classes/class.ilECSConnector.php'; $connector = new ilECSConnector($this->getCurrentServer()); $res = $connector->getAuth($hash); $auths = $res->getResult(); $this->abreviation = $auths->abbr; $ilLog->write(__METHOD__ . ': Got abr: ' . $this->abreviation); return true; } catch (ilECSConnectorException $e) { $ilLog->write(__METHOD__ . ': Authentication failed with message: ' . $e->getMessage()); return false; } }
/** * Validate ECS hash * * @access public * @param string username * @param string pass * */ public function validateHash() { global $ilLog; // fetch hash if (isset($_GET['ecs_hash']) and strlen($_GET['ecs_hash'])) { $hash = $_GET['ecs_hash']; } if (isset($_GET['ecs_hash_url'])) { $hashurl = urldecode($_GET['ecs_hash_url']); $hash = basename(parse_url($hashurl, PHP_URL_PATH)); //$hash = urldecode($_GET['ecs_hash_url']); } $GLOBALS['ilLog']->write(__METHOD__ . ': Using ecs hash ' . $hash); // Check if hash is valid ... try { include_once './Services/WebServices/ECS/classes/class.ilECSConnector.php'; $connector = new ilECSConnector($this->getCurrentServer()); $res = $connector->getAuth($hash); $auths = $res->getResult(); $GLOBALS['ilLog']->write(__METHOD__ . ': Auths: ' . print_r($auths, TRUE)); if ($auths->pid) { try { include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php'; $reader = ilECSCommunityReader::getInstanceByServerId($this->getCurrentServer()->getServerId()); $part = $reader->getParticipantByMID($auths->pid); if (is_object($part) and is_object($part->getOrganisation())) { $this->abreviation = $part->getOrganisation()->getAbbreviation(); } else { $this->abreviation = $auths->abbr; } } catch (Exception $e) { $ilLog->write(__METHOD__ . ': Authentication failed with message: ' . $e->getMessage()); return false; } } else { $this->abreviation = $auths->abbr; } $ilLog->write(__METHOD__ . ': Got abr: ' . $this->abreviation); } catch (ilECSConnectorException $e) { $ilLog->write(__METHOD__ . ': Authentication failed with message: ' . $e->getMessage()); return false; } // read current mid try { include_once './Services/WebServices/ECS/classes/class.ilECSConnector.php'; $connector = new ilECSConnector($this->getCurrentServer()); $details = $connector->getAuth($hash, TRUE); $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($details, TRUE)); $GLOBALS['ilLog']->write(__METHOD__ . ': Token created for mid ' . $details->getFirstSender()); $this->setMID($details->getFirstSender()); } catch (ilECSConnectorException $e) { $ilLog->write(__METHOD__ . ': Receiving mid failed with message: ' . $e->getMessage()); return false; } return TRUE; }