Public Member Functions

ilCASAuth Class Reference

Class CASAuth. More...

Inheritance diagram for ilCASAuth:
Collaboration diagram for ilCASAuth:

Public Member Functions

 ilCASAuth ($a_params)
 Constructor public.
 checkCASAuth ()
 check cas autehntication
 forceCASAuth ()
 getCASUser ()
 login ()
 Checks if the current user is authenticated yet public.
 logout ()
 Register variable in a session telling that the user has logged in successfully.

Detailed Description

Class CASAuth.

CAS Authentication class.

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


Member Function Documentation

ilCASAuth::checkCASAuth (  ) 

check cas autehntication

can be called before forceAuthentication, but forceAuthentication must be called afterwards

Definition at line 64 of file class.ilCASAuth.php.

References $PHPCAS_CLIENT.

        {
                global $PHPCAS_CLIENT;

                return $PHPCAS_CLIENT->isAuthenticated();
        }

ilCASAuth::forceCASAuth (  ) 

Definition at line 71 of file class.ilCASAuth.php.

        {
                phpCAS::forceAuthentication();
        }

ilCASAuth::getCASUser (  ) 

Definition at line 76 of file class.ilCASAuth.php.

References getUser().

        {
                return phpCAS::getUser();
        }

Here is the call graph for this function:

ilCASAuth::ilCASAuth ( a_params  ) 

Constructor public.

Definition at line 43 of file class.ilCASAuth.php.

        {
                parent::Auth("");
                
                include_once("./Services/CAS/phpcas/source/CAS/CAS.php");
                $this->server_version = CAS_VERSION_2_0;
                $this->server_hostname = $a_params["server_hostname"];
                $this->server_port = (int) $a_params["server_port"];
                $this->server_uri = $a_params["server_uri"];

                phpCAS::setDebug();
                phpCAS::client($this->server_version, $this->server_hostname,
                        $this->server_port, $this->server_uri);
        }

ilCASAuth::login (  ) 

Checks if the current user is authenticated yet public.

Returns:
boolean true if user is authenticated Set the maximum idle time
Parameters:
integer time in seconds
bool add time to current maximum idle time or not
Returns:
void public Set the maximum expire time
Parameters:
integer time in seconds
bool add time to current expire time or not
Returns:
void public Checks if there is a session with valid auth information.

private

Returns:
boolean Whether or not the user is authenticated. Start new auth session public
void Login function private
void

Definition at line 205 of file class.ilCASAuth.php.

References $ilias, $rbacadmin, ilObjUser::_checkExternalAuthAccount(), ilAuthUtils::_generateLogin(), getUser(), and logout().

        {
                global $ilias, $rbacadmin, $ilSetting;

                if (phpCAS::getUser() != "")
                {
                        $username = phpCAS::getUser();

                        // Authorize this user
                        include_once("classes/class.ilObjUser.php");
                        $local_user = ilObjUser::_checkExternalAuthAccount("cas", $username);

                        if ($local_user != "")
                        {
                                $this->setAuth($local_user);
                        }
                        else
                        {
                                if (!$ilSetting->get("cas_create_users"))
                                {
                                        $this->status = AUTH_CAS_NO_ILIAS_USER;
                                        $this->logout();
                                        return;
                                }
                                
                                $userObj = new ilObjUser();
                                
                                $local_user = ilAuthUtils::_generateLogin($username);
                                
                                $newUser["firstname"] = $local_user;
                                $newUser["lastname"] = "";
                                
                                $newUser["login"] = $local_user;
                                
                                // set "plain md5" password (= no valid password)
                                $newUser["passwd"] = ""; 
                                $newUser["passwd_type"] = IL_PASSWD_MD5;
                                                                
                                //$newUser["gender"] = "m";
                                $newUser["auth_mode"] = "cas";
                                $newUser["ext_account"] = $username;
                                $newUser["profile_incomplete"] = 1;
                                
                                // 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(1);
                                $userObj->setTimeLimitFrom(time());
                                $userObj->setTimeLimitUntil(time());
                                                                
                                // Create user in DB
                                $userObj->setOwner(6);
                                $userObj->create();
                                $userObj->setActive(1, 6);
                                
                                $userObj->updateOwner();
                                
                                //insert user data in table user_data
                                $userObj->saveAsNew();
                                
                                // setup user preferences
                                $userObj->writePrefs();
                                
                                // to do: test this
                                $rbacadmin->assignUser($ilSetting->get('cas_user_default_role'), $userObj->getId(),true);

                                unset($userObj);
                                
                                $this->setAuth($local_user);

                        }
                }
                else
                {
                        // This should never occur unless CAS is not configured properly
                        $this->status = AUTH_WRONG_LOGIN;
                }
        }

Here is the call graph for this function:

ilCASAuth::logout (  ) 

Register variable in a session telling that the user has logged in successfully.

public

Parameters:
string Username
Returns:
void Logout function This function clears any auth tokens in the currently active session and executes the logout callback function, if any

public

Returns:
void

Definition at line 333 of file class.ilCASAuth.php.

Referenced by login().

        {
                parent::logout();
                //PHPCAS::logout();             // CAS logout should be provided separately
                                                                // maybe on ILISA login screen
        }

Here is the caller graph for this function:


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