ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
33include_once 'Auth/Auth.php';
34include_once './Services/Authentication/classes/class.ilBaseAuthentication.php';
35
37{
38 public $soap_check = true;
39
40
44 public function __construct()
45 {
46 // First unset all cookie inforamtions
47 unset($_COOKIE['PHPSESSID']);
48
49 parent::__construct();
50 $this->__setMessageCode('Client');
51 }
52
53 public function disableSoapCheck()
54 {
55 $this->soap_check = false;
56 }
57
58 public function authenticate()
59 {
60 if (!$this->getClient()) {
61 $this->__setMessage('No client given');
62 return false;
63 }
64 if (!$this->getUsername()) {
65 $this->__setMessage('No username given');
66 return false;
67 }
68 // Read ilias ini
69 if (!$this->__buildDSN()) {
70 $this->__setMessage('Error building dsn/Wrong client Id?');
71 return false;
72 }
73 if (!$this->__setSessionSaveHandler()) {
74 return false;
75 }
76 if (!$this->__checkAgreement('local')) {
77 return false;
78 }
79 if (!$this->__buildAuth()) {
80 return false;
81 }
82 if ($this->soap_check and !$this->__checkSOAPEnabled()) {
83 $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
84 $this->__setMessageCode('Server');
85
86 return false;
87 }
88
89
90 $this->auth->start();
91
92 if (!$this->auth->getAuth()) {
93 $this->__getAuthStatus();
94
95 return false;
96 }
97
98 $this->setSid(session_id());
99
100 return true;
101 }
102
110 protected function __checkAgreement($a_auth_mode)
111 {
112 include_once('./Services/User/classes/class.ilObjUser.php');
113 include_once('./Services/Administration/classes/class.ilSetting.php');
114
115 $GLOBALS['ilSetting'] = new ilSetting();
116
117 if (!$login = ilObjUser::_checkExternalAuthAccount($a_auth_mode, $this->getUsername())) {
118 return true;
119 }
120
121 if (ilObjUser::hasUserToAcceptTermsOfService($login)) {
122 $this->__setMessage('User agreement no accepted.');
123 return false;
124 }
125
126 return true;
127 }
128
129
130
131 public function validateSession()
132 {
133 if (!$this->getClient()) {
134 $this->__setMessage('No client given');
135 return false;
136 }
137 if (!$this->getSid()) {
138 $this->__setMessage('No session id given');
139 return false;
140 }
141
142 if (!$this->__buildDSN()) {
143 $this->__setMessage('Error building dsn');
144 return false;
145 }
146 if (!$this->__checkClientEnabled()) {
147 $this->__setMessage('Client disabled.');
148 return false;
149 }
150
151 if (!$this->__setSessionSaveHandler()) {
152 return false;
153 }
154 if (!$this->__buildAuth()) {
155 return false;
156 }
157 if ($this->soap_check and !$this->__checkSOAPEnabled()) {
158 $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
159 $this->__setMessageCode('Server');
160
161 return false;
162 }
163 $this->auth->start();
164 if (!$this->auth->getAuth()) {
165 $this->__setMessage('Session not valid');
166
167 return false;
168 }
169
170 return true;
171 }
172
173 // PRIVATE
174 public function __checkSOAPEnabled()
175 {
176 include_once './Services/Database/classes/MDB2/class.ilDB.php';
177
178 //$db = new ilDB($this->dsn);
179 $ilDB = $this->db;
180 $ilDB->connect();
181
182 $GLOBALS["ilDB"] = $ilDB;
183 include_once './Services/Administration/classes/class.ilSetting.php';
184 $set = new ilSetting();
185 return ($set->get("soap_user_administration") == 1);
186
187 /*$query = "SELECT * FROM set tings WHERE keyword = 'soap_user_administration' AND value = 1";
188
189 $res = $db->query($query);
190
191 return $res->numRows() ? true : false;*/
192 }
193
194 public function __checkClientEnabled()
195 {
196 if (is_object($this->ini) and $this->ini->readVariable('client', 'access')) {
197 return true;
198 }
199 return false;
200 }
201}
$_COOKIE['client_id']
Definition: server.php:9
An exception for terminatinating execution or to throw for unit testing.
static _checkExternalAuthAccount($a_auth, $a_account, $tryFallback=true)
check whether external account and authentication method matches with a user
ILIAS Setting Class.
__checkAgreement($a_auth_mode)
Check if user agreement is accepted.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilDB