Added Authentication in SoapClientBuilder
This commit is contained in:
parent
a9b1bdc714
commit
9ce673b8cb
@ -16,9 +16,12 @@ use BeSimple\SoapCommon\AbstractSoapBuilder;
|
||||
|
||||
/**
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
*/
|
||||
class SoapClientBuilder extends AbstractSoapBuilder
|
||||
{
|
||||
protected $soapOptionAuthentication = array();
|
||||
|
||||
/**
|
||||
* @return SoapClientBuilder
|
||||
*/
|
||||
@ -36,7 +39,7 @@ class SoapClientBuilder extends AbstractSoapBuilder
|
||||
{
|
||||
$this->validateOptions();
|
||||
|
||||
return new SoapClient($this->optionWsdl, $this->options);
|
||||
return new SoapClient($this->optionWsdl, $this->getSoapOptions() + $this->soapOptionAuthentication);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,6 +72,34 @@ class SoapClientBuilder extends AbstractSoapBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SoapClientBuilder
|
||||
*/
|
||||
public function withBasicAuthentication($username, $password)
|
||||
{
|
||||
$this->soapOptionAuthentication = array(
|
||||
'authentication' => SOAP_AUTHENTICATION_BASIC,
|
||||
'login' => $username,
|
||||
'password' => $password
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SoapClientBuilder
|
||||
*/
|
||||
public function withDigestAuthentication($certificate, $password)
|
||||
{
|
||||
$this->soapOptionAuthentication = array(
|
||||
'authentication' => SOAP_AUTHENTICATION_DIGEST,
|
||||
'local_cert' => $certificate,
|
||||
'passphrase' => $password
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function validateOptions()
|
||||
{
|
||||
$this->validateWsdl();
|
||||
|
Loading…
Reference in New Issue
Block a user