public async Task Login_ValidUser_ReturnsToken()
        {
            //unit testing to ensure that a valid user and credentials
            //return a token
            var logonRequest = new LogonRequest
            {
                Email    = "*****@*****.**",
                Password = "******"
            };

            using (var server = TestServer.Create <TestStartupConfiguration>())
            {
                var response = await server.CreateRequest("/token").And(x =>
                                                                        x.Content = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("username",
                                                      logonRequest.Email),
                    new KeyValuePair <string, string>("password",
                                                      logonRequest.Password),
                    new KeyValuePair <string, string>("grant_type",
                                                      "password")
                })).PostAsync();


                Assert.IsTrue(response.IsSuccessStatusCode);

                var responseContent =
                    await response.Content.ReadAsStringAsync();


                Console.WriteLine(responseContent);

                Assert.IsFalse(string.IsNullOrWhiteSpace(responseContent));
            }
        }
Exemple #2
0
        public override void Logon(Google.ProtocolBuffers.IRpcController controller, LogonRequest request, Action <LogonResponse> done)
        {
            /*var client_auth = client.GetImportedService<bnet.protocol.authentication.AuthenticationClient>();
             * var mod_load_req = ModuleLoadRequest.CreateBuilder();
             * var mod_handle = ContentHandle.CreateBuilder();
             * mod_handle.SetRegion(0x00005553);
             * mod_handle.SetUsage(0x61757468);
             * var password_hash = new byte[] { 0x8f, 0x52, 0x90, 0x6a, 0x2c, 0x85, 0xb4, 0x16, 0xa5, 0x95, 0x70, 0x22, 0x51, 0x57, 0xf, 0x96, 0xd3, 0x52, 0x2f, 0x39, 0x23, 0x76, 0x3, 0x11, 0x5f, 0x2f, 0x1a, 0xb2, 0x49, 0x62, 0x4, 0x3c };
             * mod_handle.SetHash(ByteString.CopyFrom(password_hash));
             * mod_load_req.SetModuleHandle(mod_handle);
             *
             * client_auth.ModuleLoad(null, mod_load_req.Build(), res => {
             *      Console.WriteLine(res);
             * });*/


            var response     = LogonResponse.CreateBuilder();
            var account      = bnet.protocol.EntityId.CreateBuilder();
            var game_account = bnet.protocol.EntityId.CreateBuilder();

            account.SetHigh(0x100000000000000).SetLow(1234);

            game_account.SetHigh(0x200006200004433).SetLow(1234);

            response.SetAccount(account).SetGameAccount(game_account);

            done(response.Build());
        }
Exemple #3
0
        private LogonRequest CreateLogonRequest()
        {
            LogonRequest logonRequest = new LogonRequest();

            logonRequest.SetProgram("WoW");
            logonRequest.SetLocale(this.Client().GetLocaleName());
            logonRequest.SetPlatform(this.Client().GetPlatformName());
            logonRequest.SetVersion(this.Client().GetAuroraVersionName());
            logonRequest.SetApplicationVersion(1);
            logonRequest.SetPublicComputer(false);
            logonRequest.SetAllowLogonQueueNotifications(true);
            string userAgent = this.Client().GetUserAgent();

            if (!string.IsNullOrEmpty(userAgent))
            {
                logonRequest.SetUserAgent(userAgent);
            }
            logonRequest.SetWebClientVerification(true);
            bool flag = true;

            this.m_logSource.LogDebug("CreateLogonRequest SSL={0}", new object[]
            {
                flag
            });
            if (!string.IsNullOrEmpty(this.m_userEmailAddress))
            {
                this.m_logSource.LogDebug("Email = {0}", new object[]
                {
                    this.m_userEmailAddress
                });
            }
            return(logonRequest);
        }
        public override Task <LogonResponse> Logon(LogonRequest request, ServerCallContext context)
        {
            var contracts = new List <CustomerContract>()
            {
                new CustomerContract()
                {
                    Contract = "Contrac" + (++contactCounter), Created = Timestamp.FromDateTime(DateTime.UtcNow)
                },
                new CustomerContract()
                {
                    Contract = "Contract" + (++contactCounter), Created = Timestamp.FromDateTime(DateTime.UtcNow)
                },
            };
            var response = new LogonResponse()
            {
                Token        = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                CustomerInfo = new CustomerInfo()
                {
                    Detail         = "Detail Text",
                    LastUpdateDate = Timestamp.FromDateTime(DateTime.UtcNow)
                }
            };

            response.CustomerInfo.Contacts.AddRange(contracts.ToArray());
            return(Task.FromResult(response));
        }
Exemple #5
0
		public override void Logon(Google.ProtocolBuffers.IRpcController controller, LogonRequest request, Action<LogonResponse> done) {
			/*var client_auth = client.GetImportedService<bnet.protocol.authentication.AuthenticationClient>();
			var mod_load_req = ModuleLoadRequest.CreateBuilder();
			var mod_handle = ContentHandle.CreateBuilder();
			mod_handle.SetRegion(0x00005553);
			mod_handle.SetUsage(0x61757468);
			var password_hash = new byte[] { 0x8f, 0x52, 0x90, 0x6a, 0x2c, 0x85, 0xb4, 0x16, 0xa5, 0x95, 0x70, 0x22, 0x51, 0x57, 0xf, 0x96, 0xd3, 0x52, 0x2f, 0x39, 0x23, 0x76, 0x3, 0x11, 0x5f, 0x2f, 0x1a, 0xb2, 0x49, 0x62, 0x4, 0x3c };
			mod_handle.SetHash(ByteString.CopyFrom(password_hash));
			mod_load_req.SetModuleHandle(mod_handle);

			client_auth.ModuleLoad(null, mod_load_req.Build(), res => {
				Console.WriteLine(res);
			});*/


			var response = LogonResponse.CreateBuilder();
			var account = bnet.protocol.EntityId.CreateBuilder();
			var game_account = bnet.protocol.EntityId.CreateBuilder();

			account.SetHigh(0x100000000000000).SetLow(1234);

			game_account.SetHigh(0x200006200004433).SetLow(1234);

			response.SetAccount(account).SetGameAccount(game_account);

			done(response.Build());
		}
Exemple #6
0
        public Game GetNewGame(LogonRequest request)
        {
            var game = new Game(request.MapGeneration);

            Games.Add(game.Id, game);
            return(game);
        }
Exemple #7
0
        ////******** Navitaire API Integration ************************

        public static string Login()
        {
            ISessionManager sessionManager = new SessionManagerClient();
            LogonRequest    logonRequest   = new LogonRequest();
            string          username       = "******"; //ConfigurationManager.AppSettings["userid_fapi"].ToString();
            string          password       = "******"; //ConfigurationManager.AppSettings["password_fapi"].ToString();
            string          domain         = "WWW";

            logonRequest.logonRequestData            = new LogonRequestData();
            logonRequest.logonRequestData.DomainCode = domain;
            logonRequest.logonRequestData.AgentName  = username;
            logonRequest.logonRequestData.Password   = password;
            LogonResponse logonResponse = sessionManager.Logon(logonRequest);
            string        signature     = "";

            if (logonResponse != null && logonResponse.Signature != null && logonResponse.Signature != string.Empty)
            {
                signature = logonResponse.Signature;
            }
            else
            {
                //Response.Write("Agent Authentication Failed.");
                //ScriptManager.RegisterStartupScript(Page, GetType(), "ab", "alert('Agent Authentication Failed.');", true);
            }
            return(signature);
        }
        BattlenetRpcErrorCode HandleLogon(LogonRequest logonRequest, NoData response)
        {
            if (logonRequest.Program != "WoW")
            {
                Log.outDebug(LogFilter.Session, $"Battlenet.LogonRequest: {GetClientInfo()} attempted to log in with game other than WoW (using {logonRequest.Program})!");
                return(BattlenetRpcErrorCode.BadProgram);
            }

            if (logonRequest.Platform != "Win" && logonRequest.Platform != "Wn64" && logonRequest.Platform != "Mc64")
            {
                Log.outDebug(LogFilter.Session, $"Battlenet.LogonRequest: {GetClientInfo()} attempted to log in from an unsupported platform (using {logonRequest.Platform})!");
                return(BattlenetRpcErrorCode.BadPlatform);
            }

            if (!SharedConst.IsValidLocale(logonRequest.Locale.ToEnum <Locale>()))
            {
                Log.outDebug(LogFilter.Session, $"Battlenet.LogonRequest: {GetClientInfo()} attempted to log in with unsupported locale (using {logonRequest.Locale})!");
                return(BattlenetRpcErrorCode.BadLocale);
            }

            locale = logonRequest.Locale;
            os     = logonRequest.Platform;
            build  = (uint)logonRequest.ApplicationVersion;

            var endpoint = Global.LoginServiceMgr.GetAddressForClient(GetRemoteIpEndPoint().Address);

            ChallengeExternalRequest externalChallenge = new ChallengeExternalRequest();

            externalChallenge.PayloadType = "web_auth_url";
            externalChallenge.Payload     = ByteString.CopyFromUtf8($"https://{endpoint.Address}:{endpoint.Port}/bnetserver/login/");

            SendRequest((uint)OriginalHash.ChallengeListener, 3, externalChallenge);
            return(BattlenetRpcErrorCode.Ok);
        }
        public async Task Login_InvalidUser_ReturnsBadRequest()
        {
            //testing for response on invalid user details
            var logonRequest = new LogonRequest
            {
                Email    = "fds",
                Password = "******"
            };

            using (var server = TestServer.Create <TestStartupConfiguration>())
            {
                var response = await server.CreateRequest("/token").And(x =>
                                                                        x.Content = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("username",
                                                      logonRequest.Email),
                    new KeyValuePair <string, string>("password",
                                                      logonRequest.Password),
                    new KeyValuePair <string, string>("grant_type",
                                                      "password")
                })).PostAsync();


                Assert.IsFalse(response.IsSuccessStatusCode);
                Assert.IsTrue(response.StatusCode == HttpStatusCode.BadRequest);
            }
        }
Exemple #10
0
        public void AuroraStateHandler_Logon()
        {
            this.m_logSource.LogDebug("Sending Logon request");
            LogonRequest message = this.CreateLogonRequest();

            this.m_rpcConnection.QueueRequest(this.m_authenticationAPI.AuthServerService.Id, 1u, message, null, 0u);
            this.SwitchToState(BattleNetCSharp.ConnectionState.WaitForLogon);
        }
 public TestLoginRequest(string username, string password)
 {
     LogonRequest = new LogonRequest
     {
         UserName = username,
         Password = password
     };
 }
        public static void OnLogonRequest(Client pClient, Header pHeader, MemoryStream pData)
        {
            LogonRequest logonRequest = new LogonRequest();

            if (!logonRequest.Read(pData) || !logonRequest.HasEmail)
            {
                return;
            }
            Program.AddCallback(() => LogonRequestCallback(pClient, pHeader, logonRequest));
        }
 public void CreateEQXloginRequest(string pwd, ref LogonRequest oLogonRequest)
 {
     oLogonRequest.MemberID    = UtilityLoginDetails.GETInstance.MemberId = Convert.ToUInt16(MemberID);
     oLogonRequest.TraderID    = UtilityLoginDetails.GETInstance.TraderId = Convert.ToUInt16(TraderID);;//204;
     oLogonRequest.Password    = pwd;
     oLogonRequest.MessageTag  = MemoryManager.GetMesageTag();
     oLogonRequest.Market      = 1; //1 - Equity, 2- Derv., 3. Curr
     oLogonRequest.Exchange    = 1; //1- BSE, 2-BOW, 3-NSE
     oLogonRequest.NewPassword = "";
     oLogonRequest.Filler_c    = "";
 }
        public override void Logon(Google.ProtocolBuffers.IRpcController controller, LogonRequest request, System.Action<LogonResponse> done)
        {
            Logger.Trace("LogonRequest(); Email={0}", request.Email);
            Client.Account = AccountManager.GetAccount(request.Email);

            var builder = bnet.protocol.authentication.LogonResponse.CreateBuilder()
                .SetAccount(Client.Account.BnetAccountID)
                .SetGameAccount(Client.Account.BnetGameAccountID);

            done(builder.Build());
        }
        public LogonResponse Logon(LogonRequest request)
        {
            AuthenticationActions.LogonAction action = PolicyInjection.Create <AuthenticationActions.LogonAction>();

            AuthenticationEntities.LogonResult resultParams = action.Execute(Translators.LogonTranslator.TranslateFromServiceToBusiness(request.LogonParameters));
            LogonResponse response = new LogonResponse();

            response.LogonResult = Translators.LogonTranslator.TranslateFromBusinessToService(resultParams);

            return(response);
        }
        private static void LogonRequestCallback(Client pClient, Header pHeader, LogonRequest pLogonRequest)
        {
            Account account = AccountCache.RetrieveAccountByEmail(pLogonRequest.Email);

            if (account == null)
            {
                pClient.PermittedServices.Clear();
                pClient.ImportedServices.Clear();
                pClient.SendAuthenticationClientLogonComplete(new LogonResult(EErrorCode.LoginInformationWasIncorrect));
                return;
            }
        }
Exemple #17
0
        /// <summary>
        ///     Validates username and password provided match a user record in the system
        /// </summary>
        /// <param name="request">The request containing the username and password</param>
        /// <returns>A response indicating success or failure of the operation</returns>
        public LogonResponse Logon(LogonRequest request)
        {
            //find the user first by the email provided
            var user = UserRepository.FindByEmail(request.Email);

            //if found continue
            if (user != null)
            {
                if (user.Password.Equals(Encryption.EncryptString(request.Password)))
                {
                    if (user.Status == Constants.UserOTPStatus)
                    {
                        var response = new LogonResponse
                        {
                            Success        = false,
                            Message        = "Account activation required. Please activate your account.",
                            HasOpenBooking = false
                        };
                        return(response);
                    }
                    //if the password check passes, check if the user has an active status
                    else if (user.Status == Constants.UserActiveStatus || user.Status == Constants.UserPartialStatus)
                    {
                        var response = new LogonResponse
                        {
                            Id             = user.AccountID,
                            Success        = true,
                            Message        = "Logon was successful.",
                            HasOpenBooking = false
                        };

                        var openBooking = BookingRepository.FindByAccountId(user.AccountID)
                                          .FirstOrDefault(x => x.BookingStatus == Constants.BookingOpenStatus);

                        if (openBooking != null)
                        {
                            response.HasOpenBooking = true;
                            response.OpenBookingId  = openBooking.BookingID;
                        }

                        return(response);
                    }
                }
            }

            return(new LogonResponse
            {
                Success = false,
                Message = "Invalid email or password.",
                HasOpenBooking = false
            });
        }
        public static async void HandleLogonRequest(LogonRequest logonRequest, BnetSession session)
        {
            // TODO: Implement version checks, etc.
            //if (DB.Auth.Any<Application>(a => a.Program == logonRequest.Program))
            {
                var challengeExternalRequest = new ChallengeExternalRequest
                {
                    PayloadType = "web_auth_url",
                    Payload     = ByteString.CopyFromUtf8($"https://{BnetConfig.BnetChallengeHost}:{BnetConfig.BnetChallengeBindPort}/login/{session.Guid}")
                };

                await session.Send(challengeExternalRequest, BnetServiceHash.AuthenticationClientService, 3);
            }
        }
        public static async void HandleLogonRequest(LogonRequest logonRequest, BnetSession session)
        {
            // TODO: Implement version checks, etc.
            //if (DB.Auth.Any<Application>(a => a.Program == logonRequest.Program))
            {
                var challengeExternalRequest = new ChallengeExternalRequest
                {
                    PayloadType = "web_auth_url",
                    Payload = ByteString.CopyFromUtf8($"https://{BnetConfig.BnetChallengeHost}:{BnetConfig.BnetChallengeBindPort}/login/{session.Guid}")
                };

                await session.Send(challengeExternalRequest, BnetServiceHash.AuthenticationClientService, 3);
            }
        }
Exemple #20
0
        public BaseResult <LogonResult> Logon(LogonRequest logon)
        {
            var validator = new LogonRequestValidator();
            var results   = validator.Validate(logon);

            if (results.IsValid)
            {
                return(_gameManager.Execute(logon));
            }
            else
            {
                return(BaseResult <LogonResult> .Fail(errors : results.Errors.Select(e => e.ErrorMessage)));
            }
        }
Exemple #21
0
        public override void Logon(Google.ProtocolBuffers.IRpcController controller, LogonRequest request, System.Action <LogonResponse> done)
        {
            Logger.Trace("LogonRequest(); Email={0}", request.Email);
            Client.Account = AccountManager.GetAccountByEmail(request.Email);
            Client.Account.LoggedInBNetClient = (BNetClient)Client;

            var builder = bnet.protocol.authentication.LogonResponse.CreateBuilder()
                          .SetAccount(Client.Account.BnetAccountID)
                          .SetGameAccount(Client.Account.BnetGameAccountID);

            done(builder.Build());

            OnlinePlayers.Players.Add((BNetClient)Client);
        }
        public async Task <string> LogonAndGetTokenNavitaire(string userName = null, string password = null)
        {
            string       result  = default(string);
            LogonRequest request = GetRequestLogon(userName, password);

            string responseJson = await _integration.RequestAsync(HttpMethod.Post, _uri, request);

            LogonResponse responseObject = JsonConvert.DeserializeObject <LogonResponse>(responseJson);

            if (!string.IsNullOrEmpty(responseObject?.Data?.Token))
            {
                result = responseObject.Data.Token;
            }
            return(result);
        }
        public static void HandleConnectRequest(AuthSession session, LogonRequest logonRequest)
        {
            if (logonRequest.WebClientVerification)
            {
                while (true)
                {
IL_98:
                    uint arg_78_0 = 2859478583u;
                    while (true)
                    {
                        uint num;
                        switch ((num = (arg_78_0 ^ 2148169041u)) % 5u)
                        {
                        case 0u:
                            goto IL_98;

                        case 2u:
                        {
                            ChallengeExternalRequest challengeExternalRequest = new ChallengeExternalRequest();
                            challengeExternalRequest.PayloadType = Module.smethod_36 <string>(573305427u);
                            arg_78_0 = (num * 4022609958u ^ 1698604317u);
                            continue;
                        }

                        case 3u:
                        {
                            ChallengeExternalRequest challengeExternalRequest;
                            challengeExternalRequest.Payload = ByteString.CopyFromUtf8(Module.smethod_33 <string>(4154950356u));
                            arg_78_0 = (num * 836868245u ^ 2968312731u);
                            continue;
                        }

                        case 4u:
                        {
                            ChallengeExternalRequest challengeExternalRequest;
                            session.Send(challengeExternalRequest, 3151632159u, 3u);
                            arg_78_0 = (num * 950688502u ^ 1062584357u);
                            continue;
                        }
                        }
                        goto Block_2;
                    }
                }
                Block_2 :;
            }
        }
Exemple #24
0
        public ResultModel Post(LogonRequest vRequest)
        {
            ResultModel rs = new ResultModel();

            try
            {
                LiteonSecurity sy = new LiteonSecurity(Connection, API_DB, HR_DB);
                rs = sy.getToken(vRequest.UserName, vRequest.UserPassword, vRequest.AppID);
            }
            catch (Exception ex)
            {
                Log.Error("Got error. " + ex.Message);
                rs.Status = false;
                rs.Msg    = ex.Message;
            }
            return(rs);
        }
        public LogonResult Execute(LogonRequest request)
        {
            // check for waiting games and log players into that
            var game = GetWaitingGame();

            if (game != null)
            {
                game.Waiting = false;
                return(game.LogonPlayer(request.AgentName));
            }
            else
            {
                game         = GetNewGame();
                game.Waiting = true;
                game.Start();
                game.StartDemoAgent("Demo");
                return(game.LogonPlayer(request.AgentName));
            }
        }
Exemple #26
0
        public ActionResult Login(LogonRequest request)
        {
            if (ModelState.IsValid)
            {
                var found = db.GetByEmail(request.Email);

                if (found != null && found.Password == request.Password)
                {
                    FormsAuthentication.RedirectFromLoginPage(request.Email, false);

                    return(RedirectToAction("List", "Customer"));
                }
                else
                {
                    ModelState.AddModelError("", "The e-mail and/or password entered is invalid. Please try again.");
                    ModelState.AddModelError("Email", " ");
                    ModelState.AddModelError("Password", " ");
                }
            }

            return(View("Index"));
        }
Exemple #27
0
        public override void Logon(IRpcController controller, LogonRequest request, Action <LogonResponse> done)
        {
            srp = new SRP(request.Email, "123");

            var message = srp.LogonChallenge;

            var moduleLoadRequest = ModuleLoadRequest.CreateBuilder()
                                    .SetModuleHandle(ContentHandle.CreateBuilder()
                                                     .SetRegion(Region)
                                                     .SetUsage(Usage)
                                                     .SetHash(ByteString.CopyFrom(ModuleHash)))
                                    .SetMessage(ByteString.CopyFrom(message))
                                    .Build();

            client.ListenerId = request.ListenerId;

            AuthenticationClient.CreateStub(client).ModuleLoad(controller, moduleLoadRequest, ClientServiceCallback);

            new Thread(() =>
            {
                wait.WaitOne();
                if (client.ErrorCode == AuthError.None)
                {
                    done(new LogonResponse.Builder
                    {
                        Account = new EntityId.Builder {
                            High = HighId.Account, Low = 0
                        }.Build(),
                        GameAccount = new EntityId.Builder {
                            High = HighId.GameAccount, Low = 0
                        }.Build(),
                    }.Build());
                }
                else
                {
                    done(new LogonResponse());
                }
            }).Start();
        }
Exemple #28
0
 void OnConnectResponse(ConnectResponse response)
 {
     Bind(
         new List <string> {
         "bnet.protocol.authentication.AuthenticationClient"
     },
         new List <string> {
         "bnet.protocol.authentication.AuthenticationServer"
     }, delegate {
         var auth_server    = connection.GetImportedService <AuthenticationServer>();
         var request        = LogonRequest.CreateBuilder();
         request.Email      = "*****@*****.**";
         request.Locale     = "enUS";
         request.Platform   = "Win";
         request.Program    = "D3";
         request.Version    = "Aurora 130e70d23c_public/198 (Sep 20 2011 15:32:21)";
         request.ListenerId = 2;
         auth_server.Logon(null, request.Build(), logon_response => {
             Console.WriteLine(logon_response);
         });
     });
 }
Exemple #29
0
        public LogonResult Execute(LogonRequest request)
        {
            Game game;

            switch (request.GameId)
            {
            case -2:
                game = GetNewGame(request);
                game.Start();
                game.StartDemoAgent(game.Id, true);
                return(game.LogonPlayer(request.AgentName));

            case -1:
                game = GetNewGame(request);
                game.Start();
                game.StartDemoAgent(game.Id, false);
                return(game.LogonPlayer(request.AgentName));

            case 0:
                game = GetNewGame(request);
                game.Start();
                return(game.LogonPlayer(request.AgentName));

            default:
                game = GetWaitingGameById(request.GameId);
                if (game != null)
                {
                    return(game.LogonPlayer(request.AgentName));
                }
                else
                {
                    return(new LogonResult()
                    {
                        Id = request.GameId, Success = false, Message = "The game id specified is not available.", Errors = new string[] { }
                    });
                }
            }
        }
        public override void Logon(IRpcController controller, LogonRequest request, Action<LogonResponse> done)
        {
            srp = new SRP(request.Email, "123");

            var message = srp.Response1;

            var moduleLoadRequest = ModuleLoadRequest.CreateBuilder()
                .SetModuleHandle(ContentHandle.CreateBuilder()
                    .SetRegion(Region)
                    .SetUsage(Usage)
                    .SetHash(ByteString.CopyFrom(ModuleHash)))
                .SetMessage(ByteString.CopyFrom(message))
                .Build();

            client.ListenerId = request.ListenerId;

            AuthenticationClient.CreateStub(client).ModuleLoad(controller, moduleLoadRequest, ClientServiceCallback);

            new Thread(() =>
                           {
                               wait.WaitOne();
                               if (client.ErrorCode == AuthError.None)
                               {
                                   done(new LogonResponse.Builder
                                            {
                                                Account = new EntityId.Builder { High = HighId.Account, Low = 0 }.Build(),
                                                GameAccount = new EntityId.Builder { High = HighId.GameAccount, Low = 0 }.Build(),
                                            }.Build());
                               }
                               else
                               {
                                   done(new LogonResponse());
                               }
                           }).Start();

        }
Exemple #31
0
        public LogonResponse Logon(LogonRequest request)
        {
            AuthenticationServiceAdapter adapter = PolicyInjection.Create <AuthenticationServiceAdapter>();

            return(adapter.Logon(request));
        }
        public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
        {
            switch (methodId)
            {
            case 1:
            {
                LogonRequest request = new LogonRequest();
                request.MergeFrom(stream);

                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleLogon(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.Logon(bgs.protocol.authentication.v1.LogonRequest: {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 2:
            {
                ModuleNotification request = new ModuleNotification();
                request.MergeFrom(stream);


                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleModuleNotify(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.ModuleNotify(bgs.protocol.authentication.v1.ModuleNotification: {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 3:
            {
                ModuleMessageRequest request = new ModuleMessageRequest();
                request.MergeFrom(stream);


                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleModuleMessage(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.ModuleMessage(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:
            {
                EntityId request = new EntityId();
                request.MergeFrom(stream);


                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleSelectGameAccount_DEPRECATED(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.SelectGameAccount_DEPRECATED(bgs.protocol.EntityId: {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 5:
            {
                GenerateSSOTokenRequest request = new GenerateSSOTokenRequest();
                request.MergeFrom(stream);


                GenerateSSOTokenResponse response = new GenerateSSOTokenResponse();
                BattlenetRpcErrorCode    status   = HandleGenerateSSOToken(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.GenerateSSOToken(bgs.protocol.authentication.v1.GenerateSSOTokenRequest: {1}) returned bgs.protocol.authentication.v1.GenerateSSOTokenResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

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


                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleSelectGameAccount(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.SelectGameAccount(bgs.protocol.authentication.v1.SelectGameAccountRequest: {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 7:
            {
                VerifyWebCredentialsRequest request = new VerifyWebCredentialsRequest();
                request.MergeFrom(stream);


                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleVerifyWebCredentials(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.VerifyWebCredentials(bgs.protocol.authentication.v1.VerifyWebCredentialsRequest: {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 8:
            {
                GenerateWebCredentialsRequest request = new GenerateWebCredentialsRequest();
                request.MergeFrom(stream);


                GenerateWebCredentialsResponse response = new GenerateWebCredentialsResponse();
                BattlenetRpcErrorCode          status   = HandleGenerateWebCredentials(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.GenerateWebCredentials(bgs.protocol.authentication.v1.GenerateWebCredentialsRequest: {1}) returned bgs.protocol.authentication.v1.GenerateWebCredentialsResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            default:
                Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
                SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
                break;
            }
        }
 BattlenetRpcErrorCode HandleLogon(LogonRequest request, NoData response)
 {
     return(_session.HandleLogon(request));
 }
        public void SelectAndClose(UserWarehouse selectedWarehouse, UserCompany selectedCompany)
        {
            if ((selectedWarehouse != null) && (selectedCompany != null))
            {
                try
                {
                    UserSettingsChangedEventArgs args = new UserSettingsChangedEventArgs();

                    EventTopic userSettingsTopic = WorkItem.EventTopics.Get(Imi.SupplyChain.UX.UXEventTopicNames.UserSettingsChangedTopic);

                    if (userSettingsTopic != null)
                    {
                        userSettingsTopic.Fire(this, args, WorkItem, PublicationScope.Descendants);

                        if (args.OpenDialogs.Count > 0)
                        {
                            if (ShellInteractionService.ShowMessageBox(this.View.Title, string.Format(LocalResources.ChangeUserSettings_CloseAll, string.Join("\n", args.OpenDialogs)), null, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                            {
                                Close(false);
                                return;
                            }
                        }
                    }

                    ShellInteractionService.ShowProgress();

                    // Get the application
                    IShellModule module = WorkItem.Items.FindByType <IShellModule>().First();

                    LogonParameters logonParameters = new LogonParameters();
                    logonParameters.UserIdentity        = UserSessionService.UserId;
                    logonParameters.CompanyIdentity     = selectedCompany.CompanyIdentity;
                    logonParameters.WarehouseIdentity   = selectedCompany.WarehouseIdentity;
                    logonParameters.TerminalIdentity    = UserSessionService.TerminalId;
                    logonParameters.ApplicationIdentity = module.Id;

                    LogonRequest logonRequest = new LogonRequest();

                    logonRequest.LogonParameters = logonParameters;

                    LogonResponse response = Service.Logon(logonRequest);

                    // Set the selected Warehouse and ClientId on statusrow in container
                    ShellInteractionService.ContextInfo = string.Format(LocalResources.STATUSBAR_WH_CLIENT,
                                                                        selectedWarehouse.WarehouseIdentity,
                                                                        selectedWarehouse.WarehouseName,
                                                                        selectedCompany.CompanyIdentity,
                                                                        selectedCompany.CompanyName);
                    Close(true);
                }
                catch (Exception ex)
                {
                    ShellInteractionService.HideProgress();
                    ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, ex.ToString(), MessageBoxButton.Ok, MessageBoxImage.Error);
                }
                finally
                {
                    ShellInteractionService.HideProgress();
                }
            }
        }
Exemple #35
0
 public override void Logon(IRpcController controller, LogonRequest request, Action<LogonResponse> done)
 {
     ProtoOutputBuffer.Write(request.GetType(), request.ToString());
 }