ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAuthContainerECS Class Reference

Custom PEAR Auth Container for ECS auth checks. More...

+ Inheritance diagram for ilAuthContainerECS:
+ Collaboration diagram for ilAuthContainerECS:

Public Member Functions

 __construct ($a_params=array())
 Constructor.
 getAbreviation ()
 get abbreviation
 getMID ()
 get mid
 setCurrentServer (ilECSSetting $server=null)
 Set current server.
 getCurrentServer ()
 Get current server.
 getServerSettings ()
 Get server settings.
 fetchData ($a_username, $a_pass)
 Check for valid ecs_hash.
 validateHash ()
 Validate ECS hash.
 loginObserver ($a_username, $a_auth)
 Called from base class after successful login.
 failedLoginObserver ()
 Called from base class after failed login.
- Public Member Functions inherited from Auth_Container
 Auth_Container ()
 Constructor.
 fetchData ($username, $password, $isChallengeResponse=false)
 Fetch data from storage container.
 verifyPassword ($password1, $password2, $cryptType="md5")
 Crypt and verfiy the entered password.
 supportsChallengeResponse ()
 Returns true if the container supports Challenge Response password authentication.
 getCryptType ()
 Returns the crypt current crypt type of the container.
 listUsers ()
 List all users that are available from the storage container.
 getUser ($username)
 Returns a user assoc array.
 addUser ($username, $password, $additional=null)
 Add a new user to the storage container.
 removeUser ($username)
 Remove user from the storage container.
 changePassword ($username, $password)
 Change password for user in the storage container.
 log ($message, $level=AUTH_LOG_DEBUG)
 Log a message to the Auth log.
- Public Member Functions inherited from ilAuthContainerBase
 failedLoginObserver ($a_username, $a_auth)
 Called after failed login.
 checkAuthObserver ($a_username, $a_auth)
 Called after check auth requests.
 logoutObserver ($a_username, $a_auth)
 Called after logout.

Protected Member Functions

 createUser (ilECSUser $user)
 create new user
 updateUser (ilECSUser $user, $a_local_user_id)
 update existing user

Protected Attributes

 $mid = null
 $abreviation = null
 $currentServer = null
 $servers = null
 $log

Private Member Functions

 initECSServices ()
 Init ECS Services private.
 sendNotification ($user_obj)
 Send notification.

Additional Inherited Members

- Data Fields inherited from Auth_Container
 $activeUser = ""
 User that is currently selected from the storage container.
 $_auth_obj = null
 The Auth object this container is attached to.

Detailed Description

Custom PEAR Auth Container for ECS auth checks.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 34 of file class.ilAuthContainerECS.php.

Constructor & Destructor Documentation

ilAuthContainerECS::__construct (   $a_params = array())

Constructor.

public

Parameters

Definition at line 51 of file class.ilAuthContainerECS.php.

References $GLOBALS, initECSServices(), and Auth_Container\log().

{
parent::__construct($a_params);
$this->initECSServices();
$this->log = $GLOBALS['ilLog'];
}

+ Here is the call graph for this function:

Member Function Documentation

ilAuthContainerECS::createUser ( ilECSUser  $user)
protected

create new user

protected

Definition at line 215 of file class.ilAuthContainerECS.php.

References $ilLog, $ilSetting, ilAuthUtils\_generateLogin(), ilObject\_writeImportId(), getAbreviation(), getCurrentServer(), ilECSUser\getEmail(), ilECSUser\getFirstname(), ilECSUser\getImportId(), ilECSUser\getInstitution(), ilECSUser\getLastname(), ilECSUser\getLogin(), and IL_PASSWD_MD5.

Referenced by loginObserver().

{
global $ilClientIniFile, $ilSetting, $rbacadmin, $ilLog;
$userObj = new ilObjUser();
include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
$local_user = ilAuthUtils::_generateLogin($this->getAbreviation() . '_' . $user->getLogin());
$newUser["login"] = $local_user;
$newUser["firstname"] = $user->getFirstname();
$newUser["lastname"] = $user->getLastname();
$newUser['email'] = $user->getEmail();
$newUser['institution'] = $user->getInstitution();
// set "plain md5" password (= no valid password)
$newUser["passwd"] = "";
$newUser["passwd_type"] = IL_PASSWD_MD5;
$newUser["auth_mode"] = "ecs";
$newUser["profile_incomplete"] = 0;
// system data
$userObj->assignData($newUser);
$userObj->setTitle($userObj->getFullname());
$userObj->setDescription($userObj->getEmail());
// set user language to system language
$userObj->setLanguage($ilSetting->get("language"));
// Time limit
$userObj->setTimeLimitOwner(7);
$userObj->setTimeLimitUnlimited(0);
$userObj->setTimeLimitFrom(time() - 5);
$userObj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session", "expire"));
// Create user in DB
$userObj->setOwner(6);
$userObj->create();
$userObj->setActive(1);
$userObj->updateOwner();
$userObj->saveAsNew();
$userObj->writePrefs();
if($global_role = $this->getCurrentServer()->getGlobalRole())
{
$rbacadmin->assignUser($this->getCurrentServer()->getGlobalRole(), $userObj->getId(), true);
}
ilObject::_writeImportId($userObj->getId(), $user->getImportId());
$ilLog->write(__METHOD__ . ': Created new remote user with usr_id: ' . $user->getImportId());
// Send Mail
#$this->sendNotification($userObj);
return $userObj->getLogin();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAuthContainerECS::failedLoginObserver ( )

Called from base class after failed login.

Parameters
stringusername

Definition at line 202 of file class.ilAuthContainerECS.php.

References Auth_Container\log().

{
$this->log->write(__METHOD__.': Login failed');
return false;
}

+ Here is the call graph for this function:

ilAuthContainerECS::fetchData (   $a_username,
  $a_pass 
)

Check for valid ecs_hash.

Parameters
string$a_username
string$a_pass

Definition at line 114 of file class.ilAuthContainerECS.php.

References $GLOBALS, $ilLog, $server, getServerSettings(), setCurrentServer(), and validateHash().

{
global $ilLog;
$ilLog->write(__METHOD__.': Starting ECS authentication.');
if(!$this->getServerSettings()->activeServerExists())
{
$GLOBALS['ilLog']->write(__METHOD__.': no active ecs server found. Aborting');
return false;
}
// Iterate through all active ecs instances
include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
foreach($this->getServerSettings()->getServers() as $server)
{
$this->setCurrentServer($server);
if($this->validateHash())
{
return true;
}
}
$GLOBALS['ilLog']->write(__METHOD__.': Could not validate ecs hash for any server');
return false;
}

+ Here is the call graph for this function:

ilAuthContainerECS::getAbreviation ( )

get abbreviation

public

Parameters

Definition at line 67 of file class.ilAuthContainerECS.php.

References $abreviation.

Referenced by createUser().

{
}

+ Here is the caller graph for this function:

ilAuthContainerECS::getCurrentServer ( )

Get current server.

Returns
ilECSSetting

Definition at line 95 of file class.ilAuthContainerECS.php.

References $currentServer.

Referenced by createUser(), sendNotification(), updateUser(), and validateHash().

{
}

+ Here is the caller graph for this function:

ilAuthContainerECS::getMID ( )

get mid

public

Definition at line 77 of file class.ilAuthContainerECS.php.

References $mid.

{
return $this->mid;
}
ilAuthContainerECS::getServerSettings ( )

Get server settings.

Returns
ilECSServerSettings

Definition at line 104 of file class.ilAuthContainerECS.php.

References $servers.

Referenced by fetchData().

{
}

+ Here is the caller graph for this function:

ilAuthContainerECS::initECSServices ( )
private

Init ECS Services private.

Parameters

Definition at line 318 of file class.ilAuthContainerECS.php.

References ilECSServerSettings\getInstance().

Referenced by __construct().

{
include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAuthContainerECS::loginObserver (   $a_username,
  $a_auth 
)

Called from base class after successful login.

Parameters
stringusername

Reimplemented from ilAuthContainerBase.

Definition at line 177 of file class.ilAuthContainerECS.php.

References $_GET, $usr_id, ilObject\_lookupObjIdByImportId(), createUser(), Auth_Container\log(), and updateUser().

{
include_once('./Services/WebServices/ECS/classes/class.ilECSUser.php');
$user = new ilECSUser($_GET);
if(!$usr_id = ilObject::_lookupObjIdByImportId($user->getImportId()))
{
$username = $this->createUser($user);
}
else
{
$username = $this->updateUser($user,$usr_id);
}
$a_auth->setAuth($username);
$this->log->write(__METHOD__.': Login succesesful');
return true;
}

+ Here is the call graph for this function:

ilAuthContainerECS::sendNotification (   $user_obj)
private

Send notification.

private

Parameters

Definition at line 331 of file class.ilAuthContainerECS.php.

References $GLOBALS, $lang, ilMail\_getAutoGeneratedMessageString(), ilLanguageFactory\_getLanguage(), and getCurrentServer().

{
if(!count($this->getCurrentServer()->getUserRecipients()))
{
return true;
}
include_once('./Services/Language/classes/class.ilLanguageFactory.php');
$GLOBALS['lng'] = $lang;
$GLOBALS['ilUser'] = $user_obj;
$lang->loadLanguageModule('ecs');
include_once('./Services/Mail/classes/class.ilMail.php');
$mail = new ilMail(6);
$mail->enableSoap(false);
$subject = $lang->txt('ecs_new_user_subject');
// build body
$body = $lang->txt('ecs_new_user_body')."\n\n";
$body .= $lang->txt('ecs_new_user_profile')."\n\n";
$body .= $user_obj->getProfileAsString($lang)."\n\n";
$mail->sendMail(
$this->getCurrentServer()->getUserRecipientsAsString(),
"",
"",
$subject,
$body,
array(),
array("normal")
);
}

+ Here is the call graph for this function:

ilAuthContainerECS::setCurrentServer ( ilECSSetting  $server = null)

Set current server.

Parameters
ilECSSetting$server

Definition at line 86 of file class.ilAuthContainerECS.php.

References $server.

Referenced by fetchData().

{
$this->currentServer = $server;
}

+ Here is the caller graph for this function:

ilAuthContainerECS::updateUser ( ilECSUser  $user,
  $a_local_user_id 
)
protected

update existing user

protected

Definition at line 278 of file class.ilAuthContainerECS.php.

References $ilLog, getCurrentServer(), ilECSUser\getEmail(), ilECSUser\getFirstname(), ilECSUser\getImportId(), ilECSUser\getInstitution(), and ilECSUser\getLastname().

Referenced by loginObserver().

{
global $ilClientIniFile,$ilLog,$rbacadmin;
$user_obj = new ilObjUser($a_local_user_id);
$user_obj->setFirstname($user->getFirstname());
$user_obj->setLastname($user->getLastname());
$user_obj->setEmail($user->getEmail());
$user_obj->setInstitution($user->getInstitution());
$until = $user_obj->getTimeLimitUntil();
$user_obj->setTimeLimitFrom(time() - 5);
if($until < (time() + $ilClientIniFile->readVariable('session','expire')))
{
$user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session","expire"));
}
$user_obj->update();
$user_obj->refreshLogin();
if($global_role = $this->getCurrentServer()->getGlobalRole())
{
$rbacadmin->assignUser(
$this->getCurrentServer()->getGlobalRole(),
$user_obj->getId(),
true
);
}
$ilLog->write(__METHOD__.': Finished update of remote user with usr_id: '.$user->getImportId());
return $user_obj->getLogin();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAuthContainerECS::validateHash ( )

Validate ECS hash.

public

Parameters
stringusername
stringpass

Definition at line 150 of file class.ilAuthContainerECS.php.

References $_GET, $ilLog, $res, and getCurrentServer().

Referenced by fetchData().

{
global $ilLog;
// Check if hash is valid ...
try
{
include_once('./Services/WebServices/ECS/classes/class.ilECSConnector.php');
$connector = new ilECSConnector($this->getCurrentServer());
$res = $connector->getAuth($_GET['ecs_hash']);
$auths = $res->getResult();
$this->abreviation = $auths->abbr;
$ilLog->write(__METHOD__.': Got abr: '.$this->abreviation);
return true;
}
{
$ilLog->write(__METHOD__.': Authentication failed with message: '.$e->getMessage());
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilAuthContainerECS::$abreviation = null
protected

Definition at line 37 of file class.ilAuthContainerECS.php.

Referenced by getAbreviation().

ilAuthContainerECS::$currentServer = null
protected

Definition at line 39 of file class.ilAuthContainerECS.php.

Referenced by getCurrentServer().

ilAuthContainerECS::$log
protected

Definition at line 42 of file class.ilAuthContainerECS.php.

ilAuthContainerECS::$mid = null
protected

Definition at line 36 of file class.ilAuthContainerECS.php.

Referenced by getMID().

ilAuthContainerECS::$servers = null
protected

Definition at line 40 of file class.ilAuthContainerECS.php.

Referenced by getServerSettings().


The documentation for this class was generated from the following file: