ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSoapAuthentication.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
33 include_once 'Auth/Auth.php';
34 include_once './Services/Authentication/classes/class.ilBaseAuthentication.php';
35 
37 {
38  var $soap_check = true;
39 
40 
42  {
43  // First unset all cookie inforamtions
44  unset($_COOKIE['PHPSESSID']);
45 
47  $this->__setMessageCode('Client');
48  }
49 
50  function disableSoapCheck()
51  {
52  $this->soap_check = false;
53  }
54 
55  function authenticate()
56  {
57  if(!$this->getClient())
58  {
59  $this->__setMessage('No client given');
60  return false;
61  }
62  if(!$this->getUsername())
63  {
64  $this->__setMessage('No username given');
65  return false;
66  }
67  // Read ilias ini
68  if(!$this->__buildDSN())
69  {
70  $this->__setMessage('Error building dsn/Wrong client Id?');
71  return false;
72  }
73  if(!$this->__setSessionSaveHandler())
74  {
75  return false;
76  }
77  if(!$this->__checkAgreement('local'))
78  {
79  return false;
80  }
81  if(!$this->__buildAuth())
82  {
83  return false;
84  }
85  if($this->soap_check and !$this->__checkSOAPEnabled())
86  {
87  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
88  $this->__setMessageCode('Server');
89 
90  return false;
91  }
92 
93 
94  $this->auth->start();
95 
96  if(!$this->auth->getAuth())
97  {
98  $this->__getAuthStatus();
99 
100  return false;
101  }
102 
103  $this->setSid(session_id());
104 
105  return true;
106  }
107 
115  protected function __checkAgreement($a_auth_mode)
116  {
117  include_once('./Services/User/classes/class.ilObjUser.php');
118  include_once('./Services/Administration/classes/class.ilSetting.php');
119 
120  $GLOBALS['ilSetting'] = new ilSetting();
121 
122  if(!$login = ilObjUser::_checkExternalAuthAccount($a_auth_mode,$this->getUsername()))
123  {
124  return true;
125  }
126 
127  if(ilObjUser::hasUserToAcceptTermsOfService($login))
128  {
129  $this->__setMessage('User agreement no accepted.');
130  return false;
131  }
132 
133  return true;
134  }
135 
136 
137 
138  function validateSession()
139  {
140  if(!$this->getClient())
141  {
142  $this->__setMessage('No client given');
143  return false;
144  }
145  if(!$this->getSid())
146  {
147  $this->__setMessage('No session id given');
148  return false;
149  }
150 
151  if(!$this->__buildDSN())
152  {
153  $this->__setMessage('Error building dsn');
154  return false;
155  }
156  if(!$this->__checkClientEnabled())
157  {
158  $this->__setMessage('Client disabled.');
159  return false;
160  }
161 
162  if(!$this->__setSessionSaveHandler())
163  {
164  return false;
165  }
166  if(!$this->__buildAuth())
167  {
168  return false;
169  }
170  if($this->soap_check and !$this->__checkSOAPEnabled())
171  {
172  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
173  $this->__setMessageCode('Server');
174 
175  return false;
176  }
177  $this->auth->start();
178  if(!$this->auth->getAuth())
179  {
180  $this->__setMessage('Session not valid');
181 
182  return false;
183  }
184 
185  return true;
186  }
187 
188  // PRIVATE
190  {
191  include_once './Services/Database/classes/class.ilDB.php';
192 
193  //$db =& new ilDB($this->dsn);
194  $ilDB = $this->db;
195  $ilDB->connect();
196 
197  $GLOBALS["ilDB"] = $ilDB;
198  include_once './Services/Administration/classes/class.ilSetting.php';
199  $set = new ilSetting();
200  return ($set->get("soap_user_administration") == 1);
201 
202  /*$query = "SELECT * FROM set tings WHERE keyword = 'soap_user_administration' AND value = 1";
203 
204  $res = $db->query($query);
205 
206  return $res->numRows() ? true : false;*/
207  }
208 
210  {
211  if(is_object($this->ini) and $this->ini->readVariable('client','access'))
212  {
213  return true;
214  }
215  return false;
216  }
217 }
218 ?>