/// <summary>
        /// <see cref="AuthenticationService.InitialSharedSecret(string)">InitialSharedSecret</see>
        /// </summary>
        protected override string InitialSharedSecret(string applicationKey)
        {
            ApplicationRegister applicationRegister =
                applicationRegisterService.RetrieveByApplicationKey(applicationKey);

            return(applicationRegister?.SharedSecret);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static ApplicationRegister CreateApplicationRegister(string locale)
        {
            environmentType environmentTypeRequest;
            environmentType environmentTypeResponse;

            using (FileStream xmlStream = File.OpenRead("Data files\\" + locale.ToUpper() + "\\EnvironmentRequest.xml"))
            {
                environmentTypeRequest = SerialiserFactory.GetXmlSerialiser <environmentType>().Deserialise(xmlStream);
            }

            using (FileStream xmlStream = File.OpenRead("Data files\\" + locale.ToUpper() + "\\EnvironmentResponse.xml"))
            {
                environmentTypeResponse = SerialiserFactory.GetXmlSerialiser <environmentType>().Deserialise(xmlStream);
            }

            Environment         environmentRequest  = MapperFactory.CreateInstance <environmentType, Environment>(environmentTypeRequest);
            Environment         environmentResponse = MapperFactory.CreateInstance <environmentType, Environment>(environmentTypeResponse);
            EnvironmentRegister environmentRegister = CreateEnvironmentRegister(environmentRequest, environmentResponse);
            ApplicationRegister applicationRegister = new ApplicationRegister
            {
                ApplicationKey       = environmentRequest.ApplicationInfo.ApplicationKey,
                SharedSecret         = "SecretDem0",
                EnvironmentRegisters = new Collection <EnvironmentRegister> {
                    { environmentRegister }
                }
            };

            return(applicationRegister);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static ApplicationRegister CreateApplicationRegister(string locale)
        {
            environmentType environmentTypeRequest;
            environmentType environmentTypeResponse;

            using (FileStream xmlStream = File.OpenRead("Data files\\" + locale.ToUpper() + "\\EnvironmentRequest.xml"))
            {
                environmentTypeRequest = SerialiserFactory.GetXmlSerialiser<environmentType>().Deserialise(xmlStream);
            }

            using (FileStream xmlStream = File.OpenRead("Data files\\" + locale.ToUpper() + "\\EnvironmentResponse.xml"))
            {
                environmentTypeResponse = SerialiserFactory.GetXmlSerialiser<environmentType>().Deserialise(xmlStream);
            }

            Environment environmentRequest = MapperFactory.CreateInstance<environmentType, Environment>(environmentTypeRequest);
            Environment environmentResponse = MapperFactory.CreateInstance<environmentType, Environment>(environmentTypeResponse);
            EnvironmentRegister environmentRegister = CreateEnvironmentRegister(environmentRequest, environmentResponse);
            ApplicationRegister applicationRegister = new ApplicationRegister
            {
                ApplicationKey = environmentRequest.ApplicationInfo.ApplicationKey,
                SharedSecret = "SecretDem0",
                EnvironmentRegisters = new Collection<EnvironmentRegister> { { environmentRegister } }
            };

            return applicationRegister;
        }
예제 #4
0
        private static void RegisterApps(ApplicationRegister appsRegister)
        {
            AppInfoConfigurationSection serviceConfigSection =
                ConfigurationManager.GetSection("AppsSection") as AppInfoConfigurationSection;


            foreach (AppInfo appInfo in serviceConfigSection.Apps)
            {
                appsRegister.Add(appInfo);
            }
        }
예제 #5
0
        public void Start()
        {
            var appsRegister = new ApplicationRegister();

            RegisterApps(appsRegister);

            InitQuartz().GetAwaiter().GetResult();
            Scheduler.Context.Put(nameof(ApplicationRegister), appsRegister);

            SetupQuartz().GetAwaiter().GetResult();
        }
예제 #6
0
        public void Can_Get_Seeding_Automobile_And_Discount(string dataFileName)
        {
            // Arrange
            Assert.True(File.Exists(dataFileName));

            // Act
            var entities = ApplicationRegister.GetSeedingEntities(dataFileName);

            // Assert
            Assert.NotNull(entities);
            Assert.Equal(2, entities.Count());
        }
예제 #7
0
        /// <summary>
        /// <see cref="AuthenticationService.SharedSecret(string)">SharedSecret</see>
        /// </summary>
        protected override string SharedSecret(string sessionToken)
        {
            environmentType environment = environmentService.RetrieveBySessionToken(sessionToken);

            if (environment == null)
            {
                throw new InvalidSessionException();
            }

            ApplicationRegister applicationRegister = applicationRegisterService.RetrieveByApplicationKey(environment.applicationInfo.applicationKey);

            return(applicationRegister == null ? null : applicationRegister.SharedSecret);
        }
예제 #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            PersistenceRegister.RegisterDbContext(services, Configuration);
            RegisterIdentity(services);
            PersistenceRegister.RegisterRepository(services);
            PersistenceRegister.RegisterQueries(services);
            ApplicationRegister.RegisterServices(services);
            InfrastuctureRegister.RegisterInfrastucture(services, Configuration);
            InfrastuctureRegister.RegisterServices(services);
            services.AddControllers();

            // ConfigureJwt(services, Configuration);
        }
        private static ApplicationRegister CreateApplicationRegister(string path)
        {
            environmentType environmentTypeRequest;
            environmentType environmentTypeResponse;

            string request  = @path + "\\EnvironmentRequest.xml";
            string response = @path + "\\EnvironmentResponse.xml";

            if (!File.Exists(request) || !File.Exists(response))
            {
                return(null);
            }

            Console.WriteLine("");
            Console.WriteLine("Processsing input from: " + path);
            Console.WriteLine("Request:  " + request);
            Console.WriteLine("Response: " + response);
            Console.WriteLine("");

            using (FileStream xmlStream = File.OpenRead(request))
            {
                environmentTypeRequest = SerialiserFactory.GetXmlSerialiser <environmentType>().Deserialise(xmlStream);
            }

            using (FileStream xmlStream = File.OpenRead(response))
            {
                environmentTypeResponse = SerialiserFactory.GetXmlSerialiser <environmentType>().Deserialise(xmlStream);
            }

            Environment         environmentRequest  = MapperFactory.CreateInstance <environmentType, Environment>(environmentTypeRequest);
            Environment         environmentResponse = MapperFactory.CreateInstance <environmentType, Environment>(environmentTypeResponse);
            EnvironmentRegister environmentRegister = CreateEnvironmentRegister(environmentRequest, environmentResponse);
            ApplicationRegister applicationRegister = new ApplicationRegister
            {
                ApplicationKey       = environmentRequest.ApplicationInfo.ApplicationKey,
                SharedSecret         = "SecretDem0",
                EnvironmentRegisters = new Collection <EnvironmentRegister> {
                    { environmentRegister }
                }
            };

            return(applicationRegister);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static ICollection <ApplicationRegister> CreateApplicationRegisters(string locale)
        {
            IList <ApplicationRegister> registers = new List <ApplicationRegister>();

            string rootPath = "Data files\\" + locale.ToUpper();

            // Paths to look for
            List <string> paths = new List <string>(Directory.GetDirectories(rootPath));

            paths.Insert(0, rootPath);

            foreach (string path in paths)
            {
                ApplicationRegister register = CreateApplicationRegister(path);
                if (register != null)
                {
                    registers.Add(register);
                }
            }

            return(registers);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            try
            {
                string prop = null;

                if (args.Length == 1)
                {
                    prop = args[0];
                }
                else
                {
                    prop = ConfigurationManager.AppSettings["demo.locale"];
                }

                string locale = (prop != null && ("AU".Equals(prop.ToUpper()) || "US".Equals(prop.ToUpper())) ? prop.ToUpper() : null);

                if (locale == null)
                {
                    Console.WriteLine("To execute, setup requires a parameter which specifies locale, i.e. AU or US.");
                }
                else
                {
                    Console.WriteLine("Configuring the demonstration for the " + locale + " locale.");
                    DatabaseManager frameworkDatabaseManager = new DatabaseManager("SifFramework.cfg.xml");
                    frameworkDatabaseManager.CreateDatabaseTables("SifFramework schema.ddl");
                    ApplicationRegister           applicationRegister           = DataFactory.CreateApplicationRegister(locale);
                    ApplicationRegisterRepository applicationRegisterRepository = new ApplicationRegisterRepository();
                    applicationRegisterRepository.Save(applicationRegister);
                }
            }
            finally
            {
                Console.WriteLine("Press any key to continue ...");
                Console.ReadKey();
            }
        }
예제 #12
0
 public static void RegisterAllServices(IServiceCollection services)
 {
     ApplicationRegister.Register(services);
     InfraRegister.Register(services);
 }
        /// <summary>
        /// <see cref="Sif.Framework.Service.Authentication.AuthenticationService.InitialSharedSecret(System.String)">InitialSharedSecret</see>
        /// </summary>
        protected override string InitialSharedSecret(string applicationKey)
        {
            ApplicationRegister applicationRegister = (new ApplicationRegisterService()).RetrieveByApplicationKey(applicationKey);

            return(applicationRegister == null ? null : applicationRegister.SharedSecret);
        }