diff --git a/src/BeSimple/SoapClient/SoapClientBuilder.php b/src/BeSimple/SoapClient/SoapClientBuilder.php index 63c9934..fdb7f39 100644 --- a/src/BeSimple/SoapClient/SoapClientBuilder.php +++ b/src/BeSimple/SoapClient/SoapClientBuilder.php @@ -16,9 +16,12 @@ use BeSimple\SoapCommon\AbstractSoapBuilder; /** * @author Francis Besset + * @author Christian Kerl */ 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();