Exemplo n.º 1
0
        public void RequestPasswordWinForm(AccessPoint ap)
        {
            AuthRequest authRequest = null;

            try
            {
                // Auth
                authRequest = new AuthRequest(ap);
            }
            catch (System.NullReferenceException e)
            {
                //If null, ap banished when try to connect
                return;
            }
            bool overwrite = true;

            if (authRequest.IsPasswordRequired)
            {
                if (ap.HasProfile)
                // If there already is a stored profile for the network, we can either use it or overwrite it with a new password.
                {
                    ///For Windows Form
                    if (MessageBox.Show("Do you Want Connect using network profile?", "Using Profile", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        overwrite = false;
                    }
                }

                if (overwrite)
                {
                    ///For Windows Form
                    if (authRequest.IsUsernameRequired)
                    {
                        authRequest.Username = Microsoft.VisualBasic.Interaction.InputBox("Please Enter the UserName?", "UserName", "");
                    }

                    //PasswordPrompt
                    bool validPassFormat = false;
                    while (!validPassFormat)
                    {
                        string password;

                        password = Microsoft.VisualBasic.Interaction.InputBox("Please Enter the Password?", "Password", "");

                        validPassFormat = ap.IsValidPassword(password);
                        if (!validPassFormat)
                        {
                            if (MessageBox.Show(
                                    "Password is not valid for this network type.\n Do you want to re-enter the Password?",
                                    "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
                            {
                                break;
                            }
                        }
                        else
                        {
                            authRequest.Password = password;
                        }
                    }

                    if (authRequest.IsDomainSupported)
                    {
                        authRequest.Domain = Microsoft.VisualBasic.Interaction.InputBox("Please Enter the Domain?", "Domain", "");
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void RequestPasswordConsole(AccessPoint ap, bool useVBInputBox = false)
        {
            AuthRequest authRequest = null;

            try
            {
                // Auth
                authRequest = new AuthRequest(ap);
            }
            catch (System.NullReferenceException e)
            {
                //If null, ap banished when try to connect
                return;
            }
            bool overwrite = true;

            if (authRequest.IsPasswordRequired)
            {
                if (ap.HasProfile)
                // If there already is a stored profile for the network, we can either use it or overwrite it with a new password.
                {
                    ///For Console
                    Console.Write("\r\nA network profile already exist, do you want to use it (y/n)? ");
                    if (Console.ReadLine().ToLower() == "y")
                    {
                        overwrite = false;
                    }
                }

                if (overwrite)
                {
                    ///For Console
                    if (authRequest.IsUsernameRequired)
                    {
                        if (useVBInputBox)
                        {
                            authRequest.Username =
                                Microsoft.VisualBasic.Interaction.InputBox("Please Enter the UserName?", "UserName",
                                                                           "");
                        }
                        else
                        {
                            Console.Write("\r\nPlease enter a username: "******"Please Enter the Password?", "Password", "");
                        }
                        else
                        {
                            Console.Write("\r\nPlease enter the wifi password: "******"\r\nPassword is not valid for this network type.");
                        }
                        else
                        {
                            authRequest.Password = password;
                        }
                    }

                    if (!authRequest.IsDomainSupported)
                    {
                        return;
                    }
                    if (useVBInputBox)
                    {
                        authRequest.Domain =
                            Microsoft.VisualBasic.Interaction.InputBox("Please Enter the Domain?", "Domain", "");
                    }
                    else
                    {
                        Console.Write("\r\nPlease enter a domain: ");
                        authRequest.Domain = Console.ReadLine();
                    }
                }
            }
        }
Exemplo n.º 3
0
        static string PasswordPrompt(AccessPoint selectedAP)
        {
            string password = string.Empty;

            bool validPassFormat = false;

            while (!validPassFormat)
            {
                Console.Write("\r\nPlease enter the wifi password: "******"\r\nPassword is not valid for this network type.");
            }

            return password;
        }