예제 #1
0
        public override void Authenticate()
        {
            if (channelState == ChannelState.Authenticated)
            {
                return;
            }

            if (channelState != ChannelState.Connected)
            {
                throw new ChannelException("Unable to authenticate in current channel state");
            }

            try
            {
                client.Authenticate(Username, Password, true);

                channelState = ChannelState.Authenticated;
            }
            catch (POP3_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);
            }
        }
예제 #2
0
        public override void Open()
        {
            if (!(channelState == ChannelState.Closed || channelState == ChannelState.Broken))
            {
                return;
            }

            channelState = ChannelState.Connecting;

            try
            {
                client = new POP3_Client();

                if ("/Settings/Channels/LoggerEnabled".AsKey(false))
                {
                    client.Logger           = new LumiSoft.Net.Log.Logger();
                    client.Logger.WriteLog += (sender, e) => Logger.Debug(e.LogEntry.Text, LogSource.Channel);
                }

                client.Connect(Hostname, Port, IsSecured);

                channelState = ChannelState.Connected;
            }
            catch (Exception ex)
            {
                channelState = ChannelState.Closed;

                throw new ChannelException("Unable to connect to server", ex);
            }
        }
        public ConnectResult Connect()
        {
            var credentials = CredentialsProvider.GetCredentials();
            var binding     = ChannelHelper.BuildChannel(Hostname, credentials.Claim, credentials.Evidence);

            folders = new List <ChannelFolder>();

            // Try connecting
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(binding.Url);

            request.AllowAutoRedirect = false;
            request.Credentials       = new NetworkCredential(credentials.Claim, credentials.Evidence);

            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                Logger.Debug("Server {0} returned status-code {1}", LogSource.Channel, binding.Url, response.StatusCode);

                if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Found)
                {
                    return(ConnectResult.Success);
                }

                AuthMessage = String.Format("Statuscode {0}", response.StatusCode);

                return(ConnectResult.AuthFailure);
            }
            catch (Exception ex)
            {
                AuthMessage = ex.Message;

                return(ConnectResult.AuthFailure);
            }
        }
예제 #4
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);
            }
        }
예제 #5
0
 public virtual void WriteToLog()
 {
     if (isEnabled && executeWhen)
     {
         // We use error logging because this is ususally enabled on production servers
         Logger.Debug("CodeTimer: [{0}] [{1}] ms", LogSource.Performance, methodName, Elapsed);
     }
 }
예제 #6
0
        public override void Open()
        {
            Logger.Debug("Opening IMAP connection {0}", LogSource.Channel, UniqueId);

            if (!(channelState == ChannelState.Closed || channelState == ChannelState.Broken))
            {
                Logger.Debug("SUCCESS Connection was allready open {0}", LogSource.Channel, UniqueId);

                return;
            }

            channelState = ChannelState.Connecting;
            client       = new IMAP_Client();

            if ("/Settings/Channels/LoggerEnabled".AsKey(false))
            {
                client.Logger           = new LumiSoft.Net.Log.Logger();
                client.Logger.WriteLog += (sender, e) => Logger.Debug(e.LogEntry.Text.Replace("{", "{{").Replace("}", "}}"), LogSource.Channel);
            }

            try
            {
                client.Connect(Hostname, Port, IsSecured);

                channelState = ChannelState.Connected;
            }
            catch (Exception ex)
            {
                channelState = ChannelState.Closed;

                Logger.Debug("Unable to connect to server. Exception = {0}", LogSource.Channel, ex);

                throw new ChannelException("Unable to connect to server", ex);
            }

            Logger.Debug("SUCCESS Opening connection {0}", LogSource.Channel, UniqueId);
        }