ILIAS  Release_4_2_x_branch Revision 61807
 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  global $ilDB;
118 
119  include_once('./Services/User/classes/class.ilObjUser.php');
120  include_once('./Services/Administration/classes/class.ilSetting.php');
121 
122  $GLOBALS['ilSetting'] = new ilSetting();
123 
124  if(!$login = ilObjUser::_checkExternalAuthAccount($a_auth_mode,$this->getUsername()))
125  {
126  // User does not exist
127  return true;
128  }
129 
131  {
132  $this->__setMessage('User agreement no accepted.');
133  return false;
134  }
135  return true;
136  }
137 
138 
139 
140  function validateSession()
141  {
142  if(!$this->getClient())
143  {
144  $this->__setMessage('No client given');
145  return false;
146  }
147  if(!$this->getSid())
148  {
149  $this->__setMessage('No session id given');
150  return false;
151  }
152 
153  if(!$this->__buildDSN())
154  {
155  $this->__setMessage('Error building dsn');
156  return false;
157  }
158  if(!$this->__checkClientEnabled())
159  {
160  $this->__setMessage('Client disabled.');
161  return false;
162  }
163 
164  if(!$this->__setSessionSaveHandler())
165  {
166  return false;
167  }
168  if(!$this->__buildAuth())
169  {
170  return false;
171  }
172  if($this->soap_check and !$this->__checkSOAPEnabled())
173  {
174  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
175  $this->__setMessageCode('Server');
176 
177  return false;
178  }
179  $this->auth->start();
180  if(!$this->auth->getAuth())
181  {
182  $this->__setMessage('Session not valid');
183 
184  return false;
185  }
186 
187  return true;
188  }
189 
190  // PRIVATE
192  {
193  include_once './Services/Database/classes/class.ilDB.php';
194 
195  //$db =& new ilDB($this->dsn);
196  $ilDB = $this->db;
197  $ilDB->connect();
198 
199  $GLOBALS["ilDB"] = $ilDB;
200  include_once './Services/Administration/classes/class.ilSetting.php';
201  $set = new ilSetting();
202  return ($set->get("soap_user_administration") == 1);
203 
204  /*$query = "SELECT * FROM set tings WHERE keyword = 'soap_user_administration' AND value = 1";
205 
206  $res = $db->query($query);
207 
208  return $res->numRows() ? true : false;*/
209  }
210 
212  {
213  if(is_object($this->ini) and $this->ini->readVariable('client','access'))
214  {
215  return true;
216  }
217  return false;
218  }
219 }
220 ?>