5include_once
'./Services/Authentication/classes/Provider/class.ilAuthProvider.php';
6include_once
'./Services/Authentication/interfaces/interface.ilAuthProviderInterface.php';
96 $this->
getLogger()->debug(
'Starting ECS authentication');
99 $this->
getLogger()->warning(
'No active ecs server found. Aborting');
105 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
113 $this->
getLogger()->info(
'ECS authentication successful.');
115 $status->setAuthenticatedUserId($new_usr_id);
120 $this->
getLogger()->warning(
'Could not validate ecs hash for any active server.');
133 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUser.php');
147 include_once
'./Services/WebServices/ECS/classes/class.ilECSImport.php';
152 include_once
'./Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
155 $remote->setMid($this->
getMID());
156 $remote->setRemoteUserId($user->getImportId());
159 $this->
getLogger()->info(
'Current user is: ' . $username);
161 if(!$remote->exists())
182 if(isset(
$_GET[
'ecs_hash']) and strlen(
$_GET[
'ecs_hash']))
184 $hash =
$_GET[
'ecs_hash'];
186 if(isset(
$_GET[
'ecs_hash_url']))
188 $hashurl = urldecode(
$_GET[
'ecs_hash_url']);
189 $hash = basename(parse_url($hashurl,PHP_URL_PATH));
193 $this->
getLogger()->info(
'Using ecs hash: ' . $hash);
197 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
199 $res = $connector->getAuth($hash);
200 $auths =
$res->getResult();
208 include_once
'./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
210 $part =
$reader->getParticipantByMID($auths->pid);
212 if(is_object($part) and is_object($part->getOrganisation()))
214 $this->abreviation = $part->getOrganisation()->getAbbreviation();
218 $this->abreviation = $auths->abbr;
223 $this->
getLogger()->warning(
'Authentication failed with message: ' . $e->getMessage());
229 $this->abreviation = $auths->abbr;
232 $this->
getLogger()->debug(
'Got abbreviation: ' . $this->abreviation);
236 $this->
getLogger()->warning(
'Authentication failed with message: ' . $e->getMessage());
243 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
245 $details = $connector->getAuth($hash,TRUE);
248 $this->
getLogger()->debug(
'Token create for mid: ' . $details->getFirstSender());
250 $this->
setMID($details->getFirstSender());
254 $this->
getLogger()->warning(
'Receiving mid failed with message: ' . $e->getMessage());
269 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
283 $userObj->setOwner(SYSTEM_USER_ID);
285 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
288 $newUser[
"login"] = $local_user;
291 $newUser[
'email'] = $user->
getEmail();
295 $newUser[
"passwd"] =
"";
298 $newUser[
"auth_mode"] =
"ecs";
299 $newUser[
"profile_incomplete"] = 0;
302 $userObj->assignData($newUser);
303 $userObj->setTitle($userObj->getFullname());
304 $userObj->setDescription($userObj->getEmail());
307 $userObj->setLanguage(
$ilSetting->get(
"language"));
310 $userObj->setTimeLimitOwner(7);
311 $userObj->setTimeLimitUnlimited(0);
312 $userObj->setTimeLimitFrom(time() - 5);
313 $userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
315 #$now = new ilDateTime(time(), IL_CAL_UNIX);
316 #$userObj->setAgreeDate($now->get(IL_CAL_DATETIME));
319 $userObj->setOwner(6);
321 $userObj->setActive(1);
322 $userObj->updateOwner();
323 $userObj->saveAsNew();
324 $userObj->writePrefs();
328 $rbacadmin->assignUser($this->
getCurrentServer()->getGlobalRole(), $userObj->getId(),
true);
335 #$this->sendNotification($userObj);
338 return $userObj->getLogin();
348 global $ilClientIniFile,
$ilLog,$rbacadmin;
350 $user_obj =
new ilObjUser($a_local_user_id);
353 $user_obj->setEmail($user->
getEmail());
355 $user_obj->setActive(
true);
357 $until = $user_obj->getTimeLimitUntil();
359 if($until < (time() + $ilClientIniFile->readVariable(
'session',
'expire')))
361 $user_obj->setTimeLimitFrom(time() - 60);
362 $user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable(
"session",
"expire"));
365 $user_obj->refreshLogin();
369 $rbacadmin->assignUser(
378 $this->
getLogger()->debug(
'Finished update of remote user with usr_id: ' . $user->
getImportId());
379 return $user_obj->getLogin();
388 include_once
'./Services/Mail/classes/class.ilMailOptions.php';
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 UserMail 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)
Interface of auth credentials.
Standard interface for auth provider implementations.
if(!is_array($argv)) $options