Public Member Functions | Data Fields

ilSOAPAuth Class Reference

Class SOAPAuth. More...

Inheritance diagram for ilSOAPAuth:
Collaboration diagram for ilSOAPAuth:

Public Member Functions

 ilSOAPAuth ($a_params)
 Constructor public.
 validateSOAPUser ($a_ext_uid, $a_soap_pw)
 soap validation lookup: call isValidSession service of soap server
 getValidationData ()
 Get validation data.
 login ()
 Login function.
 logout ()
 Register variable in a session telling that the user has logged in successfully.

Data Fields

 $valid = array()

Detailed Description

Class SOAPAuth.

SOAP Authentication class.

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


Member Function Documentation

ilSOAPAuth::getValidationData (  ) 

Get validation data.

Definition at line 129 of file class.ilSOAPAuth.php.

        {
                return $this->valid;
        }

ilSOAPAuth::ilSOAPAuth ( a_params  ) 

Constructor public.

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

        {
                parent::Auth("");
                
                $this->server_hostname = $a_params["server_hostname"];
                $this->server_port = (int) $a_params["server_port"];
                $this->server_uri = $a_params["server_uri"];
                $this->namespace = $a_params["namespace"];
                $this->use_dotnet = $a_params["use_dotnet"];
                if ($a_params["https"])
                {
                        $this->https = true;
                        $uri = "https://";
                }
                else
                {
                        $this->https = false;
                        $uri = "http://";
                }
                
                $uri.= $this->server_hostname;
                
                if ($this->server_port > 0)
                {
                        $uri.= ":".$this->server_port;
                }

                if ($this->server_uri != "")
                {
                        $uri.= "/".$this->server_uri;
                }
                
                $this->uri = $uri;

                $this->soap_client = new soap_client($this->uri);
                
                if ($err = $this->soap_client->getError()) 
                {
                        die("SOAP Authentication Initialisation Error: ".$err);
                }
        }

ilSOAPAuth::login (  ) 

Login function.

private

Returns:
void

Definition at line 140 of file class.ilSOAPAuth.php.

References $_GET, $_POST, $ilias, $lng, $rbacadmin, ilObjUser::_checkPassword(), ilAuthUtils::_generateLogin(), ilObjUser::_getLocalAccountsForEmail(), ilObjUser::_lookupLogin(), ilObjUserFolder::_lookupNewAccountMail(), ilObjUser::_writeAuthMode(), ilObjUser::_writeExternalAccount(), ilUtil::generatePasswords(), and logout().

        {
                global $ilias, $rbacadmin, $lng, $ilSetting;

                if (empty($_GET["ext_uid"]) || empty($_GET["soap_pw"]))
                {
                        $this->status = AUTH_WRONG_LOGIN;
                        return;
                }

                $validation_data = $this->validateSoapUser($_GET["ext_uid"], $_GET["soap_pw"]);
                
                if (!$validation_data["valid"])
                {
                        $this->status = AUTH_WRONG_LOGIN;
                        return;
                }
                
                $local_user = $validation_data["local_user"];
                
                if ($local_user != "")
                {
                        // to do: handle update of user
                        $this->setAuth($local_user);
                }
                else
                {
                        if (!$ilSetting->get("soap_auth_create_users"))
                        {
                                $this->status = AUTH_SOAP_NO_ILIAS_USER;
                                $this->logout();
                                return;
                        }
//echo "1";
                        // try to map external user via e-mail to ILIAS user
                        if ($validation_data["email"] != "")
                        {
//echo "2";
//var_dump ($_POST);
                                $email_user = ilObjUser::_getLocalAccountsForEmail($validation_data["email"]);

                                // check, if password has been provided in user mapping screen
                                // (see ilStartUpGUI::showUserMappingSelection)
                                if ($_POST["LoginMappedUser"] != "")
                                { 
                                        if (count($email_user) > 0)
                                        {
                                                if (ilObjUser::_checkPassword($_POST["usr_id"], $_POST["password"]))
                                                {
                                                        // password is correct -> map user
                                                        //$this->setAuth($local_user); (use login not id)
                                                        ilObjUser::_writeExternalAccount($_POST["usr_id"], $_GET["ext_uid"]);
                                                        ilObjUser::_writeAuthMode($_POST["usr_id"], "soap");
                                                        $_GET["cmd"] = $_POST["cmd"] = $_GET["auth_stat"]= "";
                                                        $local_user = ilObjUser::_lookupLogin($_POST["usr_id"]);
                                                        $this->status = "";
                                                        $this->setAuth($local_user);
                                                        return;
                                                }
                                                else
                                                {
//echo "6"; exit;
                                                        $this->status = AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL;
                                                        $this->sub_status = AUTH_WRONG_LOGIN;
                                                        $this->logout();
                                                        return;
                                                }
                                        }
                                }
                                
                                if (count($email_user) > 0 && $_POST["CreateUser"] == "")
                                {                                       
                                        $_GET["email"] = $validation_data["email"]; 
                                        $this->status = AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL;
                                        $this->logout();
                                        return;
                                }
                        }

                        $userObj = new ilObjUser();
                        
                        $local_user = ilAuthUtils::_generateLogin($_GET["ext_uid"]);
                        
                        $newUser["firstname"] = $validation_data["firstname"];
                        $newUser["lastname"] = $validation_data["lastname"];
                        $newUser["email"] = $validation_data["email"];
                        
                        $newUser["login"] = $local_user;
                        
                        // to do: set valid password and send mail
                        $newUser["passwd"] = ""; 
                        $newUser["passwd_type"] = IL_PASSWD_MD5;
                        
                        // generate password, if local authentication is allowed
                        // and account mail is activated
                        $pw = "";

                        if ($ilSetting->get("soap_auth_allow_local") &&
                                $ilSetting->get("soap_auth_account_mail"))
                        {
                                $pw = ilUtil::generatePasswords(1);
                                $pw = $pw[0];
                                $newUser["passwd"] = md5($pw); 
                                $newUser["passwd_type"] = IL_PASSWD_MD5;
                        }

                        //$newUser["gender"] = "m";
                        $newUser["auth_mode"] = "soap";
                        $newUser["ext_account"] = $_GET["ext_uid"];
                        $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($lng->lang_default);
                        
                        // 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(false);
                        
                        // setup user preferences
                        $userObj->writePrefs();
                        
                        // to do: test this
                        $rbacadmin->assignUser($ilSetting->get('soap_auth_user_default_role'), $userObj->getId(),true);

                        // send account mail
                        if ($ilSetting->get("soap_auth_account_mail"))
                        {
                                include_once("classes/class.ilObjUserFolder.php");
                                $amail = ilObjUserFolder::_lookupNewAccountMail($ilSetting->get("language"));
                                if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
                                {
                                        include_once("classes/class.ilAccountMail.php");
                                        $acc_mail = new ilAccountMail();

                                        if ($pw != "")
                                        {
                                                $acc_mail->setUserPassword($pw);
                                        }
                                        $acc_mail->setUser($userObj);
                                        $acc_mail->send();
                                }
                        }

                        unset($userObj);

                        $this->setAuth($local_user);

                }
        }

Here is the call graph for this function:

ilSOAPAuth::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 348 of file class.ilSOAPAuth.php.

Referenced by login().

Here is the caller graph for this function:

ilSOAPAuth::validateSOAPUser ( a_ext_uid,
a_soap_pw 
)

soap validation lookup: call isValidSession service of soap server

Definition at line 89 of file class.ilSOAPAuth.php.

References $new_user, $valid, and ilObjUser::_checkExternalAuthAccount().

        {
                // check whether external user exists in ILIAS database
                $local_user = ilObjUser::_checkExternalAuthAccount("soap", $a_ext_uid);
                
                if ($local_user == "")
                {
                        $new_user = true;
                }
                else
                {
                        $new_user = false;
                }
                
                $soapAction = "";
                $nspref = "";
                if ($this->use_dotnet)
                {
                        $soapAction = $this->namespace."/isValidSession";
                        $nspref = "ns1:";
                }
                
                $valid = $this->soap_client->call('isValidSession',
                        array($nspref.'ext_uid' => $a_ext_uid,
                                $nspref.'soap_pw' => $a_soap_pw,
                                $nspref.'new_user' => $new_user),
                        $this->namespace,
                        $soapAction);

                // to do check SOAP error!?
                $valid["local_user"] = $local_user;
                
                $this->valid = $valid;
                
                return $valid;
        }

Here is the call graph for this function:


Field Documentation

ilSOAPAuth::$valid = array()

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

Referenced by validateSOAPUser().


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