Ejemplo n.º 1
0
        private String InputPassword(String promptMessage, uint passwordSize)
        {
            if (logonStatus == LogonStatus.Registering)
            {
                logonStatus = LogonStatus.RegisteringConfirmPassword;
                return(userInputPassword);
            }
            else if (logonStatus == LogonStatus.RegisteringConfirmPassword)
            {
                //// xDagWallet.PaswordPlain = confirmedPassword;
                logonStatus = LogonStatus.RegisteringRandomKeys;
                return(userInputPassword);
            }
            else if (logonStatus == LogonStatus.RegisteringRandomKeys)
            {
                // Dont let customer to fill the random letters, just randomly create one
                string randomkey = Guid.NewGuid().ToString();
                xdagWallet.RandomKey = randomkey;

                logonStatus = LogonStatus.RegisteringPending;
                return(randomkey);
            }
            else if (logonStatus == LogonStatus.Connecting)
            {
                logonStatus = LogonStatus.ConnectingPending;
                ShowStatus(Properties.Strings.LogonWindow_ConnectingAccount);
                return(userInputPassword);
            }

            return(string.Empty);
        }
 private Task InsertLogonForVolunteer(string volunteerId, string attemptedUsername
                                      , LogonStatus status, string failureNotes = null)
 {
     return(_volunteerCollection.InsertOneAsync(new VolunteerLogon
     {
         VolunteerId = volunteerId,
         AttemptedUsername = attemptedUsername,
         LogonTime = DateTime.UtcNow,
         Status = status,
         Notes = failureNotes
     }));
 }
Ejemplo n.º 3
0
    public void Logon()
    {
        Debug.Log("Logon function");
        _loggedOnUser        = "";
        _gamesPlayed         = 0;
        _gamesWon            = 0;
        _gamesLost           = 0;
        _winningStreak       = 0;
        _hstry_winningStreak = 0;

        if (_username == null)
        {
            Debug.Log("username textbox is null");
        }
        //gamesparks has their own registeration and authentication. I'll use theirs in the furutre
        string tempUser     = _username.text;
        string tempPassword = _password.text;

        if (tempUser == "")
        {
            return;
        }
        new GameSparks.Api.Requests.LogEventRequest()
        .SetEventKey("Logon")
        .SetEventAttribute("Username", tempUser)
        .SetEventAttribute("Password", tempPassword)
        .Send((response) =>
        {
            Debug.Log("Logon callback");
            if (!response.HasErrors)
            {
                _logonStatus = LogonStatus.LS_logon;
                Debug.Log("Logon attempt was made successfuly");
                bool success = (bool)response.ScriptData.GetBoolean("Success");
                if (success == true)
                {
                    Debug.Log("Successful logon - GameSparks");
                    _loggedOnUser        = tempUser;
                    _gamesPlayed         = (int)response.ScriptData.GetInt("GamesPlayed");
                    _gamesWon            = (int)response.ScriptData.GetInt("GamesWon");
                    _gamesLost           = _gamesPlayed - _gamesWon;
                    _winningStreak       = (int)response.ScriptData.GetInt("WinningStreak");
                    _hstry_winningStreak = (int)response.ScriptData.GetInt("Hstry_WinningStreak");

                    //encrypt username
                    CspParameters cspParams    = new CspParameters();
                    cspParams.KeyContainerName = "UsernameKey";          // This is the key used to encrypt and decrypt can be anything.
                    var provider          = new RSACryptoServiceProvider(cspParams);
                    byte[] encryptedBytes = provider.Encrypt(
                        System.Text.Encoding.UTF8.GetBytes(_username.text), true);
                    // convert to base64string first for storage as a string in the registry.
                    string encryptionString = System.Convert.ToBase64String(encryptedBytes);
                    PlayerPrefs.SetString("_Username", encryptionString);

                    byte[] encryptedBytes2 = provider.Encrypt(
                        System.Text.Encoding.UTF8.GetBytes(_password.text), true);
                    // convert to base64string first for storage as a string in the registry.
                    string encryptionString2 = System.Convert.ToBase64String(encryptedBytes2);
                    PlayerPrefs.SetString("_Password", encryptionString2);
                }
                else
                {
                    Debug.Log("FAILED");
                }
            }
            else
            {
                Debug.Log("Error logging");
            }
            UpdateGui();
        });
    }
Ejemplo n.º 4
0
 public MsgLogonStatus() : base(2)
 {
     this.Data = new LogonStatus();
 }
Ejemplo n.º 5
0
        private void ConnectAccount()
        {
            logger.Trace("Begin ConnectAccount().");

            if (runtime == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(walletConfig?.Options?.PoolAddress))
            {
                MessageBox.Show(Properties.Strings.LogonWindow_NoPoolAddress, Properties.Strings.Common_MessageTitle);
            }

            string poolAddress = walletConfig.Options.PoolAddress;

            PasswordWindow passwordWindow = new PasswordWindow(Properties.Strings.PasswordWindow_InputPassword, (passwordInput) =>
            {
                userInputPassword = passwordInput;
            });

            passwordWindow.ShowDialog();

            Thread.Sleep(50);

            if (string.IsNullOrEmpty(userInputPassword))
            {
                logger.Trace("User input empty password, cancel the connect.");
                return;
            }

            btnConnectAccount.IsEnabled = false;

            BackgroundWork.CreateWork(
                this,
                () => {
                ShowStatus(Properties.Strings.LogonWindow_SearchingConnection);
            },
                () => {
                logonStatus = LogonStatus.Connecting;
                runtime.Start(poolAddress);

                return(0);
            },
                (taskResult) => {
                logger.Trace("ConnectAccount work finished.");
                if (taskResult.HasError)
                {
                    if (taskResult.Exception is PasswordIncorrectException)
                    {
                        MessageBox.Show(Properties.Strings.Message_PasswordIncorrect, Properties.Strings.Common_MessageTitle);
                    }

                    btnConnectAccount.IsEnabled = true;
                    ////btnLang.IsEnabled = true;

                    HideStatus();
                    return;
                }

                // Do not call HideStatus here if no error, since it will continue to wait for callback
            }
                ).Execute();

            logger.Trace("End ConnectAccount().");
        }
Ejemplo n.º 6
0
        private void RegisterAccount()
        {
            if (runtime == null || logonStatus != LogonStatus.None)
            {
                return;
            }

            if (string.IsNullOrEmpty(walletConfig?.Options?.PoolAddress))
            {
                MessageBox.Show(Properties.Strings.LogonWindow_NoPoolAddress, Properties.Strings.Common_MessageTitle);
            }

            string poolAddress = walletConfig.Options.PoolAddress;

            PasswordWindow passwordWindow = new PasswordWindow(Properties.Strings.PasswordWindow_SetPassword, (passwordInput) =>
            {
                userInputPassword = passwordInput;
            });

            passwordWindow.ShowDialog();

            if (string.IsNullOrEmpty(userInputPassword))
            {
                return;
            }

            string confirmedPassword = string.Empty;

            passwordWindow = new PasswordWindow(Properties.Strings.PasswordWindow_RetypePassword, (passwordInput) =>
            {
                confirmedPassword = passwordInput;
            });
            passwordWindow.ShowDialog();
            if (!string.Equals(userInputPassword, confirmedPassword))
            {
                MessageBox.Show(Properties.Strings.PasswordWindow_PasswordMismatch);
                return;
            }

            btnRegisterAccount.IsEnabled = false;
            BackgroundWork.CreateWork(
                this,
                () => {
                logonStatus = LogonStatus.Registering;
                StartRegisteringTimer();

                ShowStatus(Properties.Strings.LogonWindow_InitializingAccount);
            },
                () => {
                runtime.Start(poolAddress);

                return(0);
            },
                (taskResult) => {
                if (taskResult.HasError)
                {
                    MessageBox.Show(Properties.Strings.LogonWindow_InitializeFailed + taskResult.Exception.Message);

                    btnRegisterAccount.IsEnabled = true;
                    ////btnLang.IsEnabled = true;

                    HideStatus();
                    return;
                }

                // Keep waiting after this finished, wait for it callback to update status
            }
                ).Execute();
        }
Ejemplo n.º 7
0
        private void OnMessageReceived(object sender, MessageEventArgs e)
        {
            Message message = e.Message;

            if (this.MessageIn != null)
            {
                this.MessageIn(this, new MessageEventArgs(message));
            }
            switch (message.Type)
            {
            case 1000:
                if (this.Tick != null)
                {
                    this.Tick(this, new TickEventArgs(((MsgTick)message).Data));
                }
                break;

            case 1001:
                if (this.Tick != null)
                {
                    this.Tick(this, new TickEventArgs((Tick)((MsgLevel2)message).Data));
                }
                break;

            case 1101:
                if (this.Report != null)
                {
                    this.Report(this, new ExecutionReportEventArgs(((MsgReport)message).Data));
                }
                break;

            case 1102:
                if (this.OrderCancelReject != null)
                {
                    this.OrderCancelReject(this, new OrderCancelRejectEventArgs(((MsgOrderCancelReject)message).Data));
                }
                break;

            case 2001:
                if (this.BrokerInfo != null)
                {
                    this.BrokerInfo(this, new BrokerInfoEventArgs(((MsgBrokerInfo)message).Data));
                }
                break;

            case 2:
                LogonStatus data1 = ((MsgLogonStatus)message).Data;
                if (data1.IsLoggedIn)
                {
                    this.EmitLoggedIn(data1.Text);
                    break;
                }
                else
                {
                    this.EmitLoggedOut(data1.Text);
                    break;
                }

            case 3:
                Heartbeat data2 = ((MsgHeartbeat)message).Data;
                if (this.Heartbeat != null)
                {
                    this.Heartbeat(this, new HeartbeatEventArgs(data2));
                }
                break;

            case 12:
                if (this.ProviderError != null)
                {
                    this.ProviderError(this, new ProviderErrorEventArgs(((MsgProviderError)message).Data));
                }
                break;

            case 13:
                if (this.SubscriptionStatus != null)
                {
                    this.SubscriptionStatus(this, new SubscriptionStatusEventArgs(((MsgSubscriptionStatus)message).Data));
                }
                break;
            }
        }