Esempio n. 1
0
 /**
  * Handles the authentication using any known method.
  *
  * @param string $uid        The userid to authenticate as.
  * @param string $pwd        The password to authenticate with.
  * @param string $userMethod The method to use. If empty, the class chooses
  *                           the best (strongest) available method.
  * @param string $euser      The effective uid to authenticate as.
  *
  * @return void
  */
 function _cmdAuthenticate($uid, $pwd, $userMethod = null, $euser = '')
 {
     $method = $this->_getBestAuthMethod($userMethod);
     if (is_a($method, 'PEAR_Error')) {
         return $method;
     }
     switch ($method) {
         case 'DIGEST-MD5':
             return $this->_authDigestMD5($uid, $pwd, $euser);
         case 'CRAM-MD5':
             $result = $this->_authCRAMMD5($uid, $pwd, $euser);
             break;
         case 'LOGIN':
             $result = $this->_authLOGIN($uid, $pwd, $euser);
             break;
         case 'PLAIN':
             $result = $this->_authPLAIN($uid, $pwd, $euser);
             break;
         case 'EXTERNAL':
             $result = $this->_authEXTERNAL($uid, $pwd, $euser);
             break;
         default:
             $result = $this->_pear->raiseError($method . ' is not a supported authentication method');
             break;
     }
     $res = $this->_doCmd();
     if (is_a($res, 'PEAR_Error')) {
         return $res;
     }
     // Query the server capabilities again now that we are authenticated.
     if ($this->_pear->isError($res = $this->_cmdCapability())) {
         return $this->_pear->raiseError('Failed to connect, server said: ' . $res->getMessage(), 2);
     }
     return $result;
 }