Ejemplo n.º 1
0
        public static void Generate(X509Certificate2 cert)
        {
            Console.WriteLine($"----------JWT BELOW-----------");

            var userData = new UserCacheData()
            {
                AccessKey   = Guid.NewGuid().ToString(),
                FirmId      = DateTime.Now.Millisecond,
                UserId      = DateTime.Now.Millisecond + 19,
                FavoritePet = DateTime.Now.Millisecond % 2 == 0 ? "Cat" : "Hamster",
            };

            userData.UserAttributes["Attribute1"] = "CatName";
            userData.UserAttributes["Attribute2"] = "DocName";
            userData.UserAttributes["Attribute3"] = "IceCreamFlavor";

            var jwt = JwtHelper.GetJwt(cert, userData.AccessKey, userData.UserId, userData.FirmId);

            var config = RedisConfiguration.CreateFromString(ConfigurationManager.AppSettings["RedisConnString"]);

            using (var cli = new RedisClient(config, new NewtonsoftSerializer()))
            {
                cli.AddObject(userData.AccessKey, userData);
            }


            Console.WriteLine(jwt);
            Console.WriteLine($"----------END JWT-----------");
        }