5 include_once
'./Services/Authentication/classes/Provider/class.ilAuthProvider.php';
6 include_once
'./Services/Authentication/interfaces/interface.ilAuthProviderInterface.php';
29 parent::__construct($credentials);
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.');
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()) {
175 if (isset(
$_GET[
'ecs_hash']) and strlen(
$_GET[
'ecs_hash'])) {
176 $hash =
$_GET[
'ecs_hash'];
178 if (isset(
$_GET[
'ecs_hash_url'])) {
179 $hashurl = urldecode(
$_GET[
'ecs_hash_url']);
180 $hash = basename(parse_url($hashurl, PHP_URL_PATH));
184 $this->
getLogger()->info(
'Using ecs hash: ' . $hash);
187 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
189 $res = $connector->getAuth($hash);
190 $auths =
$res->getResult();
196 include_once
'./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
198 foreach (
$reader->getParticipantsByPid($auths->pid) as $participant) {
199 if ($participant->getOrganisation() instanceof \ilECSOrganisation) {
200 $this->abreviation = $participant->getOrganisation()->getAbbreviation();
204 if (!$this->abreviation) {
205 $this->abreviation = $auths->abbr;
208 $this->
getLogger()->warning(
'Authentication failed with message: ' . $e->getMessage());
212 $this->abreviation = $auths->abbr;
215 $this->
getLogger()->debug(
'Got abbreviation: ' . $this->abreviation);
217 $this->
getLogger()->warning(
'Authentication failed with message: ' . $e->getMessage());
223 include_once(
'./Services/WebServices/ECS/classes/class.ilECSConnector.php');
225 $details = $connector->getAuth($hash,
true);
228 $this->
getLogger()->debug(
'Token create for mid: ' . $details->getFirstSender());
230 $this->
setMID($details->getFirstSender());
232 $this->
getLogger()->warning(
'Receiving mid failed with message: ' . $e->getMessage());
247 include_once
'./Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
261 $userObj->setOwner(SYSTEM_USER_ID);
263 include_once(
'./Services/Authentication/classes/class.ilAuthUtils.php');
266 $newUser[
"login"] = $local_user;
269 $newUser[
'email'] = $user->
getEmail();
273 $newUser[
"passwd"] =
"";
276 $newUser[
"auth_mode"] =
"ecs";
277 $newUser[
"profile_incomplete"] = 0;
280 $userObj->assignData($newUser);
281 $userObj->setTitle($userObj->getFullname());
282 $userObj->setDescription($userObj->getEmail());
285 $userObj->setLanguage($ilSetting->get(
"language"));
288 $userObj->setTimeLimitOwner(7);
289 $userObj->setTimeLimitUnlimited(0);
290 $userObj->setTimeLimitFrom(
time() - 5);
291 $userObj->setTimeLimitUntil(
time() + $ilClientIniFile->readVariable(
"session",
"expire"));
293 #$now = new ilDateTime(time(), IL_CAL_UNIX); 294 #$userObj->setAgreeDate($now->get(IL_CAL_DATETIME)); 297 $userObj->setOwner(6);
299 $userObj->setActive(1);
300 $userObj->updateOwner();
301 $userObj->saveAsNew();
302 $userObj->writePrefs();
305 $rbacadmin->assignUser($this->
getCurrentServer()->getGlobalRole(), $userObj->getId(),
true);
312 #$this->sendNotification($userObj); 315 return $userObj->getLogin();
325 global $ilClientIniFile,
$ilLog,$rbacadmin;
327 $user_obj =
new ilObjUser($a_local_user_id);
330 $user_obj->setEmail($user->
getEmail());
332 $user_obj->setActive(
true);
334 $until = $user_obj->getTimeLimitUntil();
336 if ($until < (
time() + $ilClientIniFile->readVariable(
'session',
'expire'))) {
337 $user_obj->setTimeLimitFrom(
time() - 60);
338 $user_obj->setTimeLimitUntil(
time() + $ilClientIniFile->readVariable(
"session",
"expire"));
341 $user_obj->refreshLogin();
344 $rbacadmin->assignUser(
353 $this->
getLogger()->debug(
'Finished update of remote user with usr_id: ' . $user->
getImportId());
354 return $user_obj->getLogin();
363 include_once
'./Services/Mail/classes/class.ilMailOptions.php';
resetMailOptions($a_usr_id)
Reset mail options to "local only".
handleLogin()
Called from base class after successful login.
Class ilMailOptions this class handles user mails.
Interface of auth credentials.
getFirstname()
get firstname
getServerSettings()
Get server settings.
getCurrentServer()
Get current server.
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.
doAuthentication(\ilAuthStatus $status)
Tra ecs authentication.
setAuthenticatedUserId($a_id)
createUser(ilECSUser $user)
create new user
getAbreviation()
get abbreviation
Base class for authentication providers (radius, ldap, apache, ...)
Standard interface for auth provider implementations.
Auth prvider for ecs auth.
__construct(\ilAuthCredentials $credentials)
Constructor.
setStatus($a_status)
Set auth status.
foreach($_POST as $key=> $value) $res
Storage of ECS imported objects.
initECSServices()
Init ECS Services private.
setCurrentServer(ilECSSetting $server=null)
Set current server.
updateUser(ilECSUser $user, $a_local_user_id)
update existing user
const STATUS_AUTHENTICATED
static _writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
getInstitution()
get institution
validateHash()
Validate ECS hash.
Auth status implementation.
Stores relevant user data.
static _lookupObjIdByImportId($a_import_id)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options