Esempio n. 1
0
        public void TestLoadCompanyInfo()
        {
            Console.WriteLine("====================== TESTING COMPANY INFO LOADING ====================== ");
            CompanyInfoUtil.LoadCompanyInfos("./CompanyInfo.json");
            Assert.IsTrue(CompanyInfoUtil.CompanyClaims.ValidIssuers.Length > 0);

            foreach (var str in CompanyInfoUtil.CompanyClaims.ValidIssuers)
            {
                Console.WriteLine($"Issuer {str}");
            }

            Console.WriteLine();
            Assert.IsTrue(CompanyInfoUtil.CompanyClaims.ValidAudiences.Length > 0);

            foreach (var str in CompanyInfoUtil.CompanyClaims.ValidIssuers)
            {
                Console.WriteLine($"Adueince {str}");
            }

            Console.WriteLine();

            Assert.IsTrue(CompanyInfoUtil.CompanyClaims.Claims.Count > 0);
            foreach (var claimKey in CompanyInfoUtil.CompanyClaims.Claims.Keys)
            {
                Console.WriteLine($"Claim {claimKey} : {CompanyInfoUtil.CompanyClaims.Claims[claimKey]}");
            }

            var CompanyClaims = CompanyInfoUtil.CompanyClaims.Claims;

            ClaimsIdentity Identity = new ClaimsIdentity(
                CompanyClaims.Keys.ToList().Select(key => new Claim(typeof(ClaimTypes).GetField(key).GetValue(null).ToString(), CompanyClaims[key]))
                , "Custom");

            Assert.IsTrue(Identity.Claims.Any());
            foreach (var claim in Identity.Claims)
            {
                Console.WriteLine($"Claim {claim}");
            }


            Console.WriteLine("====================== END TESTING COMPANY INFO LOADING ====================== ");
        }
Esempio n. 2
0
        static TokensController()
        {
            // Problem using Interpolated Strings
            // Version used C# 7.0, detected C# 5.0
            // Loading the information file
            CompanyInfoUtil.LoadCompanyInfos(String.Format(@"{0}\Infos\CompanyInfo.json", Startup.ApplicationBasePath));

            // Common claims
            Claims = new ClaimsIdentity(
                CompanyInfoUtil.CompanyClaims.Claims.Keys.ToList()
                .Select(key => new Claim(key, CompanyInfoUtil.CompanyClaims.Claims[key])).ToList <Claim>()
                , "Custom");


            IdGenerationModel = new IdGenerator(1);

            // Warmup to avoid false positives
            for (int i = 0; i < 2; ++i)
            {
                IdGenerationModel.GenerateId(_ID_GEN_SIZE);
            }
        }