/// <summary> /// Verifies that the input username and password are correct /// </summary> public static void LauncherSignIn(string username, string password, LauncherSignInCompleteDelegate finished) { bool updatePersistedCredentials = String.IsNullOrEmpty(username) == false && String.IsNullOrEmpty(password) == false; if (updatePersistedCredentials == true) { AuthenticatedData.SetLogin(username, password); } TaskHandler.RunTask(delegate() { LauncherSignInResult result = new LauncherSignInResult(); try { LoginResult blackBoxData = Service.GetBlackBoxForUser(new LoginData() { Alias = AuthenticatedData.PersistedUser, LobbyId = null, LobbyIdSpecified = false, Password = AuthenticatedData.PersistedPass, SessionId = 0, SessionIdSpecified = false, Username = AuthenticatedData.PersistedUser }); if (blackBoxData.Status == LoginStatus.Authenticated) { Log.Write("ServiceHandler::LauncherSignIn() - Data received for: " + AuthenticatedData.PersistedUser + ", data length: " + blackBoxData.BlackboxData.Length); string message = null; string ticket = null; var checkInStatus = SessionNegotiator.ValidateLogin(blackBoxData.BlackboxData, ref message, ref ticket); if (checkInStatus != CheckInStatus.Ok && checkInStatus != CheckInStatus.AccountLinked) { result.Status = checkInStatus; result.StatusSpecified = true; result.LinkedAccount = String.Empty; } else { // Attempt to verify the login credentials result = Service.LauncherSignIn(new LauncherSignInData()); } } else { switch (blackBoxData.Status) { case LoginStatus.AccountLocked: result.Status = CheckInStatus.AccountLocked; break; case LoginStatus.InvalidCredentials: result.Status = CheckInStatus.InvalidCredentials; break; case LoginStatus.PermissionDenied: result.Status = CheckInStatus.PermissionDenied; break; default: throw new NotSupportedException(blackBoxData.Status.ToString()); } result.StatusSpecified = true; result.LinkedAccount = String.Empty; } } catch (Exception error) { result = new LauncherSignInResult() { Status = CheckInStatus.Timeout, StatusSpecified = false }; Log.Write(error); } if (result.StatusSpecified == true && result.Status == CheckInStatus.Ok) { DataStore.Callsigns = null; if (updatePersistedCredentials == true) { AuthenticatedData.PersistLogin(username, AuthenticatedData.PersistedPass); } } finished(result); }); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new MainForm()); // for the prototype, we're accepting untrusted server certificates ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate); AuthenticatedData.SetLogin("Orion", Hash("Test")); using (var auth = new ClientService()) { //Retrieve AutoUpdate data AutoUpdateClient.Check(auth); //Login, and then perform initial check-in Console.WriteLine("Logging in. {0}", DateTime.Now); Assembly blackbox = null; var loginResult = auth.Login(new LoginData() { Alias = "Orion" }); Console.WriteLine("Login Status: {0} - {1}", loginResult.Status, DateTime.Now); if (loginResult.Status != LoginStatus.Authenticated) { return; } //Retrieve all messages for this login ReceiveMessages(); ReceivePolls(); blackbox = Assembly.Load(loginResult.BlackboxData); var validatorType = blackbox.GetType("Allegiance.CommunitySecuritySystem.Blackbox.Validator"); var machineInfoType = blackbox.GetType("Allegiance.CommunitySecuritySystem.Blackbox.MachineInformation"); var machineInfo = Activator.CreateInstance(machineInfoType); GatherMachineInfo(machineInfoType, machineInfo); var method = validatorType.GetMethod("Check", BindingFlags.Static | BindingFlags.Public); var results = method.Invoke(null, new object[] { machineInfo }) as byte[]; var checkInResult = auth.CheckIn(new CheckInData() { SessionIdSpecified = false, EncryptedData = results, }); Console.WriteLine("Initial Check-In Status: {0} - {1}", checkInResult.Status, DateTime.Now); } }