Exemple #1
0
        private void handleWelcomeMessage(int serverVersion, int authMethod)
        {
            // We have some autologin going, ignore welcome message
            if (autologinKey != null)
            {
                return;
            }

            switch (authMethod)
            {
            // AuthMethod: User&Password or Both
            case 1:
            case 3:
                PasswordDialog pwDialog = new PasswordDialog();
                pwDialog.ShowDialog();
                if (pwDialog.DialogResult.Equals(DialogResult.OK))
                {
                    MessageIdentify identificationMessage = new MessageIdentify();
                    identificationMessage.Authenticate = new Authenticate(pwDialog.GetUsername(), pwDialog.GetPassword());
                    SendCommand(identificationMessage, socket);
                }
                else
                {
                    socket.Close();
                }
                break;

            // AuthMethod: Passcode
            case 2:
                PasscodeDialog pcDialog = new PasscodeDialog();
                pcDialog.ShowDialog();
                if (pcDialog.DialogResult.Equals(DialogResult.OK))
                {
                    MessageIdentify identificationMessage = new MessageIdentify();
                    identificationMessage.Authenticate = new Authenticate(pcDialog.GetPasscode());
                    SendCommand(identificationMessage, socket);
                }
                else
                {
                    socket.Close();
                }
                break;

            // AuthMethod: None
            case 0:
            default:
                SendCommand(new MessageIdentify(), socket);
                break;
            }
        }
Exemple #2
0
        private void handleWelcomeMessage(int serverVersion, int authMethod)
        {
            // We have some autologin going, ignore welcome message
            if (autologinKey != null) return;

            switch (authMethod)
            {
                // AuthMethod: User&Password or Both
                case 1:
                case 3:
                    PasswordDialog pwDialog = new PasswordDialog();
                    pwDialog.ShowDialog();
                    if (pwDialog.DialogResult.Equals(DialogResult.OK))
                    {
                        MessageIdentify identificationMessage = new MessageIdentify();
                        identificationMessage.Authenticate = new Authenticate(pwDialog.GetUsername(), pwDialog.GetPassword());
                        SendCommand(identificationMessage, socket);
                    }
                    else
                    {
                        socket.Close();
                    }
                    break;

                // AuthMethod: Passcode
                case 2:
                    PasscodeDialog pcDialog = new PasscodeDialog();
                    pcDialog.ShowDialog();
                    if (pcDialog.DialogResult.Equals(DialogResult.OK))
                    {
                        MessageIdentify identificationMessage = new MessageIdentify();
                        identificationMessage.Authenticate = new Authenticate(pcDialog.GetPasscode());
                        SendCommand(identificationMessage, socket);
                    }
                    else
                    {
                        socket.Close();
                    }
                    break;

                // AuthMethod: None
                case 0:
                default:
                    SendCommand(new MessageIdentify(), socket);
                    break;
            }
        }