24include_once(
'Auth/Container.php');
53 parent::__construct($a_params);
123 $ilLog->write(__METHOD__ .
': Starting ECS authentication.');
126 $GLOBALS[
'ilLog']->write(__METHOD__ .
': no active ecs server found. Aborting');
131 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
138 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Could not validate ecs hash for any server');
156 if (isset(
$_GET[
'ecs_hash']) and strlen(
$_GET[
'ecs_hash'])) {
157 $hash =
$_GET[
'ecs_hash'];
159 if (isset(
$_GET[
'ecs_hash_url'])) {
160 $hashurl = urldecode(
$_GET[
'ecs_hash_url']);
161 $hash = basename(parse_url($hashurl, PHP_URL_PATH));
165 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Using ecs hash ' . $hash);
169 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
171 $res = $connector->getAuth($hash);
172 $auths =
$res->getResult();
174 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Auths: ' . print_r($auths,
true));
178 include_once
'./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
180 $part =
$reader->getParticipantByMID($auths->pid);
182 if (is_object($part) and is_object($part->getOrganisation())) {
183 $this->abreviation = $part->getOrganisation()->getAbbreviation();
185 $this->abreviation = $auths->abbr;
187 }
catch (Exception $e) {
188 $ilLog->write(__METHOD__ .
': Authentication failed with message: ' . $e->getMessage());
192 $this->abreviation = $auths->abbr;
195 $ilLog->write(__METHOD__ .
': Got abr: ' . $this->abreviation);
197 $ilLog->write(__METHOD__ .
': Authentication failed with message: ' . $e->getMessage());
203 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
205 $details = $connector->getAuth($hash,
true);
207 $GLOBALS[
'ilLog']->write(__METHOD__ .
': ' . print_r($details,
true));
208 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Token created for mid ' . $details->getFirstSender());
210 $this->
setMID($details->getFirstSender());
212 $ilLog->write(__METHOD__ .
': Receiving mid failed with message: ' . $e->getMessage());
225 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
232 $username = $this->
updateUser($user, $usr_id);
236 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
241 include_once
'./Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
244 $remote->setMid($this->
getMID());
245 $remote->setRemoteUserId($user->getImportId());
248 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Current username ' . $username);
250 if (!$remote->exists()) {
254 $a_auth->setAuth($username);
255 $this->log->write(__METHOD__ .
': Login succesesful');
266 $this->log->write(__METHOD__ .
': Login failed');
282 $userObj->setOwner(SYSTEM_USER_ID);
284 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
287 $newUser[
"login"] = $local_user;
290 $newUser[
'email'] = $user->
getEmail();
294 $newUser[
"passwd"] =
"";
297 $newUser[
"auth_mode"] =
"ecs";
298 $newUser[
"profile_incomplete"] = 0;
301 $userObj->assignData($newUser);
302 $userObj->setTitle($userObj->getFullname());
303 $userObj->setDescription($userObj->getEmail());
306 $userObj->setLanguage(
$ilSetting->get(
"language"));
309 $userObj->setTimeLimitOwner(7);
310 $userObj->setTimeLimitUnlimited(0);
311 $userObj->setTimeLimitFrom(time() - 5);
312 $userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
314 #$now = new ilDateTime(time(), IL_CAL_UNIX);
315 #$userObj->setAgreeDate($now->get(IL_CAL_DATETIME));
318 $userObj->setOwner(6);
320 $userObj->setActive(1);
321 $userObj->updateOwner();
322 $userObj->saveAsNew();
323 $userObj->writePrefs();
326 $rbacadmin->assignUser($this->
getCurrentServer()->getGlobalRole(), $userObj->getId(),
true);
330 $ilLog->write(__METHOD__ .
': Created new remote user with usr_id: ' . $user->
getImportId());
333 #$this->sendNotification($userObj);
336 return $userObj->getLogin();
346 global $ilClientIniFile,
$ilLog,$rbacadmin;
348 $user_obj =
new ilObjUser($a_local_user_id);
351 $user_obj->setEmail($user->
getEmail());
353 $user_obj->setActive(
true);
355 $until = $user_obj->getTimeLimitUntil();
357 if ($until < (time() + $ilClientIniFile->readVariable(
'session',
'expire'))) {
358 $user_obj->setTimeLimitFrom(time() - 60);
359 $user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
362 $user_obj->refreshLogin();
365 $rbacadmin->assignUser(
374 $ilLog->write(__METHOD__ .
': Finished update of remote user with usr_id: ' . $user->
getImportId());
375 return $user_obj->getLogin();
384 include_once
'./Services/Mail/classes/class.ilMailOptions.php';
399 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
416 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
417 include_once
'./Services/Language/classes/class.ilLanguage.php';
421 $lang->loadLanguageModule(
'ecs');
423 include_once(
'./Services/Mail/classes/class.ilMail.php');
425 $mail->enableSoap(
false);
426 $subject =
$lang->txt(
'ecs_new_user_subject');
429 $body =
$lang->txt(
'ecs_new_user_body') .
"\n\n";
430 $body .=
$lang->txt(
'ecs_new_user_profile') .
"\n\n";
431 $body .= $user_obj->getProfileAsString(
$lang) .
"\n\n";
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
An exception for terminatinating execution or to throw for unit testing.
Custom PEAR Auth Container for ECS auth checks.
resetMailOptions($a_usr_id)
Reset mail options to "local only".
loginObserver($a_username, $a_auth)
Called from base class after successful login.
validateHash()
Validate ECS hash.
fetchData($a_username, $a_pass)
Check for valid ecs_hash.
__construct($a_params=array())
Constructor.
getServerSettings()
Get server settings.
setCurrentServer(ilECSSetting $server=null)
Set current server.
failedLoginObserver()
Called from base class after failed login.
initECSServices()
Init ECS Services @access private.
getCurrentServer()
Get current server.
createUser(ilECSUser $user)
create new user
updateUser(ilECSUser $user, $a_local_user_id)
update existing user
sendNotification($user_obj)
Send notification.
getAbreviation()
get abbreviation
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
Storage of ECS imported objects.
Storage of ecs remote user.
static getInstance()
Get singleton instance.
Stores relevant user data.
getFirstname()
get firstname
getInstitution()
get institution
static _getLanguage($a_lang_key='')
Get langauge object.
Class ilMailOptions this class handles user mails.
This class handles base functions for mail handling.
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
Get auto generated info string.
static _lookupId($a_user_str)
Lookup id by login.
static _writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
static _lookupObjIdByImportId($a_import_id)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
foreach($_POST as $key=> $value) $res