private void FillGUIInputFields(AuthenticationForm Form)
        {
            listViewInputFields.Items.Clear();
            for (int i = 0; i < Form.InputFields.Count; i++)
            {
                ListViewItem Item     = new ListViewItem();
                string       MarkedAs = string.Empty;
                if (Form.InputFields[i].InputType == InputField.InputTypes.Password)
                {
                    MarkedAs = "Password";
                }
                else if (Form.InputFields[i].InputType == InputField.InputTypes.Username)
                {
                    MarkedAs = "Username";
                }

                Item.Text = MarkedAs;
                Item.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Text = Form.InputFields[i].Name
                });
                Item.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Text = Form.InputFields[i].Type
                });
                Item.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Text = Form.InputFields[i].Value
                });

                listViewInputFields.Items.Add(Item);
            }
        }
 private void buttonOk_Click(object sender, EventArgs e)
 {
     if (listViewForms.SelectedIndices.Count > 0)
     {
         authForm = authForms[listViewForms.SelectedIndices[0]];
     }
 }
 public frmAuthenticationForm(string URL)
 {
     InitializeComponent();
     authForm        = new AuthenticationForm();
     authForms       = new List <AuthenticationForm>();
     textBoxURL.Text = URL;
 }
Exemple #4
0
        public void Should_BePossibleTo_CreateDifferentBrowsersInDifferentThreads()
        {
            var thread01 = new Thread(() =>
            {
                var checkBoxesForm = new CheckBoxesForm();
                checkBoxesForm.Open();
                Assert.AreEqual(checkBoxesForm.Url, AqualityServices.Browser.CurrentUrl);
                AqualityServices.Browser.Quit();
            });
            var thread02 = new Thread(() =>
            {
                var authForm = new AuthenticationForm();
                authForm.Open();
                Assert.AreEqual(authForm.Url, AqualityServices.Browser.CurrentUrl);
                AqualityServices.Browser.Quit();
            });

            thread01.Start();
            thread02.Start();

            thread01.Join();
            thread02.Join();

            thread01.Interrupt();
            thread02.Interrupt();
        }
        /// <summary>
        /// This method will be executed after the user login in the application , if the credentials are no correct send the menu for login or create new user.
        /// in other way show the menu of options for manage an appointment
        /// </summary>
        /// <param name="context"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        private async Task ResumeAfterAutheticateCustomerDialog(IDialogContext context, IAwaitable <AuthenticationForm> result)
        {
            try
            {
                AuthenticationForm authenticationForm = await result;
                ACFCustomer        customerState2     = new ACFCustomer();
                if (!context.PrivateConversationData.TryGetValue <ACFCustomer>("customerState", out customerState2))
                {
                    customerState2 = new ACFCustomer();
                }
                int testCustomerStateId = customerState2.CustomerId;

                if (authenticationForm.logged == true)
                {
                    await context.PostAsync("Welcome " + authenticationForm.UserName + "...");

                    context.Wait(this.MessageReceivedAsync2);
                }
                else
                {
                    //this.MessageReceivedAsync(context);
                    await this.StartAsync(context);
                }
            }
            catch (Exception ex)
            {
                await context.PostAsync($"Failed with message: {ex.Message}");
            }
            finally
            {
                // context.Wait(this.MessageReceivedAsync2);
            }
        }
Exemple #6
0
        private void authenticate()
        {
            AuthenticationForm authForm = new AuthenticationForm();

            accessKeyID = authForm.GetAWSAccessKeyID();
            secretKeyID = authForm.GetAWSSecretKeyID();
        }
 public frmAuthenticationForm(string URL)
 {
     InitializeComponent();
     authForm = new AuthenticationForm();
     authForms = new List<AuthenticationForm>();
     textBoxURL.Text = URL;
 }
Exemple #8
0
        public void Evaluate(int SpreadMax)
        {
            client_out.SliceCount  = 1;
            succeed_out.SliceCount = 1;
            if (authorize_in.SliceCount > 0 && authorize_in[0] && app_key_in[0].Length > 0 && app_secret_in[0].Length > 0 && callback_url_in[0].Length > 0)
            {
                //weiboClient = new SinaWeiboClient("1402038860", "62e1ddd4f6bc33077c796d5129047ca2", "http://qcyn.sina.com.cn");
                SinaWeiboClient    weiboClient = new SinaWeiboClient(app_key_in[0], app_secret_in[0], callback_url_in[0]);
                AuthenticationForm form        = weiboClient.GetAuthenticationForm();

                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    client_out[0]  = weiboClient;
                    succeed_out[0] = true;
                    FLogger.Log(LogType.Debug, "Authorize Succeed");
                    FLogger.Log(LogType.Debug, weiboClient.AccessToken);
                }
                else
                {
                    client_out[0]  = null;
                    succeed_out[0] = false;
                    FLogger.Log(LogType.Debug, "Authorize Failed");
                }
            }
        }
 public UserControlAuthenticationTester()
 {
     InitializeComponent();
     AuthForm            = new AuthenticationForm();
     AuthenticationForms = new List <AuthenticationForm>();
     authTester          = new AuthenticationTester();
     LoadTestFiles();
     AwaitingFinish       = false;
     LastCombinationIndex = 0;
 }
        private void ActionsOnAutomationPractice()
        {
            AqualityServices.Browser.Quit();
            OpenAutomationPracticeSite();
            AqualityServices.Browser.Maximize();
            var sliderForm = new SliderForm();

            Assert.IsTrue(sliderForm.State.WaitForDisplayed(), "Slider Form is not opened");

            sliderForm.ClickNextButton();
            sliderForm.ClickNextButton();
            var productListForm = new ProductListForm();

            Assert.AreEqual(ExpectedNumdberOfProducts, productListForm.GetNumberOfProductsInContainer(), "Number of products is incorrect");

            productListForm.AddRandomProductToCart();
            var proceedToCheckoutModal = new ProceedToCheckoutModal();

            proceedToCheckoutModal.ClickProceedToCheckoutButton();
            var shoppingCardSummaryForm = new ShoppingCardSummaryForm();

            shoppingCardSummaryForm.ClickPlusButton();
            var actualQuantity = shoppingCardSummaryForm.WaitForQuantityAndGetValue(ExpectedQuantity);

            Assert.AreEqual(ExpectedQuantity, actualQuantity, "Quantity is incorrect");

            shoppingCardSummaryForm.ClickProceedToCheckoutButton();
            var authForm = new AuthenticationForm();

            Assert.IsTrue(authForm.State.WaitForDisplayed(), "Authentication Form is not opened");

            var cartMenuForm = new CartMenuForm();

            cartMenuForm.OpenCartMenu();
            cartMenuForm.ClickCheckoutButton();

            shoppingCardSummaryForm.ClickProceedToCheckoutButton();
            authForm.SetEmail(Email);
            authForm.ClickCreateAccountButton();

            var personalInfoForm = new YourPersonalInfoForm();

            personalInfoForm.SelectGender(Gender);
            personalInfoForm.SetFirstName(FirstName);
            var actualNumberOfDays = personalInfoForm.GetNumberOfDays();

            Assert.AreEqual(ExpectedNumberOfDays, actualNumberOfDays, "Number of days from combobox is incorrect");

            personalInfoForm.SelectState(State);
            personalInfoForm.SelectDay(DayToSelect);
            Assert.IsFalse(personalInfoForm.IsNewsCheckBoxChecked(), "News checkbox state is not correct");

            personalInfoForm.SetNewsCheckBox();
            Assert.IsTrue(personalInfoForm.IsNewsCheckBoxChecked(), "News checkbox state is not correct");
        }
Exemple #11
0
        /// <summary>
        /// Logins the user into the current mod repository.
        /// </summary>
        /// <param name="p_vmlViewModel">The view model that provides the data and operations for this view.</param>
        /// <returns><c>true</c> if the user was successfully logged in;
        /// <c>false</c> otherwise</returns>
        protected bool Login(AuthenticationFormViewModel p_vmlViewModel)
        {
            if (InvokeRequired)
            {
                return((bool)Invoke((Func <AuthenticationFormViewModel, bool>)Login, p_vmlViewModel));
            }

            var frmLogin = new AuthenticationForm(p_vmlViewModel, null);

            return(frmLogin.ShowDialog(this) == DialogResult.OK);
        }
Exemple #12
0
        public static void login()
        {
            AuthenticationForm loginScreen = new AuthenticationForm(FBQueryManager.Manager.getLoginURL());

            loginScreen.ShowDialog();
            if (m_loggedIn)
            {
                DataSetManager.Manager.loadFiles();
                m_activeForm.Close();
            }
        }
Exemple #13
0
        public dynamic Create([FromBody] AuthenticationForm form)
        {
            dynamic jsonResponse = new JObject();

            if (form.Email == "" || form.Email == null)
            {
                return(BadRequest());
            }

            var uniqueEmail = _context.Users.Count(e => e.Email == form.Email);

            if (form.Type == "login")
            {
                User findUser = _context.Users.FirstOrDefault(u => u.Email == form.Email);

                bool testLogin = findUser != null?ValidateLogin(form.Password, findUser) : false;

                if (testLogin)
                {
                    var tokenString = GenerateJSONWebToken(findUser);
                    jsonResponse.token  = tokenString;
                    jsonResponse.status = "OK";
                    return(jsonResponse);
                }
                else
                {
                    return(BadRequest());
                }
            }
            else if (form.Type == "register" && uniqueEmail == 0)
            {
                byte[] passwordHash, passwordSalt;
                CreatePasswordHash(form.Password, out passwordHash, out passwordSalt);

                User newUser = new User
                {
                    Name         = form.Name,
                    Email        = form.Email,
                    Password     = passwordHash,
                    PasswordSalt = passwordSalt
                };
                _context.Users.Add(newUser);
                _context.SaveChanges();

                var tokenString = GenerateJSONWebToken(newUser);
                jsonResponse.token  = tokenString;
                jsonResponse.status = "OK";
                return(jsonResponse);
            }

            jsonResponse.msg = "Failed to authenticate, please try again";

            return(jsonResponse);
        }
Exemple #14
0
        private void UserButton_Click(object sender, EventArgs e)
        {
            CCurrentUser.User_name = ((UserButton)sender).TouchButton.Text;
            AuthenticationForm objAuthentication = AuthenticationForm.CreateInstance(((UserButton)sender).rmsUserName.Text);
            DialogResult       drResult          = objAuthentication.ShowDialog();

            if (drResult == DialogResult.OK)
            {
                RMSAdminMdiForm objParent = new RMSAdminMdiForm();  //Previous
                objParent.Show();
            }
        }
Exemple #15
0
        private void authenticate()
        {
            AuthenticationForm authForm = new AuthenticationForm();

            if (authForm.ShowDialog(this) != DialogResult.OK)
            {
                this.Close();
            }

            accessKeyID = authForm.GetAWSAccessKeyID();
            secretKeyID = authForm.GetAWSSecretKeyID();
        }
Exemple #16
0
        public async Task <ContentResult> Post([FromBody] AuthenticationForm form)
        {
            var userList = await new UserService().GetUsers();

            var response = new ContentResult
            {
                Content    = _authenticationService.SignToken(userList.FirstOrDefault(x => x.id == form.id)),
                StatusCode = 200
            };

            return(await Task.FromResult(response));
        }
Exemple #17
0
        public static void logout()
        {
            AuthenticationForm loginScreen = new AuthenticationForm(FBQueryManager.Manager.getLogoutURL());

            loginScreen.ShowDialog();


            // Reset states and start over from the Welcome Screen
            m_loggedIn = false;
            m_activeForm.Close();
            m_restart = true;
            FBQueryManager.Manager.setToken(null);
        }
Exemple #18
0
        public void ShouldBe_PossibleTo_CreateCustomTextBox()
        {
            var authForm = new AuthenticationForm();

            authForm.Open();
            var userNameTxb = authForm.UserNameTextBox;

            var userNameCustomTxb = new CustomTextBox(userNameTxb.Locator, userNameTxb.Name);

            userNameTxb.Type("wrong");
            userNameCustomTxb.Type("right");
            Assert.AreEqual(userNameTxb.Value, userNameCustomTxb.Text);
        }
        private List <AuthenticationForm> LoadForms(string URL)
        {
            List <AuthenticationForm> Forms = new List <AuthenticationForm>();

            CreateWebrequest webRequest = new CreateWebrequest();
            string           HTML       = webRequest.StringGetWebPage(URL, string.Empty);

            if (HTML != string.Empty)
            {
                int LastFormIndexEnd = 0;
                while (true)
                {
                    string NewHTML = HTML.Substring(LastFormIndexEnd);

                    int FormIndex    = NewHTML.ToLower().IndexOf("<form");
                    int FormIndexEnd = NewHTML.ToLower().IndexOf("</form>") + 7;
                    int FormLength   = FormIndexEnd - FormIndex;

                    if (FormIndex == -1 || FormIndex >= FormIndexEnd)
                    {
                        break;
                    }

                    string HTMLForm = NewHTML.Substring(FormIndex, FormLength);

                    string action = RegexText(" action\\=\\\"([^\"]*)\\\"", HTMLForm);
                    string method = RegexText(" method\\=\\\"([^\"]*)\\\"", HTMLForm);

                    AuthenticationForm authForm = new AuthenticationForm();
                    authForm.Action = GetURL(textBoxURL.Text, action);
                    if (method.ToLower() == "get")
                    {
                        authForm.Method = AuthenticationForm.Methods.GET;
                    }
                    else
                    {
                        authForm.Method = AuthenticationForm.Methods.POST;
                    }

                    authForm.InputFields = LoadInputFields(HTMLForm);
                    if (!authForm.Action.ToLower().Contains("javascript:"))
                    {
                        Forms.Add(authForm);
                    }

                    LastFormIndexEnd += FormIndexEnd;
                }
            }

            return(Forms);
        }
Exemple #20
0
    static public void Main(string[] args)
    {
        if (args.Length < 2 || (args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help")))
        {
            Console.WriteLine(usage);
        }
        else
        {
            try
            {
                string user = null, pw = null;
                if (args.Length > 2 && args[2].StartsWith("/p"))
                {
                    string[] credentials = args[2].Split(":".ToCharArray(), 3);
                    if (credentials.Length > 1)
                    {
                        user = credentials[1];
                    }
                    if (credentials.Length > 2)
                    {
                        pw = credentials[2];
                    }

                    if (user == null || pw == null)
                    {
                        if (!AuthenticationForm.GetCredentials(ref user, ref pw, "Proxy Authentication"))
                        {
                            return;
                        }
                    }
                }

                string htmlStr = GetHTML(args[0], user, pw);

                using (StreamWriter sw = new StreamWriter(args[1]))
                {
                    StringReader strReader = new StringReader(htmlStr);
                    string       line;
                    while ((line = strReader.ReadLine()) != null)
                    {
                        //this works better that sw.Write(htmlStr) because of nicer text layout
                        sw.WriteLine(line);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
    }
Exemple #21
0
 static public bool GetCredentials(ref string userName, ref string password, string title)
 {
     using (AuthenticationForm dlg = new AuthenticationForm(userName, password, title))
     {
         if (DialogResult.OK == dlg.ShowDialog())
         {
             userName = dlg.userName;
             password = dlg.password;
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #22
0
        public void testLocators(SchoolNet schoolnet)
        {
            schoolnet.LoadWebPage();
            AuthenticationPage page = new AuthenticationPage();
            AuthenticationForm form = page.Form;

            Assert.AreEqual("By.CssSelector: .btn.btn-primary.SignInButton", form.BySubmit.ToString(), "BySubmit locator matches");
            Assert.AreEqual("By.Id: ctl02_ddlListProvider", form.ByDistrictName.ToString(), "BySubmit locator matches");
            Assert.AreEqual("By.Id: ctl02_TextBoxUsername", form.ByUsername.ToString(), "BySubmit locator matches");
            Assert.AreEqual("By.Id: ctl02_TextBoxPassword", form.ByPassword.ToString(), "BySubmit locator matches");

            /*
             * Assert.AreEqual(form.ByErrorMessages.ToString(), "By.selector: .alert.alert-error", "BySubmit locator matches");
             * Assert.AreEqual(form.ByTroubleSigningInLinkLink.ToString(), "By.selector: #ctl02_liForgetPasswordLink > a", "BySubmit locator matches");
             */
        }
Exemple #23
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new MainForm());

            Model    ms       = new Model();
            MainForm mainForm = new MainForm(ms);

            AuthenticationForm aForm = new AuthenticationForm(ms, mainForm);

            Context = new ApplicationContext(aForm);


            Presenter presenter = new Presenter(mainForm, aForm, new ProjectForm(ms), ms);

            presenter.Run();
            Application.Run(Context);
        }
 /// <summary>
 ///     Загрузить информацию о пользователе
 /// </summary>
 private static void LoadUserInformation(User user = null)
 {
     try
     {
         if (user != null)
         {
             DBUser.Working = user;
             return;
         }
         var loginform = new AuthenticationForm();
         DBUser.Working = loginform.Login();
         if (DBUser.Working == null)
         {
             throw new Exception();
         }
     }
     catch (Exception)
     {
         Environment.Exit(0);
     }
 }
Exemple #25
0
        private void AuthenticateUser()
        {
            var authenticationForm = new AuthenticationForm();

            authenticationForm.Focus();
            if (authenticationForm.ShowDialog() == DialogResult.OK)
            {
                Focus();
                var userType = authenticationForm.UserType;
                _userLogin = authenticationForm.UserLogin;
                authenticationForm.Dispose();
                switch (userType)
                {
                case AuthenticationForm.UserTypes.Admin:
                {
                    SetGui(true, true);
                    SetUserStatus(MainLocalization.AdminRole);
                    break;
                }

                case AuthenticationForm.UserTypes.User:
                {
                    SetGui(false, true);
                    SetUserStatus(MainLocalization.OperatorRole);
                    break;
                }

                case AuthenticationForm.UserTypes.Guest:
                {
                    SetGui(false, false);
                    SetUserStatus(MainLocalization.GuestRole);
                    break;
                }
                }
            }
            else
            {
                Close();
            }
        }
        public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            using (AuthenticationForm auth = new AuthenticationForm())
            {
                auth.TopMost = true; //this isn't always setting to top, need to check

                //use attempts counter to stop basic auth dialog popping up in continually incorrect un and pass entered.
                //test here: https://www.httpwatch.com/httpgallery/authentication/
                DialogResult dr = auth.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    callback.Continue(auth.UserName, auth.Password);
                    return(true);
                }
                else
                {
                    callback.Dispose();
                    return(false);
                }
            }
            //callback.Dispose();
            //return false;
        }
Exemple #27
0
        public ActionResult Login(AuthenticationForm form)
        {
            if (string.IsNullOrWhiteSpace(form.Username) || string.IsNullOrWhiteSpace(form.Password))
            {
                form.ErrorMessage = "Username and password are both required!";
                return(View(form));
            }

            using (var db = new PostsContext())
            {
                var user = db.Accounts.FirstOrDefault(a => a.Username == form.Username.ToLower());
                if (user == null || !Crypto.VerifyHashedPassword(user.HashedPassword, form.Password))
                {
                    form.ErrorMessage = "Incorrect username or password!";
                    return(View(form));
                }

                // Store the (now) logged-in user in session
                Session["user"] = user;
            }

            return(RedirectToAction("Index", "Post"));
        }
        private void buttonSelectFields_Click(object sender, EventArgs e)
        {
            if (!VerifyInputSelectField())
            {
                return;
            }

            frmAuthenticationForm authDialog = new frmAuthenticationForm(textBoxURL.Text);

            if (AuthenticationForms.Count > 0)
            {
                authDialog.LoadAuthForms(AuthenticationForms);
            }
            else
            {
                authDialog.LoadOnlineForms();
            }

            if (authDialog.ShowDialog() == DialogResult.OK)
            {
                AuthForm            = authDialog.AuthForm;
                AuthenticationForms = authDialog.AuthForms;
            }
        }
        private List<AuthenticationForm> LoadForms(string URL)
        {
            List<AuthenticationForm> Forms = new List<AuthenticationForm>();

            CreateWebrequest webRequest = new CreateWebrequest();
            string HTML = webRequest.StringGetWebPage(URL, string.Empty);
            if (HTML != string.Empty)
            {
                int LastFormIndexEnd = 0;
                while (true)
                {
                    string NewHTML = HTML.Substring(LastFormIndexEnd);

                    int FormIndex = NewHTML.ToLower().IndexOf("<form");
                    int FormIndexEnd = NewHTML.ToLower().IndexOf("</form>") + 7;
                    int FormLength = FormIndexEnd - FormIndex;

                    if (FormIndex == -1 || FormIndex >= FormIndexEnd)
                        break;

                    string HTMLForm = NewHTML.Substring(FormIndex, FormLength);

                    string action = RegexText(" action\\=\\\"([^\"]*)\\\"", HTMLForm);
                    string method = RegexText(" method\\=\\\"([^\"]*)\\\"", HTMLForm);

                    AuthenticationForm authForm = new AuthenticationForm();
                    authForm.Action = GetURL(textBoxURL.Text, action);
                    if (method.ToLower() == "get")
                        authForm.Method = AuthenticationForm.Methods.GET;
                    else
                        authForm.Method = AuthenticationForm.Methods.POST;

                    authForm.InputFields = LoadInputFields(HTMLForm);
                    if (!authForm.Action.ToLower().Contains("javascript:"))
                        Forms.Add(authForm);

                    LastFormIndexEnd += FormIndexEnd;
                }
            }

            return Forms;
        }
Exemple #30
0
    static public void Main(string[] args)
    {
        if (args.Length < 1 || (args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help")))
        {
            Console.WriteLine(usage);
        }
        else
        {
            try
            {
                string user = null, pw = null;
                string userPxy = null, pwPxy = null;

                //prepare http credentials
                string[] credentials = args[0].Split(":".ToCharArray(), 2);
                user = credentials[0];

                if (credentials.Length > 1)
                {
                    pw = credentials[1];
                }

                if (pw == null)
                {
                    if (!AuthenticationForm.GetCredentials(ref user, ref pw, "Account login"))
                    {
                        return;
                    }
                }
                //prepare proxy credentials
                if (args.Length > 1 && args[1].StartsWith("/p"))
                {
                    string[] credentialsPxy = args[1].Split(":".ToCharArray(), 3);
                    if (credentialsPxy.Length > 1)
                    {
                        userPxy = credentialsPxy[1];
                    }
                    if (credentialsPxy.Length > 2)
                    {
                        pwPxy = credentialsPxy[2];
                    }

                    if (userPxy == null || pwPxy == null)
                    {
                        if (!AuthenticationForm.GetCredentials(ref userPxy, ref pwPxy, "Proxy Authentication"))
                        {
                            return;
                        }
                    }
                }

                string htmlStr = GetHTML(String.Format(urlTemplate, user, pw), userPxy, pwPxy);

                string msg   = "";
                string title = "";
                using (StringReader strReader = new StringReader(htmlStr))
                {
                    string line;
                    while ((line = strReader.ReadLine()) != null)
                    {
                        if (line.StartsWith("plan_limit"))
                        {
                            msg += "Limit: " + line.Split("=".ToCharArray(), 2)[1] + "\n";
                        }
                        if (line.StartsWith("usage"))
                        {
                            msg += "Usage: " + line.Split("=".ToCharArray(), 2)[1] + "\n";
                        }
                        if (line.StartsWith("username"))
                        {
                            msg += "User: "******"=".ToCharArray(), 2)[1] + "\n";
                        }
                        if (line.StartsWith("plan_name"))
                        {
                            title = line.Split("=".ToCharArray(), 2)[1] + " Plan";
                        }
                    }
                }

                MessageBox.Show(msg, title);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
    }
 private void buttonOk_Click(object sender, EventArgs e)
 {
     if (listViewForms.SelectedIndices.Count > 0)
         authForm = authForms[listViewForms.SelectedIndices[0]];
 }
Exemple #32
0
        private void ConnectEventHandler(object sender, EventArgs e)
        {
            AuthenticationModeEnum  mode       = AuthenticationModeEnum.UsernameAndPassword;
            RemoteDesktopClientForm clientForm = new RemoteDesktopClientForm();

            try
            {
                clientForm.Connect(connectControl.Locator.ChannelId, connectControl.SelectedProvider.RemoteEndPoint);
                mode = clientForm.GetAuthenticationMode();
            }
            catch (Exception)
            {
                clientForm.Dispose();
                MessageBox.Show(this, "Failed to connect to the remote host.", Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            mActiveWindows.Add(clientForm);
            clientForm.FormClosed += new FormClosedEventHandler(ClientForm_FormClosed);
            clientForm.Show(this);

            while (true)
            {
                switch (mode)
                {
                case AuthenticationModeEnum.OnlyPassword:
                case AuthenticationModeEnum.UsernameAndPassword:
                    using (AuthenticationForm authForm = new AuthenticationForm(mode))
                    {
                        if (authForm.ShowDialog(clientForm) == System.Windows.Forms.DialogResult.OK)
                        {
                            try
                            {
                                if (HandleLoginResult(clientForm, clientForm.Login(authForm.Username, authForm.Password)))
                                {
                                    return;
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(clientForm, string.Format("Failed to login. Reason: {0}", ex.Message), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                if (!clientForm.IsConnected)
                                {
                                    clientForm.Close();
                                    //clientForm.Dispose();
                                    return;
                                }
                            }
                        }
                        else
                        {
                            clientForm.Close();
                            clientForm.Dispose();
                            return;
                        }
                    }
                    break;

                case AuthenticationModeEnum.Off:
                {
                    try
                    {
                        if (HandleLoginResult(clientForm, clientForm.Login(string.Empty, string.Empty)))
                        {
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        clientForm.Close();
                        clientForm.Dispose();
                        MessageBox.Show(clientForm, string.Format("Failed to login. Reason: {0}", ex.Message), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                break;
                }
            }
        }
Exemple #33
0
 public void OnGet(string returnUrl)
 {
     AuthenticationForm = new AuthenticationForm();
 }
        private void FillGUIInputFields(AuthenticationForm Form)
        {
            listViewInputFields.Items.Clear();
            for (int i = 0; i < Form.InputFields.Count; i++)
            {
                ListViewItem Item = new ListViewItem();
                string MarkedAs = string.Empty;
                if (Form.InputFields[i].InputType == InputField.InputTypes.Password)
                    MarkedAs = "Password";
                else if (Form.InputFields[i].InputType == InputField.InputTypes.Username)
                    MarkedAs = "Username";

                Item.Text = MarkedAs;
                Item.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = Form.InputFields[i].Name });
                Item.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = Form.InputFields[i].Type });
                Item.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = Form.InputFields[i].Value });

                listViewInputFields.Items.Add(Item);
            }
        }
Exemple #35
0
 public static bool GetCredentials(ref string userName, ref string password, string title)
 {
     using(AuthenticationForm dlg = new AuthenticationForm(userName, password, title))
     {
     if (DialogResult.OK == dlg.ShowDialog())
     {
         userName = dlg.userName;
         password = dlg.password;
         return true;
     }
     else
     {
         return false;
     }
     }
 }