ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAuthContainerSOAP Class Reference

Authentication against external SOAP server More...

+ Inheritance diagram for ilAuthContainerSOAP:
+ Collaboration diagram for ilAuthContainerSOAP:

Public Member Functions

 __construct ()
 Constructor. More...
 
 initClient ()
 Init soap client. More...
 
 fetchData ($a_username, $a_password, $isChallengeResponse=false)
 Call is isValidSession of soap server. More...
 
 loginObserver ($a_username, $a_auth)
 Called after login and successful call of fetch data. More...
 

Protected Attributes

 $server_host = null
 
 $server_port = null
 
 $server_uri = null
 
 $server_https = null
 
 $server_nms = null
 
 $use_dot_net = null
 
 $uri = null
 
 $client = null
 
 $response = null
 

Detailed Description

Authentication against external SOAP server

Todo:
This class should inherit either from Auth_Container_SOAP or Auth_Container_SOAP5
Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$id$

Definition at line 35 of file class.ilAuthContainerSOAP.php.

Constructor & Destructor Documentation

◆ __construct()

ilAuthContainerSOAP::__construct ( )

Constructor.

Definition at line 52 of file class.ilAuthContainerSOAP.php.

References $_GET, $_POST, and initClient().

53  {
54  $_POST['username'] = $_GET['ext_uid'];
55  $_POST['password'] = $_GET['soap_pw'];
56 
57  parent::__construct();
58  $this->initClient();
59  }
initClient()
Init soap client.
$_GET["client_id"]
$_POST["username"]
+ Here is the call graph for this function:

Member Function Documentation

◆ fetchData()

ilAuthContainerSOAP::fetchData (   $a_username,
  $a_password,
  $isChallengeResponse = false 
)

Call is isValidSession of soap server.

Returns
bool
Parameters
string$a_username
string$a_password
bool$isChallengeResponse,[optional]

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

References $GLOBALS, $new_user, $valid, and ilObjUser\_checkExternalAuthAccount().

96  {
97  $GLOBALS['ilLog']->write(__METHOD__ . ': Soap auth fetch data');
98 
99  // check whether external user exists in ILIAS database
100  $local_user = ilObjUser::_checkExternalAuthAccount("soap", $a_username);
101 
102  if ($local_user == "") {
103  $new_user = true;
104  } else {
105  $new_user = false;
106  }
107 
108  $soapAction = "";
109  $nspref = "";
110  if ($this->use_dotnet) {
111  $soapAction = $this->server_nms . "/isValidSession";
112  $nspref = "ns1:";
113  }
114  $valid = $this->client->call(
115  'isValidSession',
116  array($nspref . 'ext_uid' => $a_username,
117  $nspref . 'soap_pw' => $a_password,
118  $nspref . 'new_user' => $new_user),
119  $this->server_nms,
120  $soapAction
121  );
122  //echo "<br>== Request ==";
123  //echo '<br><pre>' . htmlspecialchars($this->soap_client->request, ENT_QUOTES) . '</pre><br>';
124  //echo "<br>== Response ==";
125  //echo "<br>Valid: -".$valid["valid"]."-";
126  //echo '<br><pre>' . htmlspecialchars($this->soap_client->response, ENT_QUOTES) . '</pre>';
127 
128  if (trim($valid["valid"]) == "false") {
129  $valid["valid"] = false;
130  }
131 
132  // to do check SOAP error!?
133  $valid["local_user"] = $local_user;
134  $this->response = $valid;
135  return $valid['valid'] == true;
136  }
$valid
static _checkExternalAuthAccount($a_auth, $a_account, $tryFallback=true)
check whether external account and authentication method matches with a user
$new_user
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

◆ initClient()

ilAuthContainerSOAP::initClient ( )

Init soap client.

Returns

Definition at line 65 of file class.ilAuthContainerSOAP.php.

References $ilSetting, $server_host, $server_port, and $server_uri.

Referenced by __construct().

66  {
67  global $ilSetting;
68 
69  $this->server_host = $ilSetting->get('soap_auth_server');
70  $this->server_port = $ilSetting->get('soap_auth_port');
71  $this->server_uri = $ilSetting->get('soap_auth_uri');
72  $this->server_https = $ilSetting->get('soap_auth_use_https');
73  $this->server_nms = $ilSetting->get('soap_auth_namespace');
74  $this->use_dot_net = $ilSetting->get('use_dotnet');
75 
76  $this->uri = $this->server_https ? 'https://' : 'http://';
77  $this->uri .= $this->server_host;
78 
79  if ($this->server_port > 0) {
80  $this->uri .= (':' . $this->server_port);
81  }
82  if ($this->server_uri) {
83  $this->uri .= ('/' . $this->server_uri);
84  }
85  $this->client = new nusoap_client($this->uri);
86  }
[nu]soapclient higher level class for easy usage.
Definition: nusoap.php:7072
global $ilSetting
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ loginObserver()

ilAuthContainerSOAP::loginObserver (   $a_username,
  $a_auth 
)

Called after login and successful call of fetch data.

Returns
Parameters
object$a_username
object$a_auth

Definition at line 144 of file class.ilAuthContainerSOAP.php.

References $GLOBALS, $ilSetting, $lng, ilAuthUtils\_generateLogin(), ilObjUserFolder\_lookupNewAccountMail(), AUTH_SOAP_NO_ILIAS_USER, ilUtil\generatePasswords(), IL_PASSWD_CRYPTED, and IL_PASSWD_PLAIN.

145  {
146  global $ilias, $rbacadmin, $lng, $ilSetting;
147 
148  $GLOBALS['ilLog']->write(__METHOD__ . ': SOAP login observer called');
149 
150 
151  // TODO: handle passed credentials via GET
152  /*
153  if (empty($_GET["ext_uid"]) || empty($_GET["soap_pw"]))
154  {
155  $this->status = AUTH_WRONG_LOGIN;
156  return;
157  }
158  */
159 
160  // Not required anymore
161  /*
162  $validation_data = $this->validateSoapUser($_GET["ext_uid"], $_GET["soap_pw"]);
163 
164  if (!$validation_data["valid"])
165  {
166  $this->status = AUTH_WRONG_LOGIN;
167  return;
168  }
169  */
170 
171  $local_user = $this->response["local_user"];
172  if ($local_user != "") {
173  // to do: handle update of user
174  $a_auth->setAuth($local_user);
175  return true;
176  }
177  if (!$ilSetting->get("soap_auth_create_users")) {
178  $a_auth->status = AUTH_SOAP_NO_ILIAS_USER;
179  $a_auth->logout();
180  return false;
181  }
182 
183  $userObj = new ilObjUser();
184  $local_user = ilAuthUtils::_generateLogin($a_username);
185 
186  $newUser["firstname"] = $this->response["firstname"];
187  $newUser["lastname"] = $this->response["lastname"];
188  $newUser["email"] = $this->response["email"];
189 
190  $newUser["login"] = $local_user;
191 
192  // to do: set valid password and send mail
193  $newUser["passwd"] = "";
194  $newUser["passwd_type"] = IL_PASSWD_CRYPTED;
195 
196  // generate password, if local authentication is allowed
197  // and account mail is activated
198  $pw = "";
199 
200  if ($ilSetting->get("soap_auth_allow_local") &&
201  $ilSetting->get("soap_auth_account_mail")) {
202  $pw = ilUtil::generatePasswords(1);
203  $pw = $pw[0];
204  $newUser["passwd"] = $pw;
205  $newUser["passwd_type"] = IL_PASSWD_PLAIN;
206  }
207 
208  //$newUser["gender"] = "m";
209  $newUser["auth_mode"] = "soap";
210  $newUser["ext_account"] = $a_username;
211  $newUser["profile_incomplete"] = 1;
212 
213  // system data
214  $userObj->assignData($newUser);
215  $userObj->setTitle($userObj->getFullname());
216  $userObj->setDescription($userObj->getEmail());
217 
218  // set user language to system language
219  $userObj->setLanguage($lng->lang_default);
220 
221  // Time limit
222  $userObj->setTimeLimitOwner(7);
223  $userObj->setTimeLimitUnlimited(1);
224  $userObj->setTimeLimitFrom(time());
225  $userObj->setTimeLimitUntil(time());
226 
227  // Create user in DB
228  $userObj->setOwner(0);
229  $userObj->create();
230  $userObj->setActive(1);
231 
232  $userObj->updateOwner();
233 
234  //insert user data in table user_data
235  $userObj->saveAsNew(false);
236 
237  // setup user preferences
238  $userObj->writePrefs();
239 
240  // to do: test this
241  $rbacadmin->assignUser($ilSetting->get('soap_auth_user_default_role'), $userObj->getId(), true);
242 
243  // send account mail
244  if ($ilSetting->get("soap_auth_account_mail")) {
245  include_once('./Services/User/classes/class.ilObjUserFolder.php');
246  $amail = ilObjUserFolder::_lookupNewAccountMail($ilSetting->get("language"));
247  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
248  include_once("Services/Mail/classes/class.ilAccountMail.php");
249  $acc_mail = new ilAccountMail();
250 
251  if ($pw != "") {
252  $acc_mail->setUserPassword($pw);
253  }
254  $acc_mail->setUser($userObj);
255  $acc_mail->send();
256  }
257  }
258 
259  unset($userObj);
260  $a_auth->setAuth($local_user);
261  return true;
262  }
const IL_PASSWD_PLAIN
const IL_PASSWD_CRYPTED
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
static generatePasswords($a_number)
Generate a number of passwords.
$lng
const AUTH_SOAP_NO_ILIAS_USER
static _lookupNewAccountMail($a_lang)
global $ilSetting
Definition: privfeed.php:17
Class ilAccountMail.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

Field Documentation

◆ $client

ilAuthContainerSOAP::$client = null
protected

Definition at line 46 of file class.ilAuthContainerSOAP.php.

◆ $response

ilAuthContainerSOAP::$response = null
protected

Definition at line 47 of file class.ilAuthContainerSOAP.php.

◆ $server_host

ilAuthContainerSOAP::$server_host = null
protected

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

Referenced by initClient().

◆ $server_https

ilAuthContainerSOAP::$server_https = null
protected

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

◆ $server_nms

ilAuthContainerSOAP::$server_nms = null
protected

Definition at line 41 of file class.ilAuthContainerSOAP.php.

◆ $server_port

ilAuthContainerSOAP::$server_port = null
protected

Definition at line 38 of file class.ilAuthContainerSOAP.php.

Referenced by initClient().

◆ $server_uri

ilAuthContainerSOAP::$server_uri = null
protected

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

Referenced by initClient().

◆ $uri

ilAuthContainerSOAP::$uri = null
protected

Definition at line 44 of file class.ilAuthContainerSOAP.php.

◆ $use_dot_net

ilAuthContainerSOAP::$use_dot_net = null
protected

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


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