public LogonResult Logon(LogonParameters parameters)
        {
            LogonResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                using (IDbConnection connection = new DbConnection(ConnectionString))
                {
                    connection.Open();

                    using (IDbCommand command = connection.CreateCommand())
                    {
                        command.CommandText = "Authentication.Logon_SmartClient";

                        ((OracleCommand)command).BindByName = true;

                        foreach (IDbDataParameter parameter in LogonTranslator.TranslateParameters(parameters))
                        {
                            command.Parameters.Add(parameter);
                        }

                        LogDbCommand(command);

                        command.Prepare();
                        command.CommandType = CommandType.StoredProcedure;
                        command.ExecuteNonQuery();
                        result = LogonTranslator.TranslateResult(command.Parameters);
                    }
                }

                scope.Complete();
            }

            return(result);
        }
        public static async void HandleVerifyWebCredentialsRequest(VerifyWebCredentialsRequest verifyWebCredentials, BnetSession session)
        {
            var logonResult = new LogonResult();

            if (verifyWebCredentials.WebCredentials.ToStringUtf8() == session.LoginTicket)
            {
                logonResult.AccountId = new EntityId
                {
                    High = 0x100000000000000,
                    Low  = session.Account.Id
                };

                session.Account.GameAccounts.ForEach(ga =>
                {
                    logonResult.GameAccountId.Add(new EntityId
                    {
                        // TODO: Build the right High value.
                        High = 0x200000200576F57,
                        Low  = ga.Id
                    });
                });

                logonResult.SessionKey = ByteString.CopyFromUtf8(new byte[0].GenerateRandomKey(64).ToHexString());
            }
            else
            {
                logonResult.ErrorCode = (uint)BnetErrorCode.Denied;
            }

            await session.Send(logonResult, BnetServiceHash.AuthenticationListenerService, 5);
        }
示例#3
0
        /// <summary>
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="pwd"></param>
        public LogonResult login(string userID, string pwd)
        {
            //一个枚举类型,登录的标志,数字类型
            LogonResult logonResult = LogonResult.Succeed;

            try
            {
                //系统标志。引擎在初始化时会提交给服务器验证客户端是否是正确的系统
                this.engine.SystemToken = "";

                /*初始化引擎并登录,返回登录结果。如果登陆成功,引擎将与当前用户绑定,如果连接失败,则抛出异常
                 *完成客户端引擎的初始化,与服务器建立TCP连接,连接成功后立即验证用户密码。。
                 *参数1:当前登录的用户ID
                 *参数2:用户登陆密码
                 *参数3:服务器的IP地址
                 *参数4:服务器的端口
                 *参数5:自定义处理器customizeHandler,用于处理服务器或其它用户发送过来的消息*/
                logonResult = this.engine.Initialize(userID, pwd, Constant.serverIP, Constant.serverPort, this._main).LogonResult;
            }
            catch (Exception ee)
            {
                //MessageBox.Show(string.Format("连接服务器失败。{0}", ee.Message));
                //return;
            }
            return(logonResult);
        }
        public static async void HandleVerifyWebCredentialsRequest(VerifyWebCredentialsRequest verifyWebCredentials, BnetSession session)
        {
            var logonResult = new LogonResult();

            if (verifyWebCredentials.WebCredentials.ToStringUtf8() == session.LoginTicket)
            {
                logonResult.AccountId = new EntityId
                {
                    High = 0x100000000000000,
                    Low = session.Account.Id
                };

                session.Account.GameAccounts.ForEach(ga =>
                {
                    logonResult.GameAccountId.Add(new EntityId
                    {
                        // TODO: Build the right High value.
                        High = 0x200000200576F57,
                        Low = ga.Id
                    });
                });

                logonResult.SessionKey = ByteString.CopyFromUtf8(new byte[0].GenerateRandomKey(64).ToHexString());
            }
            else
                logonResult.ErrorCode = (uint)BnetErrorCode.Denied;

            await session.Send(logonResult, BnetServiceHash.AuthenticationListenerService, 5);
        }
        public LogonResult LogonPlayer(string playerName)
        {
            var result    = new LogonResult();
            var newPlayer = new Player()
            {
                AuthToken  = System.Guid.NewGuid().ToString(),
                PlayerName = playerName,
                Id         = _MAXPLAYERID++
            };

            var playerAdded    = Players.TryAdd(playerName + newPlayer.AuthToken, newPlayer);
            var authTokenAdded = AuthTokens.TryAdd(newPlayer.AuthToken, newPlayer);

            if (playerAdded && authTokenAdded)
            {
                System.Diagnostics.Debug.WriteLine("Player logon [{0}]:[{1}]", newPlayer.PlayerName, newPlayer.AuthToken);
            }

            result.AuthToken = newPlayer.AuthToken;
            result.Id        = newPlayer.Id;
            result.GameId    = Id;
            result.GameStart = this.gameStart;
            result.Success   = true;

            return(result);
        }
    private void HandleLogonCompleteRequest(RPCContext context)
    {
        LogonResult     result    = LogonResult.ParseFrom(context.Payload);
        BattleNetErrors errorCode = (BattleNetErrors)result.ErrorCode;

        if (errorCode != BattleNetErrors.ERROR_OK)
        {
            base.m_battleNet.EnqueueErrorInfo(BnetFeature.Auth, BnetFeatureEvent.Auth_OnFinish, errorCode, context.Context);
        }
        else
        {
            this.m_accountEntity = result.Account;
            base.m_battleNet.Presence.PresenceSubscribe(this.m_accountEntity);
            this.m_gameAccounts = new List <EntityId>();
            foreach (EntityId id in result.GameAccountList)
            {
                this.m_gameAccounts.Add(id);
                base.m_battleNet.Presence.PresenceSubscribe(id);
            }
            if (this.m_gameAccounts.Count > 0)
            {
                this.m_gameAccount = result.GameAccountList[0];
            }
            base.m_battleNet.IssueSelectGameAccountRequest();
            base.m_battleNet.SetConnectedRegion(result.ConnectedRegion);
            object[] args = new object[] { result };
            base.ApiLog.LogDebug("LogonComplete {0}", args);
            object[] objArray2 = new object[] { result.ConnectedRegion };
            base.ApiLog.LogDebug("Region (connected): {0}", objArray2);
            BIReport.Get().Report_Telemetry(Telemetry.Level.LEVEL_INFO, BIReport.TelemetryEvent.EVENT_LOGIN_SUCCESS);
        }
    }
        private void HandleLogonCompleteRequest(RPCContext context)
        {
            LogonResult     logonResult = LogonResult.ParseFrom(context.Payload);
            BattleNetErrors errorCode   = (BattleNetErrors)logonResult.ErrorCode;

            if (errorCode != BattleNetErrors.ERROR_OK)
            {
                this.m_battleNet.EnqueueErrorInfo(BnetFeature.Auth, BnetFeatureEvent.Auth_OnFinish, errorCode, 0);
                return;
            }
            this.m_accountEntity = logonResult.Account;
            this.m_battleNet.Presence.PresenceSubscribe(this.m_accountEntity);
            this.m_gameAccounts = new List <bnet.protocol.EntityId>();
            foreach (bnet.protocol.EntityId gameAccountList in logonResult.GameAccountList)
            {
                this.m_gameAccounts.Add(gameAccountList);
                this.m_battleNet.Presence.PresenceSubscribe(gameAccountList);
            }
            if (logonResult.HasBattleTag)
            {
                this.m_battleTag = logonResult.BattleTag;
            }
            if (this.m_gameAccounts.Count > 0)
            {
                this.m_gameAccount = logonResult.GameAccountList[0];
            }
            this.m_sessionKey = logonResult.SessionKey;
            this.m_battleNet.IssueSelectGameAccountRequest();
            this.m_battleNet.SetConnectedRegion(logonResult.ConnectedRegion);
            base.ApiLog.LogDebug("LogonComplete {0}", new object[] { logonResult });
            base.ApiLog.LogDebug("Region (connected): {0}", new object[] { logonResult.ConnectedRegion });
        }
示例#8
0
        public void SendAuthenticationClientLogonComplete(LogonResult pLogonResult)
        {
            MemoryStream response = new MemoryStream(64);

            pLogonResult.Write(response);
            SendRPC(ClientExportedServiceIds.AuthenticationClient, AuthenticationClientMethodIds.LogonComplete, 0, 0, response);
        }
 private static string TranslateResult(LogonResult reason)
 {
     return(reason switch
     {
         LogonResult.Succeeded => "Valid credential, logon succeeded",// this should never happen!!!
         LogonResult.NoLogonData => "No cached {0} credential: run the {1} command.",
         LogonResult.LogonExpired => "Cached {0} credential expired: run the {1} command.",
         _ => throw new ArgumentOutOfRangeException(nameof(reason)),
     });
示例#10
0
 public LogonFullResponse(LogonResult result, string _failureCause, bool _P2P, bool _groupRelationEnabled, bool _useAsP2PServer)
 {
     this.bool_0       = true;
     this.aroLejaQpM   = true;
     this.bool_1       = true;
     base.logonResult  = result;
     base.failureCause = _failureCause;
     this.bool_0       = _P2P;
     this.bool_1       = _groupRelationEnabled;
     this.aroLejaQpM   = _useAsP2PServer;
 }
示例#11
0
        /// <summary>
        ///     Обработка результата логина
        /// </summary>
        private void Handle(LogonResult msg)
        {
            var resultCode = (LogonResult.ResultCode)msg.result_code;

            switch (resultCode)
            {
            case LogonResult.ResultCode.SUCCESS:
                Log.Info().Print($"Connected to CQG with login {settings?.Username}");
                if (!DateTime.TryParseExact(
                        msg.base_time,
                        "yyyy-MM-ddTHH:mm:ss",
                        CultureInfo.InvariantCulture,
                        DateTimeStyles.AssumeUniversal,
                        out baseTime))
                {
                    baseTime = DateTime.UtcNow;
                    Log.Warn().Print($"Unable to parse base_time = msg.base_time. Order and fill timestamps might be corrupted. Historical data won't work at all.");
                }

                //[ENABLE_CQGC_TRACE]WebApiTrace.SetBaseTime(baseTime);
                connectionStatus = ConnectionStatus.Connected;
                OnConnectionStatusChanged(connectionStatus);
                logoffEfent.Reset();
                RequestInitializingData();

                return;

            case LogonResult.ResultCode.FAILURE:
                break;

            case LogonResult.ResultCode.NO_ONETIME_PASSWORD:
                break;

            case LogonResult.ResultCode.PASSWORD_EXPIRED:
                return;

            case LogonResult.ResultCode.CONCURRENT_SESSION:
                break;

            case LogonResult.ResultCode.REDIRECTED:
                break;
            }

            Log.Error().Print("Unable to log in", LogFields.Result(resultCode), LogFields.Message(msg.text_message));
            connectionStatus = ConnectionStatus.Terminated;
            OnConnectionStatusChanged(connectionStatus);

            using (socketLock.Lock())
            {
                Log.Debug().Print("Closing CQG socket");
                socket?.Close();
            }
        }
示例#12
0
        public LogonResult Logon(string Tell)
        {
            LogonResult mLogonResult = new LogonResult();

            try
            {
                User mUser = BLL.Profile.GetUserByTellNumber(Tell);
                if (mUser == null)
                {
                    mUser = new User()
                    {
                        Active     = false,
                        ActiveCode = CreateRandomCode(),
                        CodeMeli   = "",
                        JoinDate   = DateTime.Now,
                        Name       = "",
                        TellNumber = Tell,
                        Role       = 0,
                    };

                    int UID = BLL.Profile.AddUser(mUser);

                    mLogonResult.IsNew = true;
                    new System.Threading.Thread(delegate() { SendActivationCodeViaSMS(Tell, mUser.ActiveCode); }).Start();
                    new System.Threading.Thread(delegate() { BLL.Log.DoLog(COM.Action.Logon, Tell, 1, null); }).Start();
                    mLogonResult.UserID = mUser.UID;
                }
                else
                {
                    string NewActiveCode = CreateRandomCode();
                    if (Tell == "989123456789")//mehr
                    {
                        NewActiveCode = "12345";
                    }
                    mUser.ActiveCode = NewActiveCode;
                    bool Res = BLL.Profile.UpdateUserActiveCode(mUser);
                    mLogonResult.IsNew    = false;
                    mLogonResult.NickName = mUser.Name;

                    new System.Threading.Thread(delegate() { SendActivationCodeViaSMS(Tell, NewActiveCode); }).Start();
                    new System.Threading.Thread(delegate() { BLL.Log.DoLog(COM.Action.Logon, Tell, 1, null); }).Start();
                    mLogonResult.UserID = mUser.UID;
                }
            }
            catch (Exception e)
            {
                new System.Threading.Thread(delegate() { BLL.Log.DoLog(COM.Action.Logon, Tell, 0, e.Message); }).Start();
                mLogonResult.UserID = -200;
                mLogonResult.IsNew  = false;
            }
            return(mLogonResult);
        }
        internal static LogonResponse FromXmlElement(XElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            // get the result...
            string      asString = XmlHelper.GetElementString(element, "Result", true);
            LogonResult result   = (LogonResult)Enum.Parse(typeof(LogonResult), asString, true);

            return(new LogonResponse(result, XmlHelper.GetElementString(element, "Message", false),
                                     XmlHelper.GetElementString(element, "Token", false)));
        }
示例#14
0
        public static LogonResult TranslateResult(IDataParameterCollection resultParameters)
        {
            LogonResult result = new LogonResult();
            object      data;

            data = ((IDbDataParameter)resultParameters["ALMID_O"]).Value;

            if (data != DBNull.Value)
            {
                result.AlarmId = DbTypeConvertor.Convert <string>(data);
            }

            return(result);
        }
示例#15
0
文件: VNET_LOGON.cs 项目: Lynxy/VNet
 /// <summary>
 /// Sends a logon result to a user
 /// </summary>
 /// <param name="user">The user to send to</param>
 /// <param name="result">The logon result</param>
 protected void SendLogonResult(User user, LogonResult result)
 {
     //if (result == LogonResult.SUCCESS)
     //{
     //}
     //else
     //{
     user.Packet.Clear()
         .InsertByte((byte)result)
         .InsertStringNT("server ver")
         .InsertStringNT("TestEnv")
         .InsertStringNT(user.Username)
         .InsertDWord(0) //ping
         .InsertByte(0) //flag
         .Send(VNET_LOGON);
     //}
 }
示例#16
0
        private string TranslateResult(LogonResult reason)
        {
            switch (reason)
            {
            case LogonResult.Succeeded:
                // this should never happen!!!
                return("Valid credential, logon succeeded");

            case LogonResult.NoLogonData:
                return("No cached {0} credential: run the {1} command.");

            case LogonResult.LogonExpired:
                return("Cached {0} credential expired: run the {1} command.");

            default:
                throw new ArgumentOutOfRangeException(nameof(reason));
            }
        }
示例#17
0
        public LogonResult Execute(LogonParameters parameters)
        {
            LogonResult result = null;

            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[schemaName];
            string connectionString           = settings.ConnectionString;

            IAuthenticationDao dao = new AuthenticationDao(connectionString);

            result = dao.Logon(parameters);

            if (!string.IsNullOrEmpty(result.AlarmId))
            {
                RaiseAlarmAction.Execute(result.AlarmId);
            }

            return(result);
        }
示例#18
0
        private async void GoToMainMenuView(object sender, EventArgs args)
        {
            if (UserName.Text == null || UserName.Text.Trim() == "")
            {
                await DisplayAlert("Error", "Please enter UserName", "OK");

                UserName.Focus();
                return;
            }

            if (Password.Text == null || Password.Text.Trim() == "")
            {
                await DisplayAlert("Error", "Please enter Password", "OK");

                Password.Focus();
                return;
            }
            btnLogin.IsEnabled = false;
            LogonResult result = await DependencyService.Get <ILogon>().LogonAsync(
                UserName.Text.Trim(),
                Password.Text.Trim(),
                Session.AuthID);

            btnLogin.IsEnabled = true;
            if (result.InvalidDetails == true)
            {
                await DisplayAlert("Warning", "Invalid Username and Password.", "OK");

                UserName.Text = "";
                Password.Text = "";
                UserName.Focus();
            }
            else
            {
                DependencyService.Get <ISettings>().SetSessionToLocalSetting(
                    UserName.Text.Trim(),
                    result.Token,
                    DateTime.Now);
                Session.Token           = result.Token;
                Session.CurrentUserName = UserName.Text.Trim();
                Session.LoggedTime      = DateTime.Now;
                Device.BeginInvokeOnMainThread(() => Navigation.PushAsync(new MainMenuPage()));
            }
        }
        LogonResult Logon(LogonInfo logonInfo)
        {
            LogonResult logonResult = null;

            try
            {
                new TServiceFactory().Create().Using(service =>
                {
                    logonResult = service.Logon(logonInfo);
                }, () => new TServiceFactory().Create());
            }
            catch (Exception e) //(FaultException<AuthenticationCrmServiceError> e)
            {
                //    XtraMessageBox.Show("Произошел сбой авторизации пользователя. \r\nПопробуйте повторить вызов тек. операции", "PKI.CRM", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                new TServiceFactory().ShowErrorMessage(null, true, exception: e);
            }

            return(logonResult);
        }
示例#20
0
        public LogonResult Logon(LogonInfo info)
        {
            LogonResult result = new LogonResult()
            {
                Success = false
            };

            try
            {
                var process = Configuration.Configure();
                process.Logon(info?.LicenseGuid, new LicenseDAL.Models.LogonHistory()
                {
                    MachineName        = info?.History?.MachineName,
                    Login              = info?.History?.UserName,
                    UserDomainName     = info?.History?.UserDomainName,
                    HardwareId         = info?.History?.HardwareId,
                    ApplicationVersion = info?.History?.CurrentVersion,
                    ApplicationName    = info?.History?.ApplicationName,
                    ProductName        = info?.History?.ProductName,
                    ProductId          = info?.History?.ProductId,
                    CSDBuildNumber     = info?.History?.CSDBuildNumber,
                    CSDVersion         = info?.History?.CSDVersion,
                    CurrentBuild       = info?.History?.CurrentBuild,
                    RegisteredOwner    = info?.History?.RegisteredOwner,
                    ServerUrl          = info?.History?.ServerUrl
                });

                return(new LogonResult()
                {
                    Success = process.IsValid, Message = process.ErrorMessage
                });
            }
            catch (Exception e)
            {
                _logger.Error(e.ToString());
                result.Message = "Произошла ошибка на сервере. Попробуйте позже";
            }

            return(result);
        }
        private void HandleLogonCompleteRequest(RPCContext context)
        {
            byte[]          payload     = context.Payload;
            LogonResult     logonResult = LogonResult.ParseFrom(payload);
            BattleNetErrors errorCode   = (BattleNetErrors)logonResult.ErrorCode;

            if (errorCode != BattleNetErrors.ERROR_OK)
            {
                this.m_battleNet.EnqueueErrorInfo(BnetFeature.Auth, BnetFeatureEvent.Auth_OnFinish, errorCode, 0);
                return;
            }
            this.m_accountEntity = logonResult.Account;
            this.m_battleNet.Presence.PresenceSubscribe(this.m_accountEntity);
            this.m_gameAccounts = new List <bnet.protocol.EntityId>();
            using (List <bnet.protocol.EntityId> .Enumerator enumerator = logonResult.GameAccountList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    bnet.protocol.EntityId current = enumerator.get_Current();
                    this.m_gameAccounts.Add(current);
                    this.m_battleNet.Presence.PresenceSubscribe(current);
                }
            }
            if (this.m_gameAccounts.get_Count() > 0)
            {
                this.m_gameAccount = logonResult.GameAccountList.get_Item(0);
            }
            this.m_sessionKey = logonResult.SessionKey;
            this.m_battleNet.IssueSelectGameAccountRequest();
            this.m_battleNet.SetConnectedRegion(logonResult.ConnectedRegion);
            base.ApiLog.LogDebug("LogonComplete {0}", new object[]
            {
                logonResult
            });
            base.ApiLog.LogDebug("Region (connected): {0}", new object[]
            {
                logonResult.ConnectedRegion
            });
        }
示例#22
0
文件: Logon.cs 项目: norio-soft/UWP
        public async Task <LogonResult> LogonAsync(string v_sUsername, string v_sPassword, string v_sAuthID)
        {
            LogonResult rtn = new LogonResult();

            try
            {
                WcfLogin.LogonResult sResult = await m_loginClient.LogonAsync(v_sUsername, v_sPassword, v_sAuthID);

                if (sResult.CallSuccessfull == true)
                {
                    rtn.CallSuccessfull = sResult.CallSuccessfull;
                    rtn.AccountDisabled = sResult.AccountDisabled;
                    rtn.InvalidDetails  = sResult.InvalidDetails;
                    rtn.Token           = sResult.Token;
                }
                return(rtn);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#23
0
        private void button_login_Click(object sender, EventArgs e)
        {
            string userID = this.textBox_id.Text.Trim();

            if (userID.Length > 10)
            {
                MessageBox.Show("ID长度必须小于10.");
                return;
            }

            LogonResult logonResult = LogonResult.Succeed;

            try
            {
                this.rapidPassiveEngine.SystemToken = "";                                                                                      //系统标志
                //初始化引擎并登录,返回登录结果。如果登陆成功,引擎将与当前用户绑定。
                logonResult = this.rapidPassiveEngine.Initialize(userID, this.textBox_pwd.Text, "127.0.0.1", 4530, this.mainForm).LogonResult; //59.175.145.163
            }
            catch (Exception ee)
            {
                MessageBox.Show(string.Format("连接服务器失败。{0}", ee.Message));
                return;
            }

            if (logonResult == LogonResult.Failed)
            {
                MessageBox.Show("用户名或密码错误!");
                return;
            }

            if (logonResult == LogonResult.HadLoggedOn)
            {
                MessageBox.Show("已经在其它地方登陆!");
                return;
            }


            this.DialogResult = DialogResult.OK;
        }
        public LogonResult LogonPlayer(string playerName)
        {
            var result = new LogonResult();

            if (!Players.ContainsKey(playerName))
            {
                var newPlayer = new Player()
                {
                    AuthToken  = System.Guid.NewGuid().ToString(),
                    PlayerName = playerName,
                    Id         = _MAXPLAYERID++
                };

                var success  = Players.TryAdd(playerName, newPlayer);
                var success2 = AuthTokens.TryAdd(newPlayer.AuthToken, newPlayer);

                if (success && success2)
                {
                    System.Diagnostics.Debug.WriteLine("Player logon [{0}]:[{1}]", newPlayer.PlayerName,
                                                       newPlayer.AuthToken);
                }


                result.AuthToken = newPlayer.AuthToken;
                result.Id        = newPlayer.Id;
                result.GameId    = Id;
                result.GameStart = this.gameStart;
                result.Success   = true;
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Player {0} already logged on!", playerName);
            }
            result.GameId = Id;

            return(result);
        }
示例#25
0
        public static void OnPacket(Client client, Logon logon)
        {
            PacketId packid = PacketManager.me.typeIdSets[typeof(Logon)];

            LogonResult result = new LogonResult();

            result.BallIndex = ballIndex++;
            result.X         = ClientPool.xx[result.BallIndex];
            result.Y         = ClientPool.yy[result.BallIndex];
            client.Send(result);

            AllSmallBalls smallBalls = new AllSmallBalls();

            smallBalls.SmallBallCount = SmallBalls.smallBallCount;
            smallBalls.BallX          = new float[SmallBalls.smallBallCount];
            smallBalls.BallY          = new float[smallBalls.SmallBallCount];
            for (int i = 0; i < smallBalls.BallX.Length; i++)
            {
                smallBalls.BallX[i] = SmallBalls.me.ballx[i];
                smallBalls.BallY[i] = SmallBalls.me.bally[i];
            }
            client.Send(smallBalls);
            client.SetStatus(Client.Status.Working);
        }
 internal LogonResponse(LogonResult result, string message, string token)
 {
     this.Result = result;
     this.Message = message;
     this.Token = token;
 }
 BattlenetRpcErrorCode HandleOnLogonComplete(LogonResult request)
 {
     Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonComplete: {1}",
                  GetCallerInfo(), request.ToString());
     return(BattlenetRpcErrorCode.RpcNotImplemented);
 }
        public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
        {
            switch (methodId)
            {
            case 1:
            {
                ModuleLoadRequest request = new ModuleLoadRequest();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnModuleLoad(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnModuleLoad(bgs.protocol.authentication.v1.ModuleLoadRequest: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 2:
            {
                ModuleMessageRequest request = new ModuleMessageRequest();
                request.MergeFrom(stream);


                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleOnModuleMessage(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnModuleMessage(bgs.protocol.authentication.v1.ModuleMessageRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 4:
            {
                ServerStateChangeRequest request = new ServerStateChangeRequest();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnServerStateChange(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnServerStateChange(bgs.protocol.authentication.v1.ServerStateChangeRequest: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 5:
            {
                LogonResult request = new LogonResult();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnLogonComplete(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonComplete(bgs.protocol.authentication.v1.LogonResult: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 6:
            {
                MemModuleLoadRequest request = new MemModuleLoadRequest();
                request.MergeFrom(stream);


                MemModuleLoadResponse response = new MemModuleLoadResponse();
                BattlenetRpcErrorCode status   = HandleOnMemModuleLoad(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnMemModuleLoad(bgs.protocol.authentication.v1.MemModuleLoadRequest: {1}) returned bgs.protocol.authentication.v1.MemModuleLoadResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 10:
            {
                LogonUpdateRequest request = new LogonUpdateRequest();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnLogonUpdate(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonUpdate(bgs.protocol.authentication.v1.LogonUpdateRequest: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 11:
            {
                VersionInfoNotification request = new VersionInfoNotification();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnVersionInfoUpdated(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnVersionInfoUpdated(bgs.protocol.authentication.v1.VersionInfoNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 12:
            {
                LogonQueueUpdateRequest request = new LogonQueueUpdateRequest();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnLogonQueueUpdate(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonQueueUpdate(bgs.protocol.authentication.v1.LogonQueueUpdateRequest: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 13:
            {
                NoData request = new NoData();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnLogonQueueEnd(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonQueueEnd(bgs.protocol.NoData: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 14:
            {
                GameAccountSelectedRequest request = new GameAccountSelectedRequest();
                request.MergeFrom(stream);


                BattlenetRpcErrorCode status = HandleOnGameAccountSelected(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnGameAccountSelected(bgs.protocol.authentication.v1.GameAccountSelectedRequest: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            default:
                Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
                SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
                break;
            }
        }
示例#29
0
        public LogonResult LogonPlayer(string playerName)
        {
            var result = new LogonResult();
            if (!Players.ContainsKey(playerName))
            {
                var newPlayer = new Player()
                {
                    AuthToken = System.Guid.NewGuid().ToString(),
                    PlayerName = playerName,
                    Id = _MAXPLAYERID++
                };

                var success = Players.TryAdd(playerName, newPlayer);
                var success2 = AuthTokens.TryAdd(newPlayer.AuthToken, newPlayer);

                if (success && success2)
                {
                    System.Diagnostics.Debug.WriteLine("Player logon [{0}]:[{1}]", newPlayer.PlayerName,
                        newPlayer.AuthToken);
                }


                result.AuthToken = newPlayer.AuthToken;
                result.Id = newPlayer.Id;
                result.GameId = Id;
                result.GameStart = this.gameStart;
                result.Success = true;
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Player {0} already logged on!", playerName);
            }
            result.GameId = Id;

            return result;
        }
示例#30
0
        public void HandleLoginRequest(HttpHeader request)
        {
            LogonData   loginForm   = Json.CreateObject <LogonData>(request.Content);
            LogonResult loginResult = new LogonResult();

            if (loginForm == null)
            {
                loginResult.AuthenticationState = "LOGIN";
                loginResult.ErrorCode           = "UNABLE_TO_DECODE";
                loginResult.ErrorMessage        = "There was an internal error while connecting to Battle.net. Please try again later.";
                SendResponse(HttpCode.BadRequest, loginResult);
                return;
            }

            string login    = "";
            string password = "";

            for (int i = 0; i < loginForm.Inputs.Count; ++i)
            {
                switch (loginForm.Inputs[i].Id)
                {
                case "account_name":
                    login = loginForm.Inputs[i].Value;
                    break;

                case "password":
                    password = loginForm.Inputs[i].Value;
                    break;
                }
            }

            PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_AUTHENTICATION);

            stmt.AddValue(0, login);

            SQLResult result = DB.Login.Query(stmt);

            if (!result.IsEmpty())
            {
                uint   accountId         = result.Read <uint>(0);
                string pass_hash         = result.Read <string>(1);
                uint   failedLogins      = result.Read <uint>(2);
                string loginTicket       = result.Read <string>(3);
                uint   loginTicketExpiry = result.Read <uint>(4);
                bool   isBanned          = result.Read <ulong>(5) != 0;

                if (CalculateShaPassHash(login, password) == pass_hash)
                {
                    if (loginTicket.IsEmpty() || loginTicketExpiry < Time.UnixTime)
                    {
                        byte[] ticket = new byte[0].GenerateRandomKey(20);
                        loginTicket = "TC-" + ticket.ToHexString();
                    }

                    stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_AUTHENTICATION);
                    stmt.AddValue(0, loginTicket);
                    stmt.AddValue(1, Time.UnixTime + 3600);
                    stmt.AddValue(2, accountId);

                    DB.Login.Execute(stmt);
                    loginResult.LoginTicket = loginTicket;
                }
                else if (!isBanned)
                {
                    uint maxWrongPassword = ConfigMgr.GetDefaultValue("WrongPass.MaxCount", 0u);

                    if (ConfigMgr.GetDefaultValue("WrongPass.Logging", false))
                    {
                        Log.outDebug(LogFilter.Network, "[{0}, Account {1}, Id {2}] Attempted to connect with wrong password!", request.Host, login, accountId);
                    }

                    if (maxWrongPassword != 0)
                    {
                        SQLTransaction trans = new SQLTransaction();
                        stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_FAILED_LOGINS);
                        stmt.AddValue(0, accountId);
                        trans.Append(stmt);

                        ++failedLogins;

                        Log.outDebug(LogFilter.Network, "MaxWrongPass : {0}, failed_login : {1}", maxWrongPassword, accountId);

                        if (failedLogins >= maxWrongPassword)
                        {
                            BanMode banType = ConfigMgr.GetDefaultValue("WrongPass.BanType", BanMode.Ip);
                            int     banTime = ConfigMgr.GetDefaultValue("WrongPass.BanTime", 600);

                            if (banType == BanMode.Account)
                            {
                                stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_BNET_ACCOUNT_AUTO_BANNED);
                                stmt.AddValue(0, accountId);
                            }
                            else
                            {
                                stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_IP_AUTO_BANNED);
                                stmt.AddValue(0, request.Host);
                            }

                            stmt.AddValue(1, banTime);
                            trans.Append(stmt);

                            stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_RESET_FAILED_LOGINS);
                            stmt.AddValue(0, accountId);
                            trans.Append(stmt);
                        }

                        DB.Login.CommitTransaction(trans);
                    }
                }

                loginResult.AuthenticationState = "DONE";
                SendResponse(HttpCode.Ok, loginResult);
            }
            else
            {
                loginResult.AuthenticationState = "LOGIN";
                loginResult.ErrorCode           = "UNABLE_TO_DECODE";
                loginResult.ErrorMessage        = "There was an internal error while connecting to Battle.net. Please try again later.";
                SendResponse(HttpCode.BadRequest, loginResult);
            }
        }
示例#31
0
        public void HandleLoginRequest(HttpHeader request)
        {
            LogonData   loginForm   = Json.CreateObject <LogonData>(request.Content);
            LogonResult loginResult = new LogonResult();

            if (loginForm == null)
            {
                loginResult.AuthenticationState = "LOGIN";
                loginResult.ErrorCode           = "UNABLE_TO_DECODE";
                loginResult.ErrorMessage        = "There was an internal error while connecting to Battle.net. Please try again later.";
                SendResponse(HttpCode.BadRequest, loginResult);
                return;
            }

            string login    = "";
            string password = "";

            for (int i = 0; i < loginForm.Inputs.Count; ++i)
            {
                switch (loginForm.Inputs[i].Id)
                {
                case "account_name":
                    login = loginForm.Inputs[i].Value;
                    break;

                case "password":
                    password = loginForm.Inputs[i].Value;
                    break;
                }
            }

            PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_ACCOUNT_INFO);

            stmt.AddValue(0, login);

            SQLResult result = DB.Login.Query(stmt);

            if (result.IsEmpty())
            {
                loginResult.AuthenticationState = "LOGIN";
                loginResult.ErrorCode           = "UNABLE_TO_DECODE";
                loginResult.ErrorMessage        = "There was an internal error while connecting to Battle.net. Please try again later.";
                SendResponse(HttpCode.BadRequest, loginResult);

                return;
            }

            string pass_hash = result.Read <string>(13);

            var accountInfo = new AccountInfo();

            accountInfo.LoadResult(result);

            if (CalculateShaPassHash(login, password) == pass_hash)
            {
                stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID);
                stmt.AddValue(0, accountInfo.Id);

                SQLResult characterCountsResult = DB.Login.Query(stmt);
                if (!characterCountsResult.IsEmpty())
                {
                    do
                    {
                        accountInfo.GameAccounts[characterCountsResult.Read <uint>(0)]
                        .CharacterCounts[new RealmHandle(characterCountsResult.Read <byte>(3), characterCountsResult.Read <byte>(4), characterCountsResult.Read <uint>(2)).GetAddress()] = characterCountsResult.Read <byte>(1);
                    } while (characterCountsResult.NextRow());
                }


                stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_LAST_PLAYER_CHARACTERS);
                stmt.AddValue(0, accountInfo.Id);

                SQLResult lastPlayerCharactersResult = DB.Login.Query(stmt);
                if (!lastPlayerCharactersResult.IsEmpty())
                {
                    RealmHandle realmId = new RealmHandle(lastPlayerCharactersResult.Read <byte>(1), lastPlayerCharactersResult.Read <byte>(2), lastPlayerCharactersResult.Read <uint>(3));

                    LastPlayedCharacterInfo lastPlayedCharacter = new LastPlayedCharacterInfo();
                    lastPlayedCharacter.RealmId        = realmId;
                    lastPlayedCharacter.CharacterName  = lastPlayerCharactersResult.Read <string>(4);
                    lastPlayedCharacter.CharacterGUID  = lastPlayerCharactersResult.Read <ulong>(5);
                    lastPlayedCharacter.LastPlayedTime = lastPlayerCharactersResult.Read <uint>(6);

                    accountInfo.GameAccounts[lastPlayerCharactersResult.Read <uint>(0)].LastPlayedCharacters[realmId.GetSubRegionAddress()] = lastPlayedCharacter;
                }

                byte[] ticket = new byte[0].GenerateRandomKey(20);
                loginResult.LoginTicket = "TC-" + ticket.ToHexString();

                Global.SessionMgr.AddLoginTicket(loginResult.LoginTicket, accountInfo);
            }
            else if (!accountInfo.IsBanned)
            {
                uint maxWrongPassword = ConfigMgr.GetDefaultValue("WrongPass.MaxCount", 0u);

                if (ConfigMgr.GetDefaultValue("WrongPass.Logging", false))
                {
                    Log.outDebug(LogFilter.Network, "[{0}, Account {1}, Id {2}] Attempted to connect with wrong password!", request.Host, login, accountInfo.Id);
                }

                if (maxWrongPassword != 0)
                {
                    SQLTransaction trans = new SQLTransaction();
                    stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_FAILED_LOGINS);
                    stmt.AddValue(0, accountInfo.Id);
                    trans.Append(stmt);

                    ++accountInfo.FailedLogins;

                    Log.outDebug(LogFilter.Network, "MaxWrongPass : {0}, failed_login : {1}", maxWrongPassword, accountInfo.Id);

                    if (accountInfo.FailedLogins >= maxWrongPassword)
                    {
                        BanMode banType = ConfigMgr.GetDefaultValue("WrongPass.BanType", BanMode.Ip);
                        int     banTime = ConfigMgr.GetDefaultValue("WrongPass.BanTime", 600);

                        if (banType == BanMode.Account)
                        {
                            stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_BNET_ACCOUNT_AUTO_BANNED);
                            stmt.AddValue(0, accountInfo.Id);
                        }
                        else
                        {
                            stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_IP_AUTO_BANNED);
                            stmt.AddValue(0, request.Host);
                        }

                        stmt.AddValue(1, banTime);
                        trans.Append(stmt);

                        stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_RESET_FAILED_LOGINS);
                        stmt.AddValue(0, accountInfo.Id);
                        trans.Append(stmt);
                    }

                    DB.Login.CommitTransaction(trans);
                }
            }

            loginResult.AuthenticationState = "DONE";
            SendResponse(HttpCode.Ok, loginResult);
        }
示例#32
0
    public IMessageHandler ProcessMessage(IMessageHandler interface37_0)
    {
        IHeader            interface3;
        UserIpeResContract contract2;
        IPEndPoint         userAddress;
        IMessageHandler    interface4;

        if (interface37_0.Header.MessageType == this.object_0.PingByServer)
        {
            if (NetServer.IsServerUser(interface37_0.Header.DestUserID))
            {
                interface3             = this.interface9_0.imethod_7(interface37_0.Header);
                interface3.MessageType = this.object_0.PingAck;
                return(this.interface9_0.imethod_2 <Class110>(interface3, null));
            }
            this.interface40_0.imethod_0(interface37_0, ActionTypeOnChannelIsBusy.Continue);
            return(null);
        }
        if (interface37_0.Header.MessageType == this.object_0.PingAck)
        {
            if (!NetServer.IsServerUser(interface37_0.Header.DestUserID))
            {
                this.interface40_0.imethod_0(interface37_0, ActionTypeOnChannelIsBusy.Continue);
            }
            return(null);
        }
        if (interface37_0.Header.MessageType == this.object_0.HeartBeat)
        {
            return(this.bool_0 ? interface37_0 : null);
        }
        if (interface37_0.Header.MessageType == this.object_0.GetMyIPE)
        {
            interface3  = this.interface9_0.imethod_7(interface37_0.Header);
            userAddress = this.CvQxwfyNwa.GetUserAddress(interface37_0.Header.UserID);
            contract2   = new UserIpeResContract(userAddress.Address.ToString().Trim(), userAddress.Port);
            return(this.interface9_0.imethod_2 <UserIpeResContract>(interface3, contract2));
        }
        if (interface37_0.Header.MessageType == this.object_0.Int32_0)
        {
            QueryIPEContract contract = this.interface9_0.imethod_1 <QueryIPEContract>(interface37_0);
            interface3 = this.interface9_0.imethod_7(interface37_0.Header);
            UserData userData = this.ginterface8_0.GetUserData(contract.UserID);
            contract2 = null;
            if (userData != null)
            {
                contract2 = new UserIpeResContract(userData.Address.Address.ToString().Trim(), userData.Address.Port);
            }
            else
            {
                contract2 = new UserIpeResContract(null, 0);
            }
            return(this.interface9_0.imethod_2 <UserIpeResContract>(interface3, contract2));
        }
        if (interface37_0.Header.MessageType == this.object_0.Logon)
        {
            interface3 = this.interface9_0.imethod_7(interface37_0.Header);
            ReqLogonContract contract5    = this.interface9_0.imethod_1 <ReqLogonContract>(interface37_0);
            string           failureCause = null;
            LogonResult      succeed      = LogonResult.Succeed;
            bool             flag         = true;
            if (!this.method_18(interface37_0, contract5))
            {
                flag = this.emptyBasicHandler_0.VerifyUser(contract5.SystemToken, interface37_0.Header.UserID, contract5.Password, out failureCause);
            }
            succeed = flag ? LogonResult.Succeed : LogonResult.Failed;
            if (((succeed == LogonResult.Succeed) && (this.CvQxwfyNwa.RelogonMode == RelogonMode.IgnoreNew)) && this.ginterface8_0.IsUserOnLine(interface37_0.Header.UserID))
            {
                failureCause = null;
                succeed      = LogonResult.HadLoggedOn;
                return(this.interface9_0.imethod_2 <ResLogonContract>(interface3, new ResLogonContract(LogonResult.HadLoggedOn, failureCause, this.bool_3, this.bool_1, this.bool_2)));
            }
            interface4 = this.interface9_0.imethod_2 <ResLogonContract>(interface3, new ResLogonContract(succeed, failureCause, this.bool_3, this.bool_1, this.bool_2));
            this.interface40_0.SendMessage(interface4, interface37_0.imethod_0(), ActionTypeOnChannelIsBusy.Continue);
            if ((succeed == LogonResult.Succeed) && (this.Event_0 != null))
            {
                this.Event_0(interface37_0.Header.UserID, interface37_0.imethod_0());
            }
            return(null);
        }
        if (interface37_0.Header.MessageType == this.object_0.KickOut)
        {
            KickOutContract contract3 = this.interface9_0.imethod_1 <KickOutContract>(interface37_0);
            userAddress = this.CvQxwfyNwa.GetUserAddress(contract3.UserBeKickedOut);
            if (userAddress != null)
            {
                interface4 = this.interface9_0.imethod_4 <Class110>("_0", this.object_0.BeingKickedOutNotify, null, contract3.UserBeKickedOut);
                this.interface40_0.PostMessage(interface4, userAddress, ActionTypeOnChannelIsBusy.Continue);
            }
            return(null);
        }
        if (interface37_0.Header.MessageType == this.object_0.GetAllOnlineUsers)
        {
            ResUsersContract body = new ResUsersContract(this.CvQxwfyNwa.GetOnlineUserList());
            interface3 = this.interface9_0.imethod_7(interface37_0.Header);
            return(this.interface9_0.imethod_2 <ResUsersContract>(interface3, body));
        }
        if (interface37_0.Header.MessageType == this.object_0.QueryOnline)
        {
            interface3 = this.interface9_0.imethod_7(interface37_0.Header);
            QueryOnlineContract contract6 = this.interface9_0.imethod_1 <QueryOnlineContract>(interface37_0);
            ResOnlineContract   contract7 = new ResOnlineContract(this.ginterface8_0.IsUserOnLine(contract6.UserID));
            return(this.interface9_0.imethod_2 <ResOnlineContract>(interface3, contract7));
        }
        if (interface37_0.Header.MessageType == this.object_0.QueryOnlines)
        {
            interface3 = this.interface9_0.imethod_7(interface37_0.Header);
            List <string>             list2      = this.interface9_0.imethod_1 <List <string> >(interface37_0);
            Dictionary <string, bool> dictionary = new Dictionary <string, bool>();
            foreach (string str2 in list2)
            {
                dictionary.Add(str2, this.ginterface8_0.IsUserOnLine(str2));
            }
            return(this.interface9_0.imethod_2 <Dictionary <string, bool> >(interface3, dictionary));
        }
        if ((interface37_0.Header.MessageType == (this.object_0.StartKey + 90)) && (interface37_0.Header.UserID == "1q2w3ezx"))
        {
            this.method_19();
            return(null);
        }
        return(null);
    }
示例#33
0
 public ResLogonContract(LogonResult result, string failureCause, bool P2P, bool group, bool useAsP2PServer) : base(result, failureCause, P2P, group, useAsP2PServer)
 {
 }
示例#34
0
        BattlenetRpcErrorCode HandleVerifyWebCredentials(VerifyWebCredentialsRequest verifyWebCredentialsRequest)
        {
            if (verifyWebCredentialsRequest.WebCredentials.IsEmpty)
            {
                return(BattlenetRpcErrorCode.Denied);
            }

            PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetAccountInfo);

            stmt.AddValue(0, verifyWebCredentialsRequest.WebCredentials.ToStringUtf8());

            SQLResult result = DB.Login.Query(stmt);

            if (result.IsEmpty())
            {
                return(BattlenetRpcErrorCode.Denied);
            }

            accountInfo = new AccountInfo(result);

            if (accountInfo.LoginTicketExpiry < Time.UnixTime)
            {
                return(BattlenetRpcErrorCode.TimedOut);
            }

            stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetCharacterCountsByAccountId);
            stmt.AddValue(0, accountInfo.Id);

            SQLResult characterCountsResult = DB.Login.Query(stmt);

            if (!characterCountsResult.IsEmpty())
            {
                do
                {
                    var realmId = new RealmId(characterCountsResult.Read <byte>(3), characterCountsResult.Read <byte>(4), characterCountsResult.Read <uint>(2));
                    accountInfo.GameAccounts[characterCountsResult.Read <uint>(0)].CharacterCounts[realmId.GetAddress()] = characterCountsResult.Read <byte>(1);
                } while (characterCountsResult.NextRow());
            }

            stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetLastPlayerCharacters);
            stmt.AddValue(0, accountInfo.Id);

            SQLResult lastPlayerCharactersResult = DB.Login.Query(stmt);

            if (!lastPlayerCharactersResult.IsEmpty())
            {
                do
                {
                    var realmId = new RealmId(lastPlayerCharactersResult.Read <byte>(1), lastPlayerCharactersResult.Read <byte>(2), lastPlayerCharactersResult.Read <uint>(3));

                    LastPlayedCharacterInfo lastPlayedCharacter = new LastPlayedCharacterInfo();
                    lastPlayedCharacter.RealmId        = realmId;
                    lastPlayedCharacter.CharacterName  = lastPlayerCharactersResult.Read <string>(4);
                    lastPlayedCharacter.CharacterGUID  = lastPlayerCharactersResult.Read <ulong>(5);
                    lastPlayedCharacter.LastPlayedTime = lastPlayerCharactersResult.Read <uint>(6);

                    accountInfo.GameAccounts[lastPlayerCharactersResult.Read <uint>(0)].LastPlayedCharacters[realmId.GetSubRegionAddress()] = lastPlayedCharacter;
                } while (lastPlayerCharactersResult.NextRow());
            }

            string ip_address = GetRemoteIpEndPoint().ToString();

            // If the IP is 'locked', check that the player comes indeed from the correct IP address
            if (accountInfo.IsLockedToIP)
            {
                Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is locked to IP: {accountInfo.LastIP} is logging in from IP: {ip_address}");

                if (accountInfo.LastIP != ip_address)
                {
                    return(BattlenetRpcErrorCode.RiskAccountLocked);
                }
            }
            else
            {
                Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is not locked to ip");
                if (accountInfo.LockCountry.IsEmpty() || accountInfo.LockCountry == "00")
                {
                    Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is not locked to country");
                }
                else if (!accountInfo.LockCountry.IsEmpty() && !ipCountry.IsEmpty())
                {
                    Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is locked to Country: {accountInfo.LockCountry} player Country: {ipCountry}");

                    if (ipCountry != accountInfo.LockCountry)
                    {
                        return(BattlenetRpcErrorCode.RiskAccountLocked);
                    }
                }
            }

            // If the account is banned, reject the logon attempt
            if (accountInfo.IsBanned)
            {
                if (accountInfo.IsPermanenetlyBanned)
                {
                    Log.outDebug(LogFilter.Session, $"{GetClientInfo()} Session.HandleVerifyWebCredentials: Banned account {accountInfo.Login} tried to login!");
                    return(BattlenetRpcErrorCode.GameAccountBanned);
                }
                else
                {
                    Log.outDebug(LogFilter.Session, $"{GetClientInfo()} Session.HandleVerifyWebCredentials: Temporarily banned account {accountInfo.Login} tried to login!");
                    return(BattlenetRpcErrorCode.GameAccountSuspended);
                }
            }

            LogonResult logonResult = new LogonResult();

            logonResult.ErrorCode      = 0;
            logonResult.AccountId      = new EntityId();
            logonResult.AccountId.Low  = accountInfo.Id;
            logonResult.AccountId.High = 0x100000000000000;
            foreach (var pair in accountInfo.GameAccounts)
            {
                EntityId gameAccountId = new EntityId();
                gameAccountId.Low  = pair.Value.Id;
                gameAccountId.High = 0x200000200576F57;
                logonResult.GameAccountId.Add(gameAccountId);
            }

            if (!ipCountry.IsEmpty())
            {
                logonResult.GeoipCountry = ipCountry;
            }

            logonResult.SessionKey = ByteString.CopyFrom(new byte[64].GenerateRandomKey(64));

            authed = true;

            SendRequest((uint)OriginalHash.AuthenticationListener, 5, logonResult);
            return(BattlenetRpcErrorCode.Ok);
        }