コード例 #1
0
    /// <inheritdoc/>
    public async ValueTask AddAsync(TApplication application, CancellationToken cancellationToken)
    {
        if (application is null)
        {
            throw new ArgumentNullException(nameof(application));
        }

        _cache.Remove(new
        {
            Method     = nameof(FindByClientIdAsync),
            Identifier = await _store.GetClientIdAsync(application, cancellationToken)
        });

        _cache.Remove(new
        {
            Method     = nameof(FindByIdAsync),
            Identifier = await _store.GetIdAsync(application, cancellationToken)
        });

        foreach (var address in await _store.GetPostLogoutRedirectUrisAsync(application, cancellationToken))
        {
            _cache.Remove(new
            {
                Method  = nameof(FindByPostLogoutRedirectUriAsync),
                Address = address
            });
        }

        foreach (var address in await _store.GetRedirectUrisAsync(application, cancellationToken))
        {
            _cache.Remove(new
            {
                Method  = nameof(FindByRedirectUriAsync),
                Address = address
            });
        }

        await CreateEntryAsync(new
        {
            Method     = nameof(FindByIdAsync),
            Identifier = await _store.GetIdAsync(application, cancellationToken)
        }, application, cancellationToken);

        await CreateEntryAsync(new
        {
            Method     = nameof(FindByClientIdAsync),
            Identifier = await _store.GetClientIdAsync(application, cancellationToken)
        }, application, cancellationToken);
    }
コード例 #2
0
    public async Task GetIdAsync()
    {
        var application = await _applicationStore.FindByIdAsync(AbpOpenIddictTestData.App1Id.ToString(), CancellationToken.None);

        var id = await _applicationStore.GetIdAsync(application, CancellationToken.None);

        id.ShouldBe(AbpOpenIddictTestData.App1Id.ToString());
    }
コード例 #3
0
        /// <summary>
        /// Add the specified application to the cache.
        /// </summary>
        /// <param name="application">The application to add to the cache.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
        /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
        public async ValueTask AddAsync([NotNull] TApplication application, CancellationToken cancellationToken)
        {
            if (application == null)
            {
                throw new ArgumentNullException(nameof(application));
            }

            _cache.Remove(new
            {
                Method     = nameof(FindByClientIdAsync),
                Identifier = await _store.GetClientIdAsync(application, cancellationToken)
            });

            _cache.Remove(new
            {
                Method     = nameof(FindByIdAsync),
                Identifier = await _store.GetIdAsync(application, cancellationToken)
            });

            foreach (var address in await _store.GetPostLogoutRedirectUrisAsync(application, cancellationToken))
            {
                _cache.Remove(new
                {
                    Method  = nameof(FindByPostLogoutRedirectUriAsync),
                    Address = address
                });
            }

            foreach (var address in await _store.GetRedirectUrisAsync(application, cancellationToken))
            {
                _cache.Remove(new
                {
                    Method  = nameof(FindByRedirectUriAsync),
                    Address = address
                });
            }

            var signal = await CreateExpirationSignalAsync(application, cancellationToken);

            if (signal == null)
            {
                throw new InvalidOperationException("An error occurred while creating an expiration signal.");
            }

            using (var entry = _cache.CreateEntry(new
            {
                Method = nameof(FindByIdAsync),
                Identifier = await _store.GetIdAsync(application, cancellationToken)
            }))
            {
                entry.AddExpirationToken(signal)
                .SetSize(1L)
                .SetValue(application);
            }

            using (var entry = _cache.CreateEntry(new
            {
                Method = nameof(FindByClientIdAsync),
                Identifier = await _store.GetClientIdAsync(application, cancellationToken)
            }))
            {
                entry.AddExpirationToken(signal)
                .SetSize(1L)
                .SetValue(application);
            }
        }