19,7 → 19,7 |
* @author Adam Ashley <aashley@php.net> |
* @copyright 2001-2006 The PHP Group |
* @license http://www.php.net/license/3_01.txt PHP License 3.01 |
* @version CVS: $Id: SOAP5.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $ |
* @version CVS: $Id: SOAP5.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $ |
* @since File available since Release 1.4.0 |
*/ |
|
38,7 → 38,7 |
* thats using the PEAR SOAP Package. |
* |
* This class takes one parameter (options), where |
* you specify the following fields: |
* you specify the following fields: |
* * location and uri, or wsdl file |
* * method to call on the SOAP service |
* * usernamefield, the name of the parameter where the username is supplied |
58,10 → 58,10 |
* 'wsdl' => NULL, |
* 'location' => 'http://your.soap.service/endpoint', |
* 'uri' => 'urn:/Your/Namespace', |
* 'method' => 'checkAuth', |
* 'method' => 'checkAuth', |
* 'usernamefield' => 'username', |
* 'passwordfield' => 'password', |
* 'matchpasswords' => false, |
* 'matchpasswords' => false, |
* '_features' => array ( |
* 'extra_parameter' => 'example_value', |
* 'another_parameter' => 'foobar' |
79,10 → 79,10 |
* |
* $options = array ( |
* 'wsdl' => 'http://your.soap.service/wsdl', |
* 'method' => 'checkAuth', |
* 'method' => 'checkAuth', |
* 'usernamefield' => 'username', |
* 'passwordfield' => 'password', |
* 'matchpasswords' => false, |
* 'matchpasswords' => false, |
* '_features' => array ( |
* 'extra_parameter' => 'example_value', |
* 'another_parameter' => 'foobar' |
101,7 → 101,7 |
* @author Adam Ashley <aashley@php.net> |
* @copyright 2001-2006 The PHP Group |
* @license http://www.php.net/license/3_01.txt PHP License 3.01 |
* @version Release: 1.4.3 File: $Revision: 1.1 $ |
* @version Release: 1.5.4 File: $Revision: 1.2 $ |
* @since Class available since Release 1.4.0 |
*/ |
class Auth_Container_SOAP5 extends Auth_Container |
115,7 → 115,7 |
* @access private |
*/ |
var $_requiredOptions = array( |
'location', |
'location', |
'uri', |
'method', |
'usernamefield', |
143,7 → 143,7 |
* @access public |
*/ |
var $soapResponse = array(); |
|
|
// }}} |
// {{{ Auth_Container_SOAP5() |
|
164,7 → 164,7 |
if (!empty($this->_options['_features'])) { |
$this->_features = $this->_options['_features']; |
unset($this->_options['_features']); |
} |
} |
} |
|
// }}} |
181,7 → 181,8 |
* @return mixed Returns the SOAP response or false if something went wrong |
*/ |
function fetchData($username, $password) |
{ |
{ |
$this->log('Auth_Container_SOAP5::fetchData() called.', AUTH_LOG_DEBUG); |
$result = $this->_validateOptions(); |
if (PEAR::isError($result)) |
return $result; |
188,8 → 189,8 |
|
// create a SOAP client |
$soapClient = new SoapClient($this->_options["wsdl"], $this->_options); |
|
$params = array(); |
|
$params = array(); |
// first, assign the optional features |
foreach ($this->_features as $fieldName => $fieldValue) { |
$params[$fieldName] = $fieldValue; |
196,11 → 197,11 |
} |
// assign username and password ... |
$params[$this->_options['usernamefield']] = $username; |
$params[$this->_options['passwordfield']] = $password; |
|
$params[$this->_options['passwordfield']] = $password; |
|
try { |
$this->soapResponse = $soapClient->__soapCall($this->_options['method'], $params); |
|
|
if ($this->_options['matchpasswords']) { |
// check if passwords match |
if ($password == $this->soapResponse[$this->_options['passwordfield']]) { |
208,17 → 209,17 |
} else { |
return false; |
} |
} else { |
} else { |
return true; |
} |
} catch (SoapFault $e) { |
return PEAR::raiseError("Error retrieving authentication data. Received SOAP Fault: ".$e->faultstring, $e->faultcode); |
} |
} |
} |
|
// }}} |
// {{{ _validateOptions() |
|
|
/** |
* Validate that the options passed to the container class are enough for us to proceed |
* |
225,22 → 226,22 |
* @access private |
* @param array |
*/ |
function _validateOptions($array) |
function _validateOptions() |
{ |
if ( ( is_null($this->options['wsdl']) |
&& is_null($this->options['location']) |
&& is_null($this->options['uri'])) |
|| ( is_null($this->options['wsdl']) |
&& ( is_null($this->options['location']) |
|| is_null($this->options['uri'])))) { |
if ( ( is_null($this->_options['wsdl']) |
&& is_null($this->_options['location']) |
&& is_null($this->_options['uri'])) |
|| ( is_null($this->_options['wsdl']) |
&& ( is_null($this->_options['location']) |
|| is_null($this->_options['uri'])))) { |
return PEAR::raiseError('Either a WSDL file or a location/uri pair must be specified.'); |
} |
if (is_null($this->options['method'])) { |
if (is_null($this->_options['method'])) { |
return PEAR::raiseError('A method to call on the soap service must be specified.'); |
} |
return true; |
} |
|
|
// }}} |
// {{{ _setDefaults() |
|
252,16 → 253,16 |
*/ |
function _setDefaults() |
{ |
$this->options['wsdl'] = null; |
$this->options['location'] = null; |
$this->options['uri'] = null; |
$this->options['method'] = null; |
$this->options['usernamefield'] = 'username'; |
$this->options['passwordfield'] = 'password'; |
$this->options['matchpasswords'] = true; |
$this->_options['wsdl'] = null; |
$this->_options['location'] = null; |
$this->_options['uri'] = null; |
$this->_options['method'] = null; |
$this->_options['usernamefield'] = 'username'; |
$this->_options['passwordfield'] = 'password'; |
$this->_options['matchpasswords'] = true; |
} |
|
// }}} |
|
|
} |
?> |