Esempio n. 1
0
        /*
         * /// <summary>
         * /// Return true if this is among the supported AUTH
         * /// types.
         * /// </summary>
         * /// <param name="authtypes"></param>
         * /// <returns></returns>
         * public bool IsSupported(SmtpAuthType[] authtypes)
         * {
         *      log.Debug("CHECKING SUPPORTED TYPES");
         *      for (int i=0; i<authtypes.Length; i++)
         *      {
         *              log.Debug("CHECKING IF "+authtypes[i]+"="+SmtpAuthType.Login);
         *              if (authtypes[i]==SmtpAuthType.Login)
         *              {
         *                      return true;
         *              }
         *      }
         *      return false;
         * }
         */

        /// <summary>
        /// Return the 235 response code if valid, otherwise
        /// return the error.
        /// </summary>
        /// <param name="smtpProxy"></param>
        /// <param name="supportedAuthTypes">the supported auth types</param>
        /// <returns></returns>
        public SmtpResponse Negotiate(ISmtpProxy smtpProxy, String[] supportedAuthTypes)
        {
            SmtpResponse response = smtpProxy.Auth("login");

            //log.Debug("RESPONSE WAS "+response.ResponseCode+" "+response.Message);
            if (response.ResponseCode != 334)
            {
                return(response);
            }
            Base64Encoder encoder = Base64Encoder.GetInstance();

            response = smtpProxy.SendString(encoder.EncodeString(this.UserName, this._charEncoding));
            if (response.ResponseCode != 334)
            {
                return(response);
            }
            response = smtpProxy.SendString(encoder.EncodeString(this.Password, this._charEncoding));
            if (response.ResponseCode != 334)
            {
                // here it's an error
                return(response);
            }
            else
            {
                // here it's ok.
                return(response);
            }
        }
Esempio n. 2
0
 /*
 /// <summary>
 /// Return true if this is among the supported AUTH
 /// types.
 /// </summary>
 /// <param name="authtypes"></param>
 /// <returns></returns>
 public bool IsSupported(SmtpAuthType[] authtypes)
 {
     log.Debug("CHECKING SUPPORTED TYPES");
     for (int i=0; i<authtypes.Length; i++)
     {
         log.Debug("CHECKING IF "+authtypes[i]+"="+SmtpAuthType.Login);
         if (authtypes[i]==SmtpAuthType.Login)
         {
             return true;
         }
     }
     return false;
 }
 */
 /// <summary>
 /// Return the 235 response code if valid, otherwise
 /// return the error.
 /// </summary>
 /// <param name="smtpProxy"></param>
 /// <param name="supportedAuthTypes">the supported auth types</param>
 /// <returns></returns>
 public SmtpResponse Negotiate(ISmtpProxy smtpProxy, String[] supportedAuthTypes)
 {
     SmtpResponse response=smtpProxy.Auth("login");
     //log.Debug("RESPONSE WAS "+response.ResponseCode+" "+response.Message);
     if (response.ResponseCode!=334)
     {
         return response;
     }
     Base64Encoder encoder=Base64Encoder.GetInstance();
     response=smtpProxy.SendString(encoder.EncodeString(this.UserName, this._charEncoding ));
     if (response.ResponseCode!=334)
     {
         return response;
     }
     response=smtpProxy.SendString(encoder.EncodeString(this.Password, this._charEncoding ));
     if (response.ResponseCode!=334)
     {
         // here it's an error
         return response;
     }
     else
     {
         // here it's ok.
         return response;
     }
 }