ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilBaseAuthentication Class Reference
+ Inheritance diagram for ilBaseAuthentication:
+ Collaboration diagram for ilBaseAuthentication:

Public Member Functions

 __construct ()
 
 setClient ($a_client)
 
 getClient ()
 
 setUsername ($a_username)
 
 getUsername ()
 
 setPassword ($a_password)
 
 getPassword ()
 
 setSid ($a_sid)
 
 getSid ()
 
 getMessage ()
 
 getMessageCode ()
 
 __setMessage ($a_message)
 
 __setMessageCode ($a_message_code)
 
 setPasswordType ($a_type)
 
 getPasswordType ()
 
 authenticate ()
 
 start ()
 
 validateSession ()
 
 logout ()
 
 __buildDSN ()
 
 __buildAuth ()
 
 __setSessionSaveHandler ()
 
 __getAuthStatus ()
 

Data Fields

 $auth = null
 
 $sid = ''
 
 $username = ''
 
 $password = ''
 
 $client = ''
 

Detailed Description

Definition at line 19 of file class.ilBaseAuthentication.php.

Constructor & Destructor Documentation

◆ __construct()

ilBaseAuthentication::__construct ( )

Definition at line 55 of file class.ilBaseAuthentication.php.

References __setMessage(), and __setMessageCode().

56  {
57  $this->__setMessage('');
58  $this->__setMessageCode('Client');
59  $this->check_setting = true;
60  }
+ Here is the call graph for this function:

Member Function Documentation

◆ __buildAuth()

ilBaseAuthentication::__buildAuth ( )

Definition at line 275 of file class.ilBaseAuthentication.php.

References array, getClient(), getPasswordType(), and IL_AUTH_MD5.

Referenced by ilSoapAuthentication\authenticate(), authenticate(), ilSoapAuthentication\validateSession(), and validateSession().

276  {
277 
278  // BEGIN WebDAV
279  // The realm is needed to support a common session between Auth_HTTP and Auth.
280  // It also helps us to distinguish between parallel sessions run on different clients.
281  // Common session only works if we use a common session name starting with "_authhttp".
282  // We must use the "_authttp" prefix, because it is hardcoded in the session name of
283  // class Auth_HTTP.
284  // Note: The realm and sessionName used here, must be the same as in
285  // class ilAuthUtils. Otherwise, Soap clients won't be able to log
286  // in to ILIAS.
287  $realm = $this->getClient();
288  // END WebDAV
289 
290  $this->auth_params = array(
291  'dsn' => $this->db->getDSN(),
292  'table' => $this->ini->readVariable("auth", "table"),
293  'usernamecol' => $this->ini->readVariable("auth", "usercol"),
294  'passwordcol' => $this->ini->readVariable("auth", "passcol"),
295  'sessionName' => "_authhttp".md5($realm)
296  );
297 
298  if($this->getPasswordType() == IL_AUTH_MD5)
299  {
300  $this->auth_params['cryptType'] = 'none';
301  }
302 
303  include_once './Services/Authentication/classes/class.ilAuthContainerDatabase.php';
304  $authContainerDB = new ilAuthContainerDatabase($this->auth_params);
305  $this->auth = new Auth($authContainerDB, $this->auth_params,"",false);
306 
307  return true;
308  }
Storage driver for fetching login data from a database.
const IL_AUTH_MD5
base authentication class
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildDSN()

ilBaseAuthentication::__buildDSN ( )

Definition at line 244 of file class.ilBaseAuthentication.php.

References __setMessage(), __setMessageCode(), and getClient().

Referenced by ilSoapAuthentication\authenticate(), authenticate(), and ilSoapAuthentication\validateSession().

245  {
246  include_once './Services/Init/classes/class.ilIniFile.php';
247 
248  // get ilias ini file
249  $this->ilias_ini = new ilIniFile('./ilias.ini.php');
250  $this->ilias_ini->read();
251 
252  if(!@file_exists("./".$this->ilias_ini->readVariable('clients','path')."/".$this->getClient()."/client.ini.php"))
253  {
254  $this->__setMessageCode('Client');
255  $this->__setMessage('Client does not exist');
256 
257  return false;
258  }
259 
260  $this->ini = new ilIniFile("./".$this->ilias_ini->readVariable('clients','path')."/".$this->getClient()."/client.ini.php");
261  $this->ini->read();
262 
263  include_once("./Services/Database/classes/class.ilDBWrapperFactory.php");
264  $this->db = ilDBWrapperFactory::getWrapper($this->ini->readVariable("db","type"),
265  $this->ini->readVariable("db","inactive_mysqli"));
266  $this->db->setDBUser($this->ini->readVariable("db", "user"));
267  $this->db->setDBPassword($this->ini->readVariable("db", "pass"));
268  $this->db->setDBName($this->ini->readVariable("db", "name"));
269  $this->db->setDBHost($this->ini->readVariable("db", "host"));
270  $this->dsn = $this->db->getDSN();
271 
272  return true;
273  }
INIFile Parser.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getAuthStatus()

ilBaseAuthentication::__getAuthStatus ( )

Definition at line 336 of file class.ilBaseAuthentication.php.

References __setMessage(), and __setMessageCode().

Referenced by ilSoapAuthentication\authenticate(), and authenticate().

337  {
338  switch($this->auth->getStatus())
339  {
340  case AUTH_EXPIRED:
341  $this->__setMessageCode('Server');
342  $this->__setMessage('Session expired');
343 
344  return false;
345 
346  case AUTH_IDLED:
347  $this->__setMessageCode('Server');
348  $this->__setMessage('Session idled');
349 
350  return false;
351 
352  case AUTH_WRONG_LOGIN:
353  default:
354  $this->__setMessageCode('Client');
355  $this->__setMessage('Wrong Login or Password');
356 
357  return false;
358 
359 
360  }
361  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __setMessage()

ilBaseAuthentication::__setMessage (   $a_message)

◆ __setMessageCode()

ilBaseAuthentication::__setMessageCode (   $a_message_code)

Definition at line 113 of file class.ilBaseAuthentication.php.

Referenced by __buildDSN(), ilSoapAuthentication\__construct(), __construct(), __getAuthStatus(), __setSessionSaveHandler(), ilSoapAuthentication\authenticate(), and ilSoapAuthentication\validateSession().

114  {
115  $this->message_code = $a_message_code;
116  }
+ Here is the caller graph for this function:

◆ __setSessionSaveHandler()

ilBaseAuthentication::__setSessionSaveHandler ( )

Definition at line 310 of file class.ilBaseAuthentication.php.

References $GLOBALS, __setMessage(), and __setMessageCode().

Referenced by ilSoapAuthentication\authenticate(), authenticate(), ilSoapAuthentication\validateSession(), and validateSession().

311  {
312  require_once "./Services/Authentication/classes/class.ilSessionDBHandler.php";
313  include_once "./Services/Utilities/classes/class.ilUtil.php";
314  include_once './Services/Init/classes/class.ilErrorHandling.php';
315  include_once './Services/Database/classes/MDB2/class.ilDB.php';
316 
317  $this->db->connect();
318  $GLOBALS['ilDB'] = $this->db;
319 
320  if(ini_get('session.save_handler') != 'user')
321  {
322  ini_set("session.save_handler", "user");
323  }
324  $db_session_handler = new ilSessionDBHandler();
325  if (!$db_session_handler->setSaveHandler())
326  {
327  $this->__setMessageCode('Server');
328  $this->__setMessage('Cannot set session handler');
329 
330  return false;
331  }
332 
333  return true;
334  }
Database Session Handling.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ authenticate()

ilBaseAuthentication::authenticate ( )

Definition at line 127 of file class.ilBaseAuthentication.php.

References __buildAuth(), __buildDSN(), __getAuthStatus(), __setMessage(), __setSessionSaveHandler(), getClient(), getUsername(), and setSid().

128  {
129  if(!$this->getClient())
130  {
131  $this->__setMessage('No client given');
132  return false;
133  }
134  if(!$this->getUsername())
135  {
136  $this->__setMessage('No username given');
137  return false;
138  }
139  // Read ilias ini
140  if(!$this->__buildDSN())
141  {
142  return false;
143  }
144  if(!$this->__setSessionSaveHandler())
145  {
146  return false;
147  }
148  if(!$this->__buildAuth())
149  {
150  return false;
151  }
152  $this->auth->start();
153 
154  if(!$this->auth->getAuth())
155  {
156  $this->__getAuthStatus();
157 
158  return false;
159  }
160 
161  $this->setSid(session_id());
162 
163  return true;
164  }
+ Here is the call graph for this function:

◆ getClient()

ilBaseAuthentication::getClient ( )

Definition at line 69 of file class.ilBaseAuthentication.php.

References $client.

Referenced by __buildAuth(), __buildDSN(), ilSoapAuthentication\authenticate(), authenticate(), logout(), ilSoapAuthentication\validateSession(), and validateSession().

+ Here is the caller graph for this function:

◆ getMessage()

ilBaseAuthentication::getMessage ( )

Definition at line 101 of file class.ilBaseAuthentication.php.

102  {
103  return $this->message;
104  }

◆ getMessageCode()

ilBaseAuthentication::getMessageCode ( )

Definition at line 105 of file class.ilBaseAuthentication.php.

106  {
107  return $this->message_code;
108  }

◆ getPassword()

ilBaseAuthentication::getPassword ( )

Definition at line 87 of file class.ilBaseAuthentication.php.

References $password.

◆ getPasswordType()

ilBaseAuthentication::getPasswordType ( )

Definition at line 122 of file class.ilBaseAuthentication.php.

References IL_AUTH_PLAIN.

Referenced by __buildAuth().

123  {
124  return isset($this->password_type) ? $this->password_type : IL_AUTH_PLAIN;
125  }
const IL_AUTH_PLAIN
+ Here is the caller graph for this function:

◆ getSid()

ilBaseAuthentication::getSid ( )

Definition at line 96 of file class.ilBaseAuthentication.php.

References $sid.

Referenced by logout(), start(), ilSoapAuthentication\validateSession(), and validateSession().

+ Here is the caller graph for this function:

◆ getUsername()

ilBaseAuthentication::getUsername ( )

Definition at line 78 of file class.ilBaseAuthentication.php.

References $username.

Referenced by ilSoapAuthentication\__checkAgreement(), ilSoapAuthentication\authenticate(), and authenticate().

+ Here is the caller graph for this function:

◆ logout()

ilBaseAuthentication::logout ( )

Definition at line 212 of file class.ilBaseAuthentication.php.

References __setMessage(), getClient(), and getSid().

213  {
214  if(!$this->getClient())
215  {
216  $this->__setMessage('No client given');
217  return false;
218  }
219  if(!$this->getSid())
220  {
221  $this->__setMessage('No session id given');
222  return false;
223  }
224  // logged auth users are authenticated
225  // No preperations are required
226  #if(!$this->__buildAuth())
227  #{
228  # return false;
229  #}
230  #if(!$this->__setSessionSaveHandler())
231  #{
232  # return false;
233  #}
234 
235  // And finally logout
236  #$this->auth->start();
237  $this->auth->logout();
238  session_destroy();
239 
240  return true;
241 
242  }
+ Here is the call graph for this function:

◆ setClient()

ilBaseAuthentication::setClient (   $a_client)

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

References $_COOKIE.

65  {
66  $this->client = $a_client;
67  $_COOKIE['ilClientId'] = $a_client;
68  }
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15

◆ setPassword()

ilBaseAuthentication::setPassword (   $a_password)

Definition at line 82 of file class.ilBaseAuthentication.php.

References $_POST.

83  {
84  $this->password = $a_password;
85  $_POST['password'] = $a_password;
86  }
$_POST["username"]

◆ setPasswordType()

ilBaseAuthentication::setPasswordType (   $a_type)

Definition at line 118 of file class.ilBaseAuthentication.php.

References $a_type.

119  {
120  $this->password_type = $a_type;
121  }
$a_type
Definition: workflow.php:93

◆ setSid()

ilBaseAuthentication::setSid (   $a_sid)

Definition at line 91 of file class.ilBaseAuthentication.php.

References $_COOKIE, and $sid.

Referenced by ilSoapAuthentication\authenticate(), and authenticate().

92  {
93  $this->sid = $a_sid;
94  $_COOKIE['PHPSESSID'] = $this->sid;
95  }
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15
+ Here is the caller graph for this function:

◆ setUsername()

ilBaseAuthentication::setUsername (   $a_username)

Definition at line 73 of file class.ilBaseAuthentication.php.

References $_POST.

74  {
75  $this->username = $a_username;
76  $_POST['username'] = $a_username;
77  }
$_POST["username"]

◆ start()

ilBaseAuthentication::start ( )

Definition at line 166 of file class.ilBaseAuthentication.php.

References __setMessage(), and getSid().

167  {
168  if(!$this->getSid())
169  {
170  $this->__setMessage('No session id given');
171  return false;
172  }
173 
174  $this->auth->start();
175 
176  return true;
177  }
+ Here is the call graph for this function:

◆ validateSession()

ilBaseAuthentication::validateSession ( )

Definition at line 179 of file class.ilBaseAuthentication.php.

References __buildAuth(), __setMessage(), __setSessionSaveHandler(), getClient(), and getSid().

180  {
181  if(!$this->getClient())
182  {
183  $this->__setMessage('No client given');
184  return false;
185  }
186  if(!$this->getSid())
187  {
188  $this->__setMessage('No session id given');
189  return false;
190  }
191 
192  if(!$this->__buildAuth())
193  {
194  return false;
195  }
196  if(!$this->__setSessionSaveHandler())
197  {
198  return false;
199  }
200 
201  $this->auth->start();
202  if(!$this->auth->getAuth())
203  {
204  $this->__setMessage('Session not valid');
205 
206  return false;
207  }
208 
209  return true;
210  }
+ Here is the call graph for this function:

Field Documentation

◆ $auth

ilBaseAuthentication::$auth = null

Definition at line 26 of file class.ilBaseAuthentication.php.

◆ $client

ilBaseAuthentication::$client = ''

Definition at line 53 of file class.ilBaseAuthentication.php.

Referenced by getClient().

◆ $password

ilBaseAuthentication::$password = ''

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

Referenced by getPassword().

◆ $sid

ilBaseAuthentication::$sid = ''

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

Referenced by getSid(), and setSid().

◆ $username

ilBaseAuthentication::$username = ''

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

Referenced by getUsername().


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