/* * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) * See https://github.com/openiddict/openiddict-core for more information concerning * the license and the contributors participating to this project. */ using System; using System.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; using Newtonsoft.Json.Linq; namespace OpenIddict.Abstractions { /// /// Provides methods allowing to manage the applications stored in a database. /// /// The type of the Application entity. public interface IOpenIddictApplicationStore where TApplication : class { /// /// Determines the number of applications that exist in the database. /// /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of applications in the database. /// Task CountAsync(CancellationToken cancellationToken); /// /// Determines the number of applications that match the specified query. /// /// The result type. /// The query to execute. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the number of applications that match the specified query. /// Task CountAsync([NotNull] Func, IQueryable> query, CancellationToken cancellationToken); /// /// Creates a new application. /// /// The application to create. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Removes an existing application. /// /// The application to delete. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task DeleteAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves an application using its unique identifier. /// /// The unique identifier associated with the application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the client application corresponding to the identifier. /// Task FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); /// /// Retrieves an application using its client identifier. /// /// The client identifier associated with the application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the client application corresponding to the identifier. /// Task FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken); /// /// Retrieves all the applications associated with the specified post_logout_redirect_uri. /// /// The post_logout_redirect_uri associated with the applications. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, whose result /// returns the client applications corresponding to the specified post_logout_redirect_uri. /// Task> FindByPostLogoutRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken); /// /// Retrieves all the applications associated with the specified redirect_uri. /// /// The redirect_uri associated with the applications. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, whose result /// returns the client applications corresponding to the specified redirect_uri. /// Task> FindByRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken); /// /// Executes the specified query and returns the first element. /// /// The state type. /// The result type. /// The query to execute. /// The optional state. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the first element returned when executing the query. /// Task GetAsync( [NotNull] Func, TState, IQueryable> query, [CanBeNull] TState state, CancellationToken cancellationToken); /// /// Retrieves the client identifier associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the client identifier associated with the application. /// ValueTask GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the client secret associated with an application. /// Note: depending on the manager used to create the application, /// the client secret may be hashed for security reasons. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the client secret associated with the application. /// ValueTask GetClientSecretAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the client type associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the client type of the application (by default, "public"). /// ValueTask GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the consent type associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the consent type of the application (by default, "explicit"). /// ValueTask GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the display name associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the display name associated with the application. /// ValueTask GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the unique identifier associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the unique identifier associated with the application. /// ValueTask GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the permissions associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns all the permissions associated with the application. /// ValueTask> GetPermissionsAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the logout callback addresses associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns all the post_logout_redirect_uri associated with the application. /// ValueTask> GetPostLogoutRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the additional properties associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns all the additional properties associated with the application. /// ValueTask GetPropertiesAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Retrieves the callback addresses associated with an application. /// /// The application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns all the redirect_uri associated with the application. /// ValueTask> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken); /// /// Instantiates a new application. /// /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns the instantiated application, that can be persisted in the database. /// ValueTask InstantiateAsync(CancellationToken cancellationToken); /// /// Executes the specified query and returns all the corresponding elements. /// /// The number of results to return. /// The number of results to skip. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns all the elements returned when executing the specified query. /// Task> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); /// /// Executes the specified query and returns all the corresponding elements. /// /// The state type. /// The result type. /// The query to execute. /// The optional state. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation, /// whose result returns all the elements returned when executing the specified query. /// Task> ListAsync( [NotNull] Func, TState, IQueryable> query, [CanBeNull] TState state, CancellationToken cancellationToken); /// /// Sets the client identifier associated with an application. /// /// The application. /// The client identifier associated with the application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetClientIdAsync([NotNull] TApplication application, [CanBeNull] string identifier, CancellationToken cancellationToken); /// /// Sets the client secret associated with an application. /// Note: depending on the manager used to create the application, /// the client secret may be hashed for security reasons. /// /// The application. /// The client secret associated with the application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetClientSecretAsync([NotNull] TApplication application, [CanBeNull] string secret, CancellationToken cancellationToken); /// /// Sets the client type associated with an application. /// /// The application. /// The client type associated with the application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetClientTypeAsync([NotNull] TApplication application, [CanBeNull] string type, CancellationToken cancellationToken); /// /// Sets the consent type associated with an application. /// /// The application. /// The consent type associated with the application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetConsentTypeAsync([NotNull] TApplication application, [CanBeNull] string type, CancellationToken cancellationToken); /// /// Sets the display name associated with an application. /// /// The application. /// The display name associated with the application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetDisplayNameAsync([NotNull] TApplication application, [CanBeNull] string name, CancellationToken cancellationToken); /// /// Sets the permissions associated with an application. /// /// The application. /// The permissions associated with the application /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetPermissionsAsync([NotNull] TApplication application, ImmutableArray permissions, CancellationToken cancellationToken); /// /// Sets the logout callback addresses associated with an application. /// /// The application. /// The logout callback addresses associated with the application /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetPostLogoutRedirectUrisAsync([NotNull] TApplication application, ImmutableArray addresses, CancellationToken cancellationToken); /// /// Sets the additional properties associated with an application. /// /// The application. /// The additional properties associated with the application. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetPropertiesAsync([NotNull] TApplication application, [CanBeNull] JObject properties, CancellationToken cancellationToken); /// /// Sets the callback addresses associated with an application. /// /// The application. /// The callback addresses associated with the application /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task SetRedirectUrisAsync([NotNull] TApplication application, ImmutableArray addresses, CancellationToken cancellationToken); /// /// Updates an existing application. /// /// The application to update. /// The that can be used to abort the operation. /// /// A that can be used to monitor the asynchronous operation. /// Task UpdateAsync([NotNull] TApplication application, CancellationToken cancellationToken); } }