Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();

            var launcherInWindowsRegistrator = new LauncherInWindowsRegistrator();
            var launcherIdGenerator          = new LauncherIdGenerator();

            var computerNameProvider = new ComputerNameProvider();
            var launcherIdProvider   = new LauncherIdProvider(launcherInWindowsRegistrator, launcherIdGenerator);
            var hardwareIdProvider   = new HardwareIdProvider(launcherIdProvider);

            var forgameAuthProvider = new ForgameAuthProvider(computerNameProvider, launcherIdProvider, hardwareIdProvider);

            var aesStorage    = new AesStorage(computerNameProvider);
            var cryptoManager = new CryptoManager(aesStorage);

            var launcherConfigDataProvider = new LauncherConfigDataProvider(cryptoManager);
            var launcherConfigParser       = new LauncherConfigJsonParser();
            var launcherConfigProvider     = new LauncherConfigProvider(launcherConfigDataProvider, launcherConfigParser);

            launcherConfigProvider.Init();

            Router _router = new Router(this);

            _router.AddRoute(
                "/",
                () => new LauncherPage(
                    computerNameProvider,
                    launcherIdProvider,
                    hardwareIdProvider,
                    launcherConfigProvider,
                    forgameAuthProvider),
                new RouteData {
                Title = "bns-ru"
            });

            _router.AddRoute(
                "/auth",
                () => new LoginPage(launcherConfigProvider, forgameAuthProvider),
                new RouteData {
                Title = "bns-ru: Login"
            });

            _router.AddRoute(
                "/auth/activate/{sessionId}",
                () => new ActivationCodePage(launcherConfigProvider, forgameAuthProvider),
                new RouteData {
                Title = "bns-ru: Activate"
            });

            _router.AddRoute(
                "/settings",
                () => new SettingsPage(launcherConfigProvider),
                new RouteData {
                Title = "bns-ru: Settings"
            });
        }
        static void DumpToken()
        {
            try
            {
                Stopwatch watch = new Stopwatch();
                watch.Start();

                WindowsTokenBuilder wb = new WindowsTokenBuilder();

                var nameProvider      = new MachineNameIdProvider();
                var baseBoardProvider = new HardwareIdProvider(new BaseBoardEntity());
                var processorProvider = new HardwareIdProvider(new ProcessorEntity());

                Console.WriteLine("Entities");
                Console.WriteLine(new string('-', 20));

                Console.WriteLine($"{nameProvider}: {nameProvider.FetchHardwareId()}");
                Console.WriteLine($"{baseBoardProvider}: {baseBoardProvider.FetchHardwareId()}");
                Console.WriteLine($"{processorProvider}: {processorProvider.FetchHardwareId()}");

                var scoped_token = wb.Build(new List <IHardwareIdProvider>()
                {
                    nameProvider, baseBoardProvider, processorProvider
                });

                Console.WriteLine(new string('-', 20));
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"Generated token: {scoped_token}");
                Console.ResetColor();
                Console.WriteLine();

                watch.Stop();
                Console.WriteLine($"Token time cost: {watch.Elapsed}");
            }
            catch (ManagementException mex)
            {
                Console.WriteLine(mex);
            }

            Console.CursorTop = 0;
        }