5include_once
'./Services/Authentication/classes/Provider/class.ilAuthProvider.php';
6include_once
'./Services/Authentication/interfaces/interface.ilAuthProviderInterface.php';
96 $this->
getLogger()->debug(
'Starting ECS authentication');
98 $this->
getLogger()->warning(
'No active ecs server found. Aborting');
104 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
110 $this->
getLogger()->info(
'ECS authentication successful.');
112 $status->setAuthenticatedUserId($new_usr_id);
117 $this->
getLogger()->warning(
'Could not validate ecs hash for any active server.');
130 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
137 $username = $this->
updateUser($user, $usr_id);
141 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
146 include_once
'./Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
149 $remote->setMid($this->
getMID());
150 $remote->setRemoteUserId($user->getImportId());
153 $this->
getLogger()->info(
'Current user is: ' . $username);
155 if (!$remote->exists()) {
174 $ilLog =
$DIC[
'ilLog'];
177 if (isset(
$_GET[
'ecs_hash']) and strlen(
$_GET[
'ecs_hash'])) {
178 $hash =
$_GET[
'ecs_hash'];
180 if (isset(
$_GET[
'ecs_hash_url'])) {
181 $hashurl = urldecode(
$_GET[
'ecs_hash_url']);
182 $hash = basename(parse_url($hashurl, PHP_URL_PATH));
186 $this->
getLogger()->info(
'Using ecs hash: ' . $hash);
189 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
191 $res = $connector->getAuth($hash);
192 $auths =
$res->getResult();
198 include_once
'./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
200 foreach ($reader->getParticipantsByPid($auths->pid) as $participant) {
202 $this->abreviation = $participant->getOrganisation()->getAbbreviation();
206 if (!$this->abreviation) {
207 $this->abreviation = $auths->abbr;
209 }
catch (Exception
$e) {
210 $this->
getLogger()->warning(
'Authentication failed with message: ' . $e->getMessage());
214 $this->abreviation = $auths->abbr;
217 $this->
getLogger()->debug(
'Got abbreviation: ' . $this->abreviation);
219 $this->
getLogger()->warning(
'Authentication failed with message: ' . $e->getMessage());
225 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
227 $details = $connector->getAuth($hash,
true);
230 $this->
getLogger()->debug(
'Token create for mid: ' . $details->getFirstSender());
232 $this->
setMID($details->getFirstSender());
234 $this->
getLogger()->warning(
'Receiving mid failed with message: ' . $e->getMessage());
249 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
262 $ilClientIniFile =
$DIC[
'ilClientIniFile'];
264 $rbacadmin =
$DIC[
'rbacadmin'];
265 $ilLog =
$DIC[
'ilLog'];
270 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
273 $newUser[
"login"] = $local_user;
276 $newUser[
'email'] = $user->
getEmail();
280 $newUser[
"passwd"] =
"";
283 $newUser[
"auth_mode"] =
"ecs";
284 $newUser[
"profile_incomplete"] = 0;
287 $userObj->assignData($newUser);
288 $userObj->setTitle($userObj->getFullname());
289 $userObj->setDescription($userObj->getEmail());
292 $userObj->setLanguage(
$ilSetting->get(
"language"));
295 $userObj->setTimeLimitOwner(7);
296 $userObj->setTimeLimitUnlimited(0);
297 $userObj->setTimeLimitFrom(time() - 5);
298 $userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
300 #$now = new ilDateTime(time(), IL_CAL_UNIX);
301 #$userObj->setAgreeDate($now->get(IL_CAL_DATETIME));
304 $userObj->setOwner(6);
306 $userObj->setActive(1);
307 $userObj->updateOwner();
308 $userObj->saveAsNew();
309 $userObj->writePrefs();
312 $rbacadmin->assignUser($this->
getCurrentServer()->getGlobalRole(), $userObj->getId(),
true);
319 #$this->sendNotification($userObj);
322 return $userObj->getLogin();
334 $ilClientIniFile =
$DIC[
'ilClientIniFile'];
335 $ilLog =
$DIC[
'ilLog'];
336 $rbacadmin =
$DIC[
'rbacadmin'];
338 $user_obj =
new ilObjUser($a_local_user_id);
341 $user_obj->setEmail($user->
getEmail());
343 $user_obj->setActive(
true);
345 $until = $user_obj->getTimeLimitUntil();
347 if ($until < (time() + $ilClientIniFile->readVariable(
'session',
'expire'))) {
348 $user_obj->setTimeLimitFrom(time() - 60);
349 $user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
352 $user_obj->refreshLogin();
355 $rbacadmin->assignUser(
364 $this->
getLogger()->debug(
'Finished update of remote user with usr_id: ' . $user->
getImportId());
365 return $user_obj->getLogin();
374 include_once
'./Services/Mail/classes/class.ilMailOptions.php';
377 $options->updateOptions();
An exception for terminatinating execution or to throw for unit testing.
Auth prvider for ecs auth.
doAuthentication(\ilAuthStatus $status)
Tra ecs authentication.
__construct(\ilAuthCredentials $credentials)
Constructor.
getServerSettings()
Get server settings.
getAbreviation()
get abbreviation
createUser(ilECSUser $user)
create new user
initECSServices()
Init ECS Services @access private.
handleLogin()
Called from base class after successful login.
getCurrentServer()
Get current server.
updateUser(ilECSUser $user, $a_local_user_id)
update existing user
validateHash()
Validate ECS hash.
resetMailOptions($a_usr_id)
Reset mail options to "local only".
setCurrentServer(ilECSSetting $server=null)
Set current server.
Base class for authentication providers (radius, ldap, apache, ...)
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
Auth status implementation.
setStatus($a_status)
Set auth status.
const STATUS_AUTHENTICATED
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
Class ilMailOptions this class handles user mails.
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)
const SYSTEM_USER_ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface of auth credentials.
Standard interface for auth provider implementations.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
foreach($_POST as $key=> $value) $res