コード例 #1
0
        async Task <D2LSecurityToken> IPublicKeyProvider.GetByIdAsync(string id)
        {
            D2LSecurityToken result = m_cache.Get(m_jwksProvider.Namespace, id);

            if (result != null)
            {
                return(result);
            }

            JsonWebKeySet jwks = await m_jwksProvider
                                 .RequestJwkAsync(id)
                                 .ConfigureAwait(false);

            CacheJwks(m_cache, m_jwksProvider.Namespace, jwks);

            result = m_cache.Get(m_jwksProvider.Namespace, id);
            if (result != null)
            {
                return(result);
            }

            throw new PublicKeyNotFoundException(id, jwks.Source.AbsoluteUri);
        }
コード例 #2
0
        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);
        }