/// <summary> /// Initializes a new instance of the <see cref="DefaultGrantStore{T}"/> class. /// </summary> /// <param name="grantType">Type of the grant.</param> /// <param name="store">The store.</param> /// <param name="serializer">The serializer.</param> /// <param name="handleGenerationService">The handle generation service.</param> /// <param name="logger">The logger.</param> /// <exception cref="System.ArgumentNullException">grantType</exception> protected DefaultGrantStore( string grantType, IPersistedGrantStore store, IPersistentGrantSerializer serializer, IHandleGenerationService handleGenerationService, IMemoryCache cache, ILogger logger) { if (grantType.IsMissing()) { throw new ArgumentNullException(nameof(grantType)); } _cache = cache; GrantType = grantType; Store = store; Serializer = serializer; HandleGenerationService = handleGenerationService; Logger = logger; _set = new EDCSAConfigSet { Set = new System.Collections.Generic.List <EDCSAConfig>() }; if (!_cache.TryGetValue("4be948db-3255-4fa1-a802-da66621d180c", out _set)) { throw new Exception("Could not get EDCSAConfigSet from cache"); } }
public void JWT_Ecdsa_Microsoft() { EDCSAConfigSet eDCSAConfigSet = new EDCSAConfigSet { Set = new List <EDCSAConfig> { } }; for (int i = 0; i < 2; i++) { var(privateKey, publicKey, _) = ECDsaMicrosoft.ECDSA.GenerateKeys("auth-code"); eDCSAConfigSet.Set.Add(new EDCSAConfig { PrivateKey = privateKey, PublicKey = publicKey, NotBefore = DateTime.UtcNow, Expiration = DateTime.UtcNow.AddDays(10) }); } var got = JsonConvert.DeserializeObject <EDCSAConfigSet>(ConfigS); var json = JsonConvert.SerializeObject(eDCSAConfigSet); got = JsonConvert.DeserializeObject <EDCSAConfigSet>(json); got.Set[0].PrivateKey.Should().BeEquivalentTo(eDCSAConfigSet.Set[0].PrivateKey); got.Set[0].PublicKey.Should().BeEquivalentTo(eDCSAConfigSet.Set[0].PublicKey); got.Set[0].NotBefore.Should().BeSameDateAs(eDCSAConfigSet.Set[0].NotBefore); got.Set[0].Expiration.Should().BeSameDateAs(eDCSAConfigSet.Set[0].Expiration); }