コード例 #1
0
        public override void Authenticate()
        {
            Logger.Debug("Authenticating connection {0}", LogSource.Channel, UniqueId);

            if (channelState == ChannelState.Authenticated)
            {
                return;
            }

            if (channelState != ChannelState.Connected)
            {
                Logger.Error("Unable to authenticate in current channel state. ChannelState = {0}", LogSource.Channel, channelState);

                throw new ChannelException("Unable to authenticate in current channel state");
            }

            try
            {
                client.Capability();
                client.YahooImap();
                client.Authenticate(Username, Password);

                channelState = ChannelState.Authenticated;

                Logger.Debug("SUCCESS Authenticating connection {0}", LogSource.Channel, UniqueId);
            }
            catch (IMAP_ClientException ex)
            {
                channelState = ChannelState.Broken;

                Logger.Debug("FAILED Authenticating connection {0}. Server said {1}", LogSource.Channel, UniqueId, ex.ResponseText);

                throw new ChannelAuthenticationException(ex.ResponseText, ex);
            }
        }