24include_once(
'Auth/Container.php');
53 parent::__construct($a_params);
123 $ilLog->write(__METHOD__.
': Starting ECS authentication.');
127 $GLOBALS[
'ilLog']->write(__METHOD__.
': no active ecs server found. Aborting');
132 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
141 $GLOBALS[
'ilLog']->write(__METHOD__.
': Could not validate ecs hash for any server');
160 if(isset(
$_GET[
'ecs_hash']) and strlen(
$_GET[
'ecs_hash']))
162 $hash =
$_GET[
'ecs_hash'];
164 if(isset(
$_GET[
'ecs_hash_url']))
166 $hashurl = urldecode(
$_GET[
'ecs_hash_url']);
167 $hash = basename(parse_url($hashurl,PHP_URL_PATH));
171 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using ecs hash '. $hash);
176 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
178 $res = $connector->getAuth($hash);
179 $auths =
$res->getResult();
181 $GLOBALS[
'ilLog']->write(__METHOD__.
': Auths: '.print_r($auths,TRUE));
187 include_once
'./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
189 $part =
$reader->getParticipantByMID($auths->pid);
191 if(is_object($part) and is_object($part->getOrganisation()))
193 $this->abreviation = $part->getOrganisation()->getAbbreviation();
197 $this->abreviation = $auths->abbr;
202 $ilLog->write(__METHOD__.
': Authentication failed with message: '.$e->getMessage());
208 $this->abreviation = $auths->abbr;
211 $ilLog->write(__METHOD__.
': Got abr: '.$this->abreviation);
215 $ilLog->write(__METHOD__.
': Authentication failed with message: '.$e->getMessage());
222 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
224 $details = $connector->getAuth($hash,TRUE);
226 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.print_r($details,TRUE));
227 $GLOBALS[
'ilLog']->write(__METHOD__.
': Token created for mid '. $details->getFirstSender());
229 $this->
setMID($details->getFirstSender());
233 $ilLog->write(__METHOD__.
': Receiving mid failed with message: '.$e->getMessage());
246 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
260 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
265 include_once
'./Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
268 $remote->setMid($this->
getMID());
269 $remote->setRemoteUserId($user->getImportId());
272 $GLOBALS[
'ilLog']->write(__METHOD__.
': Current username '.$username);
274 if(!$remote->exists())
279 $a_auth->setAuth($username);
280 $this->
log->write(__METHOD__.
': Login succesesful');
291 $this->
log->write(__METHOD__.
': Login failed');
308 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
311 $newUser[
"login"] = $local_user;
314 $newUser[
'email'] = $user->
getEmail();
318 $newUser[
"passwd"] =
"";
321 $newUser[
"auth_mode"] =
"ecs";
322 $newUser[
"profile_incomplete"] = 0;
325 $userObj->assignData($newUser);
326 $userObj->setTitle($userObj->getFullname());
327 $userObj->setDescription($userObj->getEmail());
330 $userObj->setLanguage(
$ilSetting->get(
"language"));
333 $userObj->setTimeLimitOwner(7);
334 $userObj->setTimeLimitUnlimited(0);
335 $userObj->setTimeLimitFrom(time() - 5);
336 $userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
338 #$now = new ilDateTime(time(), IL_CAL_UNIX);
339 #$userObj->setAgreeDate($now->get(IL_CAL_DATETIME));
342 $userObj->setOwner(6);
344 $userObj->setActive(1);
345 $userObj->updateOwner();
346 $userObj->saveAsNew();
347 $userObj->writePrefs();
351 $rbacadmin->assignUser($this->
getCurrentServer()->getGlobalRole(), $userObj->getId(),
true);
355 $ilLog->write(__METHOD__ .
': Created new remote user with usr_id: ' . $user->
getImportId());
358 #$this->sendNotification($userObj);
361 return $userObj->getLogin();
371 global $ilClientIniFile,
$ilLog,$rbacadmin;
373 $user_obj =
new ilObjUser($a_local_user_id);
376 $user_obj->setEmail($user->
getEmail());
378 $user_obj->setActive(
true);
380 $until = $user_obj->getTimeLimitUntil();
382 if($until < (time() + $ilClientIniFile->readVariable(
'session',
'expire')))
384 $user_obj->setTimeLimitFrom(time() - 60);
385 $user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
388 $user_obj->refreshLogin();
392 $rbacadmin->assignUser(
401 $ilLog->write(__METHOD__.
': Finished update of remote user with usr_id: '.$user->
getImportId());
402 return $user_obj->getLogin();
411 include_once
'./Services/Mail/classes/class.ilMailOptions.php';
430 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
448 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
449 include_once
'./Services/Language/classes/class.ilLanguage.php';
453 $lang->loadLanguageModule(
'ecs');
455 include_once(
'./Services/Mail/classes/class.ilMail.php');
457 $mail->enableSoap(
false);
458 $subject =
$lang->txt(
'ecs_new_user_subject');
461 $body =
$lang->txt(
'ecs_new_user_body').
"\n\n";
462 $body .=
$lang->txt(
'ecs_new_user_profile').
"\n\n";
463 $body .= $user_obj->getProfileAsString(
$lang).
"\n\n";
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
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
_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 UserMail this class handles user mails.
Class Mail this class handles base functions for mail handling.
static _getAutoGeneratedMessageString($lang=null)
get auto generated info string
static _lookupId($a_user_str)
Lookup id by login.
static _lookupObjIdByImportId($a_import_id)
_writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
if(!is_array($argv)) $options