Ejemplo n.º 1
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            RegisterEventBus(container);

            container.RegisterType <ILog, LogDecorator>();
            container.RegisterType <ITokenProvider, TokenProvider>();

            //use of explicit factory method to prevent Func from doing property injection
            //and stuffing your public properties with nulls (surprise!)
            container.RegisterType <IRepository>(ReuseWithinRequest, new InjectionFactory(c => new Repository()));

            container.RegisterType <IWalletOperations, WalletOperations>();
            container.RegisterType <ISynchronizationService, SynchronizationService>();
            container.RegisterType <IUgsServiceBus, FakeUgsServiceBus>();

            container.RegisterType <ISettingsRepository, SettingsRepository>();
            container.RegisterType <ISettingsQueries, SettingsQueries>();
            container.RegisterType <IUgsServiceBusSettingsProvider, UgsServiceBusSettingsProvider>();
            container.RegisterType <ICommonSettingsProvider, CommonSettingsProvider>();

            container.RegisterType <IRepositoryBase, RepositoryBase>();
            container.RegisterType <ISynchronizationService, SynchronizationService>();
            container.RegisterType <IJsonSerializationProvider, JsonSerializationProvider>();
            container.RegisterType <IWebConfigProvider, WebConfigProvider>();
            container.RegisterType <ITokenProvider, TokenProvider>();
            container.RegisterType <IErrorManager, ErrorManager>();
            container.RegisterType <ITokenValidationProvider, TokenValidationProvider>();
            container.RegisterType <IGameProviderLog, GameProviderLog>();
            container.RegisterType <ITransactionScopeProvider, TransactionScopeProvider>();
            container.RegisterType <IGameCommands, GameCommands>();
            container.RegisterType <IGameQueries, GameQueries>();
            container.RegisterType <ICommonGameActionsProvider, CommonGameActionsProvider>();
            container.RegisterType <IGameManagement, GameManagement>();
            container.RegisterType <IGameWalletOperations, GameWalletOperations>();
            container.RegisterType <IGameWalletQueries, GameWalletQueries>();
            container.RegisterType <IPlayerCommands, PlayerCommands>();
            container.RegisterType <IGameEventsProcessor, GameEventsProcessor>();
            container.RegisterType <IFlycowApiClientSettingsProvider, FlycowApiClientSettingsProvider>();
            container.RegisterType <IModeSwitch, ModeSwitch>();
            container.RegisterType <IFlycowApiClientProvider, FlycowApiClientProvider>();

            container.RegisterType <ICryptoKeyPair>("authServer", NewEachTime, new InjectionFactory(c =>
            {
                var config = c.Resolve <IWebConfigProvider>();
                return(CryptoKeyPair.LoadCertificate(
                           HostingEnvironment.MapPath(config.GetAppSettingByKey("CertificateLocation")),
                           config.GetAppSettingByKey("CertificatePassword")));
            }));

            container.RegisterType <ICryptoKeyPair>("dataServer", NewEachTime, new InjectionFactory(c =>
            {
                var config = c.Resolve <IWebConfigProvider>();
                return(CryptoKeyPair.LoadCertificate(
                           HostingEnvironment.MapPath(config.GetAppSettingByKey("CertificateLocation")),
                           config.GetAppSettingByKey("CertificatePassword")));
            }));
        }
Ejemplo n.º 2
0
        public OAuth2Controller()
        {
            // In this example, we're just newing up an auth server. A real implementation would use an IOC container
            // to resolve the dependencies and inject the auth server into our controller.
            var authServerKeys    = CryptoKeyPair.LoadCertificate(HostingEnvironment.MapPath("~/bin/Certificates/auth-server.pfx"), "p@ssw0rd");
            var dataServerKeys    = CryptoKeyPair.LoadCertificate(HostingEnvironment.MapPath("~/bin/Certificates/data-server.pfx"), "p@ssw0rd");
            var exampleAuthServer = new ExampleAuthorizationServer(new FakeCryptoKeyStore(),
                                                                   authServerKeys, dataServerKeys, new FakeOAuth2ClientStore(), new FakeUserStore());

            this.authServer = new AuthorizationServer(exampleAuthServer);
        }
        public MockSunbetTokenController(IRepository repository)
        {
            var authCertificateLocation = HostingEnvironment.MapPath(WebConfigurationManager.AppSettings["CertificateLocation"]);

            var authCryptoKeyPair = CryptoKeyPair.LoadCertificate(authCertificateLocation, WebConfigurationManager.AppSettings["CertificatePassword"]);

            var gameProviderStore = new GameProviderOAuthStore(repository);

            var regoAuthServer = new GameApiOAuthServer(new CryptoKeyStore(),
                                                        authCryptoKeyPair,
                                                        authCryptoKeyPair,
                                                        gameProviderStore,
                                                        _gameProviderId);

            _authServer = new AuthorizationServer(regoAuthServer);
        }
Ejemplo n.º 4
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
            .Add <Users>("/users")
            .Add <Users>("/users/{Username}");

            //Register all your dependencies
            ;


            container.Register("authServer", c =>
                               CryptoKeyPair.LoadCertificate(HostingEnvironment.MapPath("~/bin/Certificates/auth-server.pfx"), "p@ssw0rd"));
            container.Register("dataServer", c =>
                               CryptoKeyPair.LoadCertificate(HostingEnvironment.MapPath("~/bin/Certificates/data-server.pfx"), "p@ssw0rd"));
            container.RegisterAutoWiredAs <FakeUserStore, IUserStore>();
        }
Ejemplo n.º 5
0
        private void SetupGameApiDependencies(IUnityContainer container)
        {
            container.RegisterInstance(container);
            container.RegisterType <IJsonSerializationProvider, JsonSerializationProvider>(ReuseWithinContainer);
            container.RegisterType <IWebConfigProvider, WebConfigProvider>(ReuseWithinContainer);
            container.RegisterType <ITokenProvider, TokenProvider>(ReuseWithinContainer);
            container.RegisterType <IErrorManager, ErrorManager>(ReuseWithinContainer);
            container.RegisterType <ITokenValidationProvider, TokenValidationProvider>(ReuseWithinContainer);
            container.RegisterType <IGameProviderLog, GameProviderLog>(ReuseWithinContainer);
            container.RegisterType <ITransactionScopeProvider, TransactionScopeProvider>(ReuseWithinContainer);
            container.RegisterType <IGameRepository, GameRepository>(NewEachTime);
            container.RegisterType <IGameCommands, GameCommands>(NewEachTime);
            container.RegisterType <IGameQueries, GameQueries>(NewEachTime);
            container.RegisterType <ICommonGameActionsProvider, CommonGameActionsProvider>(NewEachTime);

            //use of explicit factory method to prevent Func from doing property injection
            //and stuffing your public properties with nulls (surprise!)
            container.RegisterType <IGameRepository>(ReuseWithinRequest,
                                                     new InjectionFactory(c => new GameRepository()));

            container.RegisterType <ICryptoKeyPair>("authServer", NewEachTime, new InjectionFactory(c =>
            {
                var config = c.Resolve <IWebConfigProvider>();
                return(CryptoKeyPair.LoadCertificate(
                           HostingEnvironment.MapPath(config.GetAppSettingByKey("CertificateLocation")),
                           config.GetAppSettingByKey("CertificatePassword")));
            }));

            container.RegisterType <ICryptoKeyPair>("dataServer", NewEachTime, new InjectionFactory(c =>
            {
                var config = c.Resolve <IWebConfigProvider>();
                return(CryptoKeyPair.LoadCertificate(
                           HostingEnvironment.MapPath(config.GetAppSettingByKey("CertificateLocation")),
                           config.GetAppSettingByKey("CertificatePassword")));
            }));
        }