private static void CacheJwks( IInMemoryPublicKeyCache cache, JsonWebKeySet jwks ) { foreach( var jwk in jwks ) { D2LSecurityToken token; try { token = jwk.ToSecurityToken(); } catch { continue; } cache.Set( token ); } }
private static void CacheJwks(IInMemoryPublicKeyCache cache, string srcNamespace, JsonWebKeySet jwks) { foreach (var jwk in jwks) { D2LSecurityToken token; try { token = jwk.ToSecurityToken(); } catch { continue; } cache.Set(srcNamespace, token); } }
async Task <D2LSecurityToken> IPublicKeyProvider.GetByIdAsync(Guid id) { D2LSecurityToken result = m_cache.Get(PUBLIC_KEY_SOURCE, id); if (result != null) { return(result); } JsonWebKey jwk = await m_publicKeyDataProvider .GetByIdAsync(id) .SafeAsync(); if (jwk != null) { result = jwk.ToSecurityToken(); m_cache.Set(PUBLIC_KEY_SOURCE, result); return(result); } throw new PublicKeyNotFoundException(id, PUBLIC_KEY_SOURCE); }