ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
SOAP.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";
37require_once 'SOAP/Client.php';
38
91{
92
93 // {{{ properties
94
100 var $_requiredOptions = array(
101 'endpoint',
102 'namespace',
103 'method',
104 'encoding',
105 'usernamefield',
106 'passwordfield',
107 );
108
114 var $_options = array();
115
121 var $_features = array();
122
128 var $soapResponse = array();
129
135 var $soapClient = null;
136
137 // }}}
138 // {{{ Auth_Container_SOAP() [constructor]
139
147 {
148 $this->_options = $options;
149 if (!isset($this->_options['matchpasswords'])) {
150 $this->_options['matchpasswords'] = true;
151 }
152 if (!empty($this->_options['_features'])) {
153 $this->_features = $this->_options['_features'];
154 unset($this->_options['_features']);
155 }
156 }
157
158 // }}}
159 // {{{ fetchData()
160
171 function fetchData($username, $password)
172 {
173 $this->log('Auth_Container_SOAP::fetchData() called.', AUTH_LOG_DEBUG);
174 // check if all required options are set
175 if (array_intersect($this->_requiredOptions, array_keys($this->_options)) != $this->_requiredOptions) {
176 return false;
177 } else {
178 // create a SOAP client and set encoding
179 $this->soapClient = new SOAP_Client($this->_options['endpoint']);
180 $this->soapClient->setEncoding($this->_options['encoding']);
181 }
182
183 // set the trace option if requested
184 if (isset($this->_options['trace'])) {
185 $this->soapClient->__options['trace'] = true;
186 }
187
188 // set the timeout option if requested
189 if (isset($this->_options['timeout'])) {
190 $this->soapClient->__options['timeout'] = $this->_options['timeout'];
191 }
192
193 // assign username and password fields
194 $usernameField = new SOAP_Value($this->_options['usernamefield'],'string', $username);
195 $passwordField = new SOAP_Value($this->_options['passwordfield'],'string', $password);
196 $SOAPParams = array($usernameField, $passwordField);
197
198 // assign optional features
199 foreach ($this->_features as $fieldName => $fieldValue) {
200 $SOAPParams[] = new SOAP_Value($fieldName, 'string', $fieldValue);
201 }
202
203 // make SOAP call
204 $this->soapResponse = $this->soapClient->call(
205 $this->_options['method'],
206 $SOAPParams,
207 array('namespace' => $this->_options['namespace'])
208 );
209
210 if (!PEAR::isError($this->soapResponse)) {
211 if ($this->_options['matchpasswords']) {
212 // check if passwords match
213 if ($password == $this->soapResponse->{$this->_options['passwordfield']}) {
214 return true;
215 } else {
216 return false;
217 }
218 } else {
219 return true;
220 }
221 } else {
222 return false;
223 }
224 }
225
226 // }}}
227
228}
229?>
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
fetchData($username, $password)
Fetch data from SOAP service.
Definition: SOAP.php:171
Auth_Container_SOAP($options)
Constructor of the container class.
Definition: SOAP.php:146
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
if(!is_array($argv)) $options