cvs: pear /Net_SMTP SMTP.php package.xml

From: Date: Tue, 14 Jan 2003 04:29:56 +0000
Subject: cvs: pear /Net_SMTP SMTP.php package.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8230@lists.php.net to get a copy of this message
jon Mon Jan 13 23:29:56 2003 EDT Modified files: /pear/Net_SMTP SMTP.php package.xml Log: DIGEST-MD5 authentication support. Submitted by: Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar> Index: pear/Net_SMTP/SMTP.php diff -u pear/Net_SMTP/SMTP.php:1.22 pear/Net_SMTP/SMTP.php:1.23 --- pear/Net_SMTP/SMTP.php:1.22 Mon Jan 13 23:19:29 2003 +++ pear/Net_SMTP/SMTP.php Mon Jan 13 23:29:56 2003 @@ -80,9 +80,9 @@ /** * The list of supported authentication methods, ordered by preference. - * @var string + * @var array */ - var $_auth_methods = array('CRAM-MD5', 'LOGIN', 'PLAIN'); + var $_auth_methods = array('DIGEST-MD5', 'CRAM-MD5', 'LOGIN', 'PLAIN'); /** * Constructor @@ -346,6 +346,9 @@ } switch ($method) { + case 'DIGEST-MD5': + $result = $this->_authDigest_MD5($uid, $pwd); + break; case 'CRAM-MD5': $result = $this->_authCRAM_MD5($uid, $pwd); break; @@ -366,6 +369,50 @@ } return true; + } + + /* Authenticates the user using the DIGEST-MD5 method. + * + * @param string The userid to authenticate as. + * @param string The password to authenticate with. + * + * @return mixed Returns a PEAR_Error with an error message on any + * kind of failure, or true on success. + * @access private + */ + function _authDigest_MD5($uid, $pwd) + { + include_once('Auth/SASL.php'); + + if (PEAR::isError($error = $this->_put('AUTH', 'DIGEST-MD5'))) { + return $error; + } + if (PEAR::isError($error = $this->_parseResponse(334))) { + return $error; + } + + $challenge = base64_decode($this->_arguments[0]); + $digest = &Auth_SASL::factory('digestmd5'); + $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge, + $this->host, "smtp")); + + if (PEAR::isError($error = $this->_put($auth_str))) { + return $error; + } + if (PEAR::isError($error = $this->_parseResponse(334))) { + return $error; + } + + /* + * We don't use the protocol's third step because SMTP doesn't allow + * subsequent authentication, so we just silently ignore it. + */ + if (PEAR::isError($error = $this->_put(' '))) { + return $error; + } + if (PEAR::isError($error = $this->_parseResponse(235))) { + return $error; + } } /* Authenticates the user using the CRAM-MD5 method. Index: pear/Net_SMTP/package.xml diff -u pear/Net_SMTP/package.xml:1.13 pear/Net_SMTP/package.xml:1.14 --- pear/Net_SMTP/package.xml:1.13 Mon Jan 13 23:12:00 2003 +++ pear/Net_SMTP/package.xml Mon Jan 13 23:29:56 2003 @@ -27,7 +27,7 @@ <date>2003-XX-XX</date> <notes> - The SMTP server's SIZE capability is now honored. -- Improved support for SMTP authentication (LOGIN, PLAIN, CRAM-MD5). +- Improved support for SMTP authentication (LOGIN, PLAIN, CRAM-MD5, DIGEST-MD5). - Overhauled the server response parsing system. - Added optional debugging output (enabled via setDebug()). - A timeout value can now be specified for the socket connection.

« previous php.pear.cvs (#8230) next »