ILIAS  Release_4_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 
86  if($this->soap_check and !$this->__checkSOAPEnabled())
87  {
88  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
89  $this->__setMessageCode('Server');
90 
91  return false;
92  }
93 
94 
95  $this->auth->start();
96 
97  if(!$this->auth->getAuth())
98  {
99  $this->__getAuthStatus();
100 
101  return false;
102  }
103 
104  $this->setSid(session_id());
105 
106  return true;
107  }
108 
109 
117  protected function __checkAgreement($a_auth_mode)
118  {
119  global $ilDB;
120 
121  include_once('./Services/User/classes/class.ilObjUser.php');
122  include_once('./Services/Administration/classes/class.ilSetting.php');
123 
124  $GLOBALS['ilSetting'] = new ilSetting();
125 
126  if(!$login = ilObjUser::_checkExternalAuthAccount($a_auth_mode,$this->getUsername()))
127  {
128  // User does not exist
129  return true;
130  }
131 
133  {
134  $this->__setMessage('User agreement no accepted.');
135  return false;
136  }
137  return true;
138  }
139 
140 
141 
142  function validateSession()
143  {
144  if(!$this->getClient())
145  {
146  $this->__setMessage('No client given');
147  return false;
148  }
149  if(!$this->getSid())
150  {
151  $this->__setMessage('No session id given');
152  return false;
153  }
154 
155  if(!$this->__buildDSN())
156  {
157  $this->__setMessage('Error building dsn');
158  return false;
159  }
160  if(!$this->__checkClientEnabled())
161  {
162  $this->__setMessage('Client disabled.');
163  return false;
164  }
165 
166  if(!$this->__setSessionSaveHandler())
167  {
168  return false;
169  }
170  if(!$this->__buildAuth())
171  {
172  return false;
173  }
174 
175 /* if (!$this->__checkGivenSessionId())
176  {
177  $this->__setMessage('Unknown session id.');
178  session_regenerate_id();
179  return false;
180  }*/
181 
182  if($this->soap_check and !$this->__checkSOAPEnabled())
183  {
184  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
185  $this->__setMessageCode('Server');
186 
187  return false;
188  }
189  $this->auth->start();
190  if(!$this->auth->getAuth())
191  {
192  $this->__setMessage('Session not valid');
193 
194  return false;
195  }
196 
197  return true;
198  }
199 
206 /* protected function __checkGivenSessionId()
207  {
208  include_once("./Services/Authentication/classes/class.ilSession.php");
209  if ($this->getSid() == "")
210  {
211  return true;
212  }
213  return ilSession::_exists($this->getSid());
214  }*/
215 
216  // PRIVATE
218  {
219  include_once './Services/Database/classes/class.ilDB.php';
220 
221  //$db =& new ilDB($this->dsn);
222  $ilDB = $this->db;
223  $ilDB->connect();
224 
225  $GLOBALS["ilDB"] = $ilDB;
226  include_once './Services/Administration/classes/class.ilSetting.php';
227  $set = new ilSetting();
228  return ($set->get("soap_user_administration") == 1);
229 
230  /*$query = "SELECT * FROM set tings WHERE keyword = 'soap_user_administration' AND value = 1";
231 
232  $res = $db->query($query);
233 
234  return $res->numRows() ? true : false;*/
235  }
236 
238  {
239  if(is_object($this->ini) and $this->ini->readVariable('client','access'))
240  {
241  return true;
242  }
243  return false;
244  }
245 }
246 ?>