Esempio n. 1
0
 private bool PerformLogin(LoginData credentials)
 {
     if (!failedLogin.Contains(credentials.User))
     {
         if (credentials.IsManual)
         {
             GameModel model = ProfileManager.CurrentProfile.GameModel;
             if (ConfigurationManager.GetConfiguration(model).IsManualLoginSupported)
             {
                 Login(credentials.User, PassEncrypt.ConvertToUnsecureString(credentials.SecurePassword), true);
                 return(true);
             }
         }
         if (credentials.IsCorrect)
         {
             LoginDialogData loginData = new LoginDialogData()
             {
                 Username = credentials.User,
                 Password = PassEncrypt.ConvertToUnsecureString(credentials.SecurePassword)
             };
             ShowLoggingInDialog(loginData);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 2
0
        private void LoginDocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            if (LogManager != null)
            {
                LogManager.InfoFormat("Document requested: {0}", e.Url.OriginalString);
            }
            switch (e.Url.AbsolutePath)
            {
            //loginning
            case "/help/Login/MemberLogin.aspx":
            {
                if (LoginAttemptNum >= 1)
                {
                    OnCompleted(LoginCode.WRONG_USER, string.Empty, UserId);
                    return;
                }
                LoginAttemptNum++;

                bool isFound = true;
                try {
                    Browser.Document.GetElementById("security_name").SetAttribute("value", UserId);
                    Browser.Document.GetElementById("security_code").SetAttribute("value", PassEncrypt.ConvertToUnsecureString(Password));
                } catch {
                    isFound = false;
                }

                if (isFound)
                {
                    System.Windows.Forms.HtmlElement form = Browser.Document.GetElementById("login");
                    if (form != null)
                    {
                        form.InvokeMember("Click");
                    }
                }
                else
                {
                    OnCompleted(LoginCode.WRONG_PAGE, string.Empty, UserId);
                    return;
                }
                break;
            }

            //logged
            case "/index.aspx":
            {
                OnStateChanged(LoginState.GETTING_DATA);
                Browser.Navigate("http://www.digimonmasters.com/inc/xml/launcher.aspx");
                break;
            }

            //getting data
            case "/inc/xml/launcher.aspx":
            {
                TryParseInfo(Browser.DocumentText);
                break;
            }

            default:
                break;
            }
        }
 public void TryLogin(string UserId, string Password)
 {
     IsManual = false;
     TryLogin(UserId, PassEncrypt.ConvertToSecureString(Password));
 }
Esempio n. 4
0
        private void LoginDocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            if (IsManual && WebWindow == null)
            {
                return;
            }
            if (LogManager != null)
            {
                LogManager.InfoFormat("Document requested: {0}", e.Url.OriginalString);
            }
            switch (e.Url.AbsolutePath)
            {
            //loginning
            case "/dialog/oauth":
            {
                bool isFound = true;
                try {
                    if (!string.IsNullOrEmpty(UserId))
                    {
                        Browser.Document.GetElementById("edit-id").SetAttribute("value", UserId);
                        Browser.Document.GetElementById("edit-pass").SetAttribute("value", PassEncrypt.ConvertToUnsecureString(Password));
                    }
                } catch {
                    isFound = false;
                }
                if (!IsManual)
                {
                    if (LoginAttemptNum >= 1)
                    {
                        OnCompleted(LoginCode.WRONG_USER, string.Empty, UserId);
                        return;
                    }
                    LoginAttemptNum++;

                    if (isFound)
                    {
                        System.Windows.Forms.HtmlElement form = Browser.Document.GetElementById("account_login");
                        if (form != null)
                        {
                            form.InvokeMember("submit");
                        }
                    }
                    else
                    {
                        OnCompleted(LoginCode.WRONG_PAGE, string.Empty, UserId);
                        return;
                    }
                }

                break;
            }

            case "/dialog/oauth/authorize":
            {
                if (!IsManual)
                {
                    System.Windows.Forms.HtmlElementCollection links = Browser.Document.GetElementsByTagName("a");
                    foreach (System.Windows.Forms.HtmlElement link in links)
                    {
                        if (link.InnerText.Trim().ToLower().Equals("authorize"))
                        {
                            link.InvokeMember("click");
                            break;
                        }
                    }
                    OnCompleted(LoginCode.UNKNOWN_URL, string.Empty, UserId);
                }
                break;
            }

            //logged
            case "/code2token.html":
            {
                OnCompleted(LoginCode.SUCCESS, string.Format("{0} {1} {2}", "Aeria", HttpUtility.ParseQueryString(e.Url.Query).Get("code"), UserId), UserId);
                break;
            }

            default:
            {
                if (!IsManual && !e.Url.Host.Contains("facebook"))
                {
                    OnCompleted(LoginCode.UNKNOWN_URL, string.Empty, UserId);
                }
                break;
            }
            }
        }
Esempio n. 5
0
        private void LoginDocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            if (LogManager != null)
            {
                LogManager.InfoFormat("Document requested: {0}", e.Url.OriginalString);
            }
            switch (e.Url.AbsolutePath)
            {
            //loginning
            case "/RealMedia/ads/adstream_sx.ads/www.imbc.com/Login@Middle":
            {
                if (LoginAttemptNum >= 1)
                {
                    OnCompleted(LoginCode.WRONG_USER, string.Empty, UserId);
                    return;
                }
                LoginAttemptNum++;

                bool isFound = true;
                try {
                    Browser.Document.GetElementsByTagName("input").GetElementsByName("Uid")[0].SetAttribute("value", UserId);
                    Browser.Document.GetElementsByTagName("input").GetElementsByName("Password")[0].SetAttribute("value", PassEncrypt.ConvertToUnsecureString(Password));
                } catch {
                    isFound = false;
                }

                if (isFound)
                {
                    System.Windows.Forms.HtmlElement form = Browser.Document.GetElementById("frmLogin");
                    if (form != null)
                    {
                        form.InvokeMember("submit");
                    }
                }
                else
                {
                    OnCompleted(LoginCode.WRONG_PAGE, string.Empty, UserId);
                    return;
                }
                break;
            }

            //logged
            case "/Counsel/PasswordModify90Days.aspx":
            case "/":
            {
                OnStateChanged(LoginState.GETTING_DATA);
                Browser.Navigate("http://dm.imbc.com/inc/xml/launcher.aspx");
                break;
            }

            //getting data
            case "/inc/xml/launcher.aspx":
            {
                TryParseInfo(Browser.DocumentText);
                break;
            }

            default:
                break;
            }
        }