ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilBaseAuthentication Class Reference
+ Inheritance diagram for ilBaseAuthentication:
+ Collaboration diagram for ilBaseAuthentication:

Public Member Functions

 ilBaseAuthentication ()
 
 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.

Member Function Documentation

◆ __buildAuth()

ilBaseAuthentication::__buildAuth ( )

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

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 }
const IL_AUTH_MD5
base authentication class
Storage driver for fetching login data from a database.

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

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

+ 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.

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 }
static getWrapper($a_type, $a_inactive_mysqli=null)
INIFile Parser.

References __setMessage(), __setMessageCode(), and ilDBWrapperFactory\getWrapper().

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

+ 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.

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 }
const AUTH_EXPIRED
Returned if session has expired.
Definition: Auth.php:34
const AUTH_WRONG_LOGIN
Returned if container is unable to authenticate user/password pair.
Definition: Auth.php:38
const AUTH_IDLED
Returned if session exceeds idle time.
Definition: Auth.php:30

References __setMessage(), __setMessageCode(), AUTH_EXPIRED, AUTH_IDLED, and AUTH_WRONG_LOGIN.

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

+ 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.

114 {
115 $this->message_code = $a_message_code;
116 }

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

+ Here is the caller graph for this function:

◆ __setSessionSaveHandler()

ilBaseAuthentication::__setSessionSaveHandler ( )

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

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/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['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ authenticate()

ilBaseAuthentication::authenticate ( )

Reimplemented in ilSoapAuthentication.

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

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 }

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

+ 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(), authenticate(), ilSoapAuthentication\authenticate(), logout(), validateSession(), and ilSoapAuthentication\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.

123 {
124 return isset($this->password_type) ? $this->password_type : IL_AUTH_PLAIN;
125 }
const IL_AUTH_PLAIN

References IL_AUTH_PLAIN.

Referenced by __buildAuth().

+ 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(), validateSession(), and ilSoapAuthentication\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(), authenticate(), and ilSoapAuthentication\authenticate().

+ Here is the caller graph for this function:

◆ ilBaseAuthentication()

ilBaseAuthentication::ilBaseAuthentication ( )

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

56 {
57 $this->__setMessage('');
58 $this->__setMessageCode('Client');
59 $this->check_setting = true;
60 }

References __setMessage(), and __setMessageCode().

+ Here is the call graph for this function:

◆ logout()

ilBaseAuthentication::logout ( )

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

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 }

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

+ Here is the call graph for this function:

◆ setClient()

ilBaseAuthentication::setClient (   $a_client)

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

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

References $_COOKIE.

◆ setPassword()

ilBaseAuthentication::setPassword (   $a_password)

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

83 {
84 $this->password = $a_password;
85 $_POST['password'] = $a_password;
86 }
$_POST['username']
Definition: cron.php:12

References $_POST.

◆ setPasswordType()

ilBaseAuthentication::setPasswordType (   $a_type)

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

119 {
120 $this->password_type = $a_type;
121 }

◆ setSid()

ilBaseAuthentication::setSid (   $a_sid)

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

92 {
93 $this->sid = $a_sid;
94 $_COOKIE['PHPSESSID'] = $this->sid;
95 }

References $_COOKIE, and $sid.

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

+ Here is the caller graph for this function:

◆ setUsername()

ilBaseAuthentication::setUsername (   $a_username)

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

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

References $_POST.

◆ start()

ilBaseAuthentication::start ( )

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

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 }

References __setMessage(), and getSid().

+ Here is the call graph for this function:

◆ validateSession()

ilBaseAuthentication::validateSession ( )

Reimplemented in ilSoapAuthentication.

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

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 }

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

+ 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: