• 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 './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 
00078                 if(!$this->__buildAuth())
00079                 {
00080                         return false;
00081                 }
00082                 if($this->soap_check and !$this->__checkSOAPEnabled())
00083                 {
00084                         $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
00085                         $this->__setMessageCode('Server');
00086 
00087                         return false;
00088                 }
00089 
00090 
00091                 $this->auth->start();
00092 
00093                 if(!$this->auth->getAuth())
00094                 {
00095                         $this->__getAuthStatus();
00096 
00097                         return false;
00098                 }
00099 
00100                 $this->setSid(session_id());
00101 
00102                 return true;
00103         }
00104 
00105 
00106         function validateSession()
00107         {
00108                 if(!$this->getClient())
00109                 {
00110                         $this->__setMessage('No client given');
00111                         return false;
00112                 }
00113                 if(!$this->getSid())
00114                 {
00115                         $this->__setMessage('No session id given');
00116                         return false;
00117                 }
00118 
00119                 if(!$this->__buildDSN())
00120                 {
00121                         $this->__setMessage('Error building dsn');
00122                         return false;
00123                 }
00124                 if(!$this->__checkClientEnabled())
00125                 {
00126                         $this->__setMessage('Client disabled.');
00127                         return false;
00128                 }
00129                 
00130                 if(!$this->__setSessionSaveHandler())
00131                 {
00132                         return false;
00133                 }
00134                 if(!$this->__buildAuth())
00135                 {
00136                         return false;
00137                 }
00138                 if($this->soap_check and !$this->__checkSOAPEnabled())
00139                 {
00140                         $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
00141                         $this->__setMessageCode('Server');
00142 
00143                         return false;
00144                 }
00145                 $this->auth->start();
00146                 if(!$this->auth->getAuth())
00147                 {
00148                         $this->__setMessage('Session not valid');
00149 
00150                         return false;
00151                 }
00152 
00153                 return true;
00154         }
00155 
00156         // PRIVATE
00157         function __checkSOAPEnabled()
00158         {
00159                 include_once './classes/class.ilDBx.php';
00160 
00161 
00162                 $db =& new ilDBx($this->dsn);
00163 
00164                 $query = "SELECT * FROM settings WHERE keyword = 'soap_user_administration' AND value = 1";
00165 
00166                 $res = $db->query($query);
00167 
00168                 return $res->numRows() ? true : false;
00169         }
00170         
00171         function __checkClientEnabled()
00172         {
00173                 if(is_object($this->ini) and $this->ini->readVariable('client','access'))
00174                 {
00175                         return true;
00176                 }
00177                 return false;
00178         }
00179 }
00180 ?>

Generated on Fri Dec 13 2013 13:52:16 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1