24 include_once(
'Auth/Container.php');
53 parent::__construct($a_params);
57 $this->log =
$GLOBALS[
'DIC'][
'ilLog'];
125 $ilLog->write(__METHOD__ .
': Starting ECS authentication.');
128 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': no active ecs server found. Aborting');
133 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
140 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Could not validate ecs hash for any server');
160 if (isset(
$_GET[
'ecs_hash'])
and strlen(
$_GET[
'ecs_hash'])) {
161 $hash =
$_GET[
'ecs_hash'];
163 if (isset(
$_GET[
'ecs_hash_url'])) {
164 $hashurl = urldecode(
$_GET[
'ecs_hash_url']);
165 $hash = basename(parse_url($hashurl, PHP_URL_PATH));
169 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Using ecs hash ' . $hash);
173 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
175 $res = $connector->getAuth($hash);
176 $auths =
$res->getResult();
178 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Auths: ' . print_r($auths,
true));
182 include_once
'./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
184 $part =
$reader->getParticipantByMID($auths->pid);
186 if (is_object($part)
and is_object($part->getOrganisation())) {
187 $this->abreviation = $part->getOrganisation()->getAbbreviation();
189 $this->abreviation = $auths->abbr;
192 $ilLog->write(__METHOD__ .
': Authentication failed with message: ' . $e->getMessage());
196 $this->abreviation = $auths->abbr;
199 $ilLog->write(__METHOD__ .
': Got abr: ' . $this->abreviation);
201 $ilLog->write(__METHOD__ .
': Authentication failed with message: ' . $e->getMessage());
207 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
209 $details = $connector->getAuth($hash,
true);
211 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': ' . print_r($details,
true));
212 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Token created for mid ' . $details->getFirstSender());
214 $this->
setMID($details->getFirstSender());
216 $ilLog->write(__METHOD__ .
': Receiving mid failed with message: ' . $e->getMessage());
229 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
240 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
245 include_once
'./Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
248 $remote->setMid($this->
getMID());
249 $remote->setRemoteUserId(
$user->getImportId());
252 $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ .
': Current username ' . $username);
254 if (!$remote->exists()) {
258 $a_auth->setAuth($username);
259 $this->log->write(__METHOD__ .
': Login succesesful');
270 $this->log->write(__METHOD__ .
': Login failed');
285 $ilClientIniFile = $DIC[
'ilClientIniFile'];
287 $rbacadmin = $DIC[
'rbacadmin'];
291 $userObj->setOwner(SYSTEM_USER_ID);
293 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
296 $newUser[
"login"] = $local_user;
299 $newUser[
'email'] = $user->
getEmail();
303 $newUser[
"passwd"] =
"";
306 $newUser[
"auth_mode"] =
"ecs";
307 $newUser[
"profile_incomplete"] = 0;
310 $userObj->assignData($newUser);
311 $userObj->setTitle($userObj->getFullname());
312 $userObj->setDescription($userObj->getEmail());
315 $userObj->setLanguage(
$ilSetting->get(
"language"));
318 $userObj->setTimeLimitOwner(7);
319 $userObj->setTimeLimitUnlimited(0);
320 $userObj->setTimeLimitFrom(time() - 5);
321 $userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
323 #$now = new ilDateTime(time(), IL_CAL_UNIX); 324 #$userObj->setAgreeDate($now->get(IL_CAL_DATETIME)); 327 $userObj->setOwner(6);
329 $userObj->setActive(1);
330 $userObj->updateOwner();
331 $userObj->saveAsNew();
332 $userObj->writePrefs();
335 $rbacadmin->assignUser($this->
getCurrentServer()->getGlobalRole(), $userObj->getId(),
true);
339 $ilLog->write(__METHOD__ .
': Created new remote user with usr_id: ' . $user->
getImportId());
342 #$this->sendNotification($userObj); 345 return $userObj->getLogin();
357 $ilClientIniFile = $DIC[
'ilClientIniFile'];
359 $rbacadmin = $DIC[
'rbacadmin'];
361 $user_obj =
new ilObjUser($a_local_user_id);
364 $user_obj->setEmail($user->
getEmail());
366 $user_obj->setActive(
true);
368 $until = $user_obj->getTimeLimitUntil();
370 if ($until < (time() + $ilClientIniFile->readVariable(
'session',
'expire'))) {
371 $user_obj->setTimeLimitFrom(time() - 60);
372 $user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
375 $user_obj->refreshLogin();
378 $rbacadmin->assignUser(
387 $ilLog->write(__METHOD__ .
': Finished update of remote user with usr_id: ' . $user->
getImportId());
388 return $user_obj->getLogin();
397 include_once
'./Services/Mail/classes/class.ilMailOptions.php';
412 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
429 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
430 include_once
'./Services/Language/classes/class.ilLanguage.php';
433 $GLOBALS[
'DIC'][
'ilUser'] = $user_obj;
434 $lang->loadLanguageModule(
'ecs');
436 include_once(
'./Services/Mail/classes/class.ilMail.php');
438 $mail->enableSoap(
false);
439 $subject =
$lang->txt(
'ecs_new_user_subject');
442 $body =
$lang->txt(
'ecs_new_user_body') .
"\n\n";
443 $body .=
$lang->txt(
'ecs_new_user_profile') .
"\n\n";
444 $body .= $user_obj->getProfileAsString(
$lang) .
"\n\n";
updateUser(ilECSUser $user, $a_local_user_id)
update existing user
Class ilMailOptions this class handles user mails.
getFirstname()
get firstname
getAbreviation()
get abbreviation
static getInstance()
Get singleton instance.
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
Storage of ecs remote user.
static _lookupId($a_user_str)
Lookup id by login.
getServerSettings()
Get server settings.
createUser(ilECSUser $user)
create new user
sendNotification($user_obj)
Send notification.
static _getLanguage($a_lang_key='')
Get langauge object.
foreach($_POST as $key=> $value) $res
failedLoginObserver()
Called from base class after failed login.
getCurrentServer()
Get current server.
Storage of ECS imported objects.
resetMailOptions($a_usr_id)
Reset mail options to "local only".
static _writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
loginObserver($a_username, $a_auth)
Called from base class after successful login.
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
Get auto generated info string.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
fetchData($a_username, $a_pass)
Check for valid ecs_hash.
setCurrentServer(ilECSSetting $server=null)
Set current server.
initECSServices()
Init ECS Services private.
__construct($a_params=array())
Constructor.
getInstitution()
get institution
Custom PEAR Auth Container for ECS auth checks.
Stores relevant user data.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
static _lookupObjIdByImportId($a_import_id)
validateHash()
Validate ECS hash.