ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
SOAP5.php
Go to the documentation of this file.
1<?php
2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
3
29require_once "Auth/Container.php";
33require_once "PEAR.php";
34
108{
109
110 // {{{ properties
111
117 var $_requiredOptions = array(
118 'location',
119 'uri',
120 'method',
121 'usernamefield',
122 'passwordfield',
123 'wsdl',
124 );
125
131 var $_options = array();
132
138 var $_features = array();
139
145 var $soapResponse = array();
146
147 // }}}
148 // {{{ Auth_Container_SOAP5()
149
157 {
158 $this->_setDefaults();
159
160 foreach ($options as $name => $value) {
161 $this->_options[$name] = $value;
162 }
163
164 if (!empty($this->_options['_features'])) {
165 $this->_features = $this->_options['_features'];
166 unset($this->_options['_features']);
167 }
168 }
169
170 // }}}
171 // {{{ fetchData()
172
183 function fetchData($username, $password)
184 {
185 $this->log('Auth_Container_SOAP5::fetchData() called.', AUTH_LOG_DEBUG);
186 $result = $this->_validateOptions();
188 return $result;
189
190 // create a SOAP client
191 $soapClient = new SoapClient($this->_options["wsdl"], $this->_options);
192
193 $params = array();
194 // first, assign the optional features
195 foreach ($this->_features as $fieldName => $fieldValue) {
196 $params[$fieldName] = $fieldValue;
197 }
198 // assign username and password ...
199 $params[$this->_options['usernamefield']] = $username;
200 $params[$this->_options['passwordfield']] = $password;
201
202 try {
203 $this->soapResponse = $soapClient->__soapCall($this->_options['method'], $params);
204
205 if ($this->_options['matchpasswords']) {
206 // check if passwords match
207 if ($password == $this->soapResponse[$this->_options['passwordfield']]) {
208 return true;
209 } else {
210 return false;
211 }
212 } else {
213 return true;
214 }
215 } catch (SoapFault $e) {
216 return PEAR::raiseError("Error retrieving authentication data. Received SOAP Fault: ".$e->faultstring, $e->faultcode);
217 }
218 }
219
220 // }}}
221 // {{{ _validateOptions()
222
230 {
231 if ( ( is_null($this->_options['wsdl'])
232 && is_null($this->_options['location'])
233 && is_null($this->_options['uri']))
234 || ( is_null($this->_options['wsdl'])
235 && ( is_null($this->_options['location'])
236 || is_null($this->_options['uri'])))) {
237 return PEAR::raiseError('Either a WSDL file or a location/uri pair must be specified.');
238 }
239 if (is_null($this->_options['method'])) {
240 return PEAR::raiseError('A method to call on the soap service must be specified.');
241 }
242 return true;
243 }
244
245 // }}}
246 // {{{ _setDefaults()
247
254 function _setDefaults()
255 {
256 $this->_options['wsdl'] = null;
257 $this->_options['location'] = null;
258 $this->_options['uri'] = null;
259 $this->_options['method'] = null;
260 $this->_options['usernamefield'] = 'username';
261 $this->_options['passwordfield'] = 'password';
262 $this->_options['matchpasswords'] = true;
263 }
264
265 // }}}
266
267}
268?>
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
$result
_setDefaults()
Set some default options.
Definition: SOAP5.php:254
fetchData($username, $password)
Fetch data from SOAP service.
Definition: SOAP5.php:183
Auth_Container_SOAP5($options)
Constructor of the container class.
Definition: SOAP5.php:156
_validateOptions()
Validate that the options passed to the container class are enough for us to proceed.
Definition: SOAP5.php:229
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is a wrapper that returns an instance of the configured error class with this object's de...
Definition: PEAR.php:524
$params
Definition: example_049.php:96
if(!is_array($argv)) $options