• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Authentication/classes/class.ilAuthMultiple.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00033 include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
00034 
00035 class ilAuthMultiple
00036 {
00037         protected $settings = null;
00038         protected $auth = null;
00039         protected $auth_modes = null;
00040         protected $current_auth_modes = null;
00041         protected $first_auth_method = true;
00042         
00049         public function __construct()
00050         {
00051                 include_once('./Services/Authentication/classes/class.ilAuthModeDetermination.php');
00052                 $this->settings = ilAuthModeDetermination::_getInstance();
00053                 
00054                 $this->auth_modes = $this->settings->getAuthModeSequence();
00055                 
00056                 $this->initNextAuthObject();
00057                 $this->first_auth_method = false;
00058         }
00059         
00067         public function setIdle($time,$add = false)
00068         {
00069                 $this->auth->setIdle($time,$add);
00070         }
00071         
00077         public function setExpire($time,$add = false)
00078         {
00079                 $this->auth->setExpire($time,$add);
00080         }
00081         
00089         public function logout()
00090         {
00091                 $this->auth->logout();
00092         }
00093         
00101         public function checkAuth()
00102         {
00103                 global $ilLog;
00104                 
00105                 do
00106                 {
00107                         if($this->auth->checkAuth())
00108                         {
00109                                 return true;
00110                         }
00111                         $this->auth->logout();
00112                         
00113                 } 
00114                 while($this->initNextAuthObject());
00115                 
00116                 $ilLog->write(__METHOD__.': Authentication failed.');
00117                 return false;
00118         }
00119         
00127         public function getUsername()
00128         {
00129                 return $this->auth->getUsername();
00130         }
00131         
00139         public function getAuth()
00140         {
00141                 return $this->checkAuth();
00142         }
00143         
00150         public function start()
00151         {
00152                 $this->auth->start();
00153         }
00154         
00162         public function getStatus()
00163         {
00164                 return $this->auth->getStatus();
00165         }
00166         
00167         
00175         private function initNextAuthObject()
00176         {
00177                 global $ilLog,$ilClientIniFile;
00178                 
00179                 if(!$this->current_auth_mode = current($this->auth_modes))
00180                 {
00181                         return false;
00182                 }
00183                 next($this->auth_modes);
00184                 switch($this->current_auth_mode)
00185                 {
00186                         case AUTH_LDAP:
00187                                 $ilLog->write(__METHOD__.': Current Authentication method is LDAP.');
00188                                 include_once 'Services/LDAP/classes/class.ilAuthLDAP.php';
00189                                 $this->auth = new ilAuthLDAP();
00190                                 break;
00191                                 
00192                         case AUTH_RADIUS:
00193                                 $ilLog->write(__METHOD__.': Current Authentication method is RADIUS.');
00194                                 include_once('Services/Radius/classes/class.ilAuthRadius.php');
00195                                 $this->auth = new ilAuthRadius();
00196                                 break;
00197                         case AUTH_LOCAL:
00198                                 $ilLog->write(__METHOD__.': Current Authentication method is ILIAS DB.');
00199                                 $auth_params = array(
00200                                                                                         'dsn'             => IL_DSN,
00201                                                                                         'table'       => $ilClientIniFile->readVariable("auth", "table"),
00202                                                                                         'usernamecol' => $ilClientIniFile->readVariable("auth", "usercol"),
00203                                                                                         'passwordcol' => $ilClientIniFile->readVariable("auth", "passcol")
00204                                                                                         );
00205                                 $this->auth = new Auth("DB", $auth_params,"",false);
00206                                 break;                          
00207                 }
00208                 if(!$this->first_auth_method)
00209                 {
00210                         $this->auth->start();
00211                 }
00212                 return true;
00213         }
00214         
00215 }
00216 ?>

Generated on Fri Dec 13 2013 17:56:55 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1