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

webservice/soap/classes/class.ilSoapAuthentication.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 
00024 
00033 include_once 'Auth/Auth.php';
00034 include_once './Services/Authentication/classes/class.ilBaseAuthentication.php';
00035 
00036 class ilSoapAuthentication extends ilBaseAuthentication
00037 {
00038         var $soap_check = true;
00039 
00040 
00041         function ilSoapAuthentication()
00042         {
00043                 // First unset all cookie inforamtions
00044                 unset($_COOKIE['PHPSESSID']);
00045 
00046                 parent::ilBaseAuthentication();
00047                 $this->__setMessageCode('Client');
00048         }
00049 
00050         function disableSoapCheck()
00051         {
00052                 $this->soap_check = false;
00053         }
00054 
00055         function authenticate()
00056         {
00057                 if(!$this->getClient())
00058                 {
00059                         $this->__setMessage('No client given');
00060                         return false;
00061                 }
00062                 if(!$this->getUsername())
00063                 {
00064                         $this->__setMessage('No username given');
00065                         return false;
00066                 }
00067                 // Read ilias ini
00068                 if(!$this->__buildDSN())
00069                 {
00070                         $this->__setMessage('Error building dsn/Wrong client Id?');
00071                         return false;
00072                 }
00073                 if(!$this->__setSessionSaveHandler())
00074                 {
00075                         return false;
00076                 }
00077                 if(!$this->__checkAgreement('local'))
00078                 {
00079                         return false;
00080                 }
00081                 if(!$this->__buildAuth())
00082                 {
00083                         return false;
00084                 }
00085                 if($this->soap_check and !$this->__checkSOAPEnabled())
00086                 {
00087                         $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
00088                         $this->__setMessageCode('Server');
00089 
00090                         return false;
00091                 }
00092 
00093 
00094                 $this->auth->start();
00095 
00096                 if(!$this->auth->getAuth())
00097                 {
00098                         $this->__getAuthStatus();
00099 
00100                         return false;
00101                 }
00102 
00103                 $this->setSid(session_id());
00104 
00105                 return true;
00106         }
00107         
00115         protected function __checkAgreement($a_auth_mode)
00116         {
00117                 global $ilDB;
00118                 
00119                 include_once('./Services/User/classes/class.ilObjUser.php');
00120                 include_once('./Services/Administration/classes/class.ilSetting.php');
00121                 
00122                 $GLOBALS['ilSetting'] = new ilSetting();
00123                 
00124                 if(!$login = ilObjUser::_checkExternalAuthAccount($a_auth_mode,$this->getUsername()))
00125                 {
00126                         // User does not exist
00127                         return true;
00128                 }
00129                 
00130                 if(!ilObjUser::_hasAcceptedAgreement($login))
00131                 {
00132                         $this->__setMessage('User aggrement no accepted.');
00133                         return false;
00134                 }
00135                 return true;
00136         }
00137         
00138 
00139 
00140         function validateSession()
00141         {
00142                 if(!$this->getClient())
00143                 {
00144                         $this->__setMessage('No client given');
00145                         return false;
00146                 }
00147                 if(!$this->getSid())
00148                 {
00149                         $this->__setMessage('No session id given');
00150                         return false;
00151                 }
00152 
00153                 if(!$this->__buildDSN())
00154                 {
00155                         $this->__setMessage('Error building dsn');
00156                         return false;
00157                 }
00158                 if(!$this->__checkClientEnabled())
00159                 {
00160                         $this->__setMessage('Client disabled.');
00161                         return false;
00162                 }
00163                 
00164                 if(!$this->__setSessionSaveHandler())
00165                 {
00166                         return false;
00167                 }
00168                 if(!$this->__buildAuth())
00169                 {
00170                         return false;
00171                 }
00172                 if($this->soap_check and !$this->__checkSOAPEnabled())
00173                 {
00174                         $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
00175                         $this->__setMessageCode('Server');
00176 
00177                         return false;
00178                 }
00179                 $this->auth->start();
00180                 if(!$this->auth->getAuth())
00181                 {
00182                         $this->__setMessage('Session not valid');
00183 
00184                         return false;
00185                 }
00186 
00187                 return true;
00188         }
00189 
00190         // PRIVATE
00191         function __checkSOAPEnabled()
00192         {
00193                 include_once './classes/class.ilDBx.php';
00194 
00195 
00196                 $db =& new ilDBx($this->dsn);
00197 
00198                 $query = "SELECT * FROM settings WHERE keyword = 'soap_user_administration' AND value = 1";
00199 
00200                 $res = $db->query($query);
00201 
00202                 return $res->numRows() ? true : false;
00203         }
00204         
00205         function __checkClientEnabled()
00206         {
00207                 if(is_object($this->ini) and $this->ini->readVariable('client','access'))
00208                 {
00209                         return true;
00210                 }
00211                 return false;
00212         }
00213 }
00214 ?>

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