diff --git a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
index 156680b6..af2d91f1 100644
--- a/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
+++ b/src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
@@ -244,8 +244,13 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier.
///
- public virtual Task FindByIdAsync(string identifier, CancellationToken cancellationToken)
+ public virtual Task FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
{
+ if (string.IsNullOrEmpty(identifier))
+ {
+ throw new ArgumentException("The identifier cannot be null or empty.", nameof(identifier));
+ }
+
return Store.FindByIdAsync(identifier, cancellationToken);
}
@@ -258,8 +263,13 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier.
///
- public virtual Task FindByClientIdAsync(string identifier, CancellationToken cancellationToken)
+ public virtual Task FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
{
+ if (string.IsNullOrEmpty(identifier))
+ {
+ throw new ArgumentException("The identifier cannot be null or empty.", nameof(identifier));
+ }
+
return Store.FindByClientIdAsync(identifier, cancellationToken);
}
@@ -408,25 +418,6 @@ namespace OpenIddict.Core
return Store.GetIdAsync(application, cancellationToken);
}
- ///
- /// Retrieves the token identifiers 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 tokens associated with the application.
- ///
- public virtual Task> GetTokensAsync([NotNull] TApplication application, CancellationToken cancellationToken)
- {
- if (application == null)
- {
- throw new ArgumentNullException(nameof(application));
- }
-
- return Store.GetTokensAsync(application, cancellationToken);
- }
-
///
/// Determines whether an application is a confidential client.
///
diff --git a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
index 5b606cbe..d32ea3fe 100644
--- a/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
+++ b/src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
@@ -182,8 +182,18 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the subject/client.
///
- public virtual Task FindAsync(string subject, string client, CancellationToken cancellationToken)
+ public virtual Task FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken)
{
+ if (string.IsNullOrEmpty(subject))
+ {
+ throw new ArgumentException("The subject cannot be null or empty.", nameof(subject));
+ }
+
+ if (string.IsNullOrEmpty(client))
+ {
+ throw new ArgumentException("The client identifier cannot be null or empty.", nameof(client));
+ }
+
return Store.FindAsync(subject, client, cancellationToken);
}
@@ -196,8 +206,13 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the identifier.
///
- public virtual Task FindByIdAsync(string identifier, CancellationToken cancellationToken)
+ public virtual Task FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
{
+ if (string.IsNullOrEmpty(identifier))
+ {
+ throw new ArgumentException("The identifier cannot be null or empty.", nameof(identifier));
+ }
+
return Store.FindByIdAsync(identifier, cancellationToken);
}
diff --git a/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs b/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
index 5ccaa461..520080d0 100644
--- a/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
+++ b/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
@@ -179,6 +179,25 @@ namespace OpenIddict.Core
await UpdateAsync(token, cancellationToken);
}
+ ///
+ /// Retrieves the list of tokens corresponding to the specified application identifier.
+ ///
+ /// The application identifier associated with the tokens.
+ /// The that can be used to abort the operation.
+ ///
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns the tokens corresponding to the specified application.
+ ///
+ public virtual Task> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
+ {
+ if (string.IsNullOrEmpty(identifier))
+ {
+ throw new ArgumentException("The identifier cannot be null or empty.", nameof(identifier));
+ }
+
+ return Store.FindByApplicationIdAsync(identifier, cancellationToken);
+ }
+
///
/// Retrieves the list of tokens corresponding to the specified authorization identifier.
///
@@ -188,8 +207,13 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified authorization.
///
- public virtual Task> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken)
+ public virtual Task> FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
{
+ if (string.IsNullOrEmpty(identifier))
+ {
+ throw new ArgumentException("The identifier cannot be null or empty.", nameof(identifier));
+ }
+
return Store.FindByAuthorizationIdAsync(identifier, cancellationToken);
}
@@ -202,8 +226,13 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified hash.
///
- public virtual Task FindByHashAsync(string hash, CancellationToken cancellationToken)
+ public virtual Task FindByHashAsync([NotNull] string hash, CancellationToken cancellationToken)
{
+ if (string.IsNullOrEmpty(hash))
+ {
+ throw new ArgumentException("The hash cannot be null or empty.", nameof(hash));
+ }
+
return Store.FindByHashAsync(hash, cancellationToken);
}
@@ -216,8 +245,13 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation,
/// whose result returns the token corresponding to the unique identifier.
///
- public virtual Task FindByIdAsync(string identifier, CancellationToken cancellationToken)
+ public virtual Task FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
{
+ if (string.IsNullOrEmpty(identifier))
+ {
+ throw new ArgumentException("The identifier cannot be null or empty.", nameof(identifier));
+ }
+
return Store.FindByIdAsync(identifier, cancellationToken);
}
@@ -230,8 +264,13 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified subject.
///
- public virtual Task> FindBySubjectAsync(string subject, CancellationToken cancellationToken)
+ public virtual Task> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken)
{
+ if (string.IsNullOrEmpty(subject))
+ {
+ throw new ArgumentException("The subject cannot be null or empty.", nameof(subject));
+ }
+
return Store.FindBySubjectAsync(subject, cancellationToken);
}
diff --git a/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs
index e4380153..43157bc3 100644
--- a/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs
+++ b/src/OpenIddict.Core/Stores/IOpenIddictApplicationStore.cs
@@ -207,17 +207,6 @@ namespace OpenIddict.Core
///
Task> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken);
- ///
- /// Retrieves the token identifiers 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 tokens associated with the application.
- ///
- Task> GetTokensAsync([NotNull] TApplication application, CancellationToken cancellationToken);
-
///
/// Executes the specified query.
///
diff --git a/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs b/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs
index d35402f9..56f4430b 100644
--- a/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs
+++ b/src/OpenIddict.Core/Stores/IOpenIddictTokenStore.cs
@@ -69,6 +69,17 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation.
Task DeleteAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ///
+ /// Retrieves the list of tokens corresponding to the specified application identifier.
+ ///
+ /// The application identifier associated with the tokens.
+ /// The that can be used to abort the operation.
+ ///
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns the tokens corresponding to the specified application.
+ ///
+ Task> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken);
+
///
/// Retrieves the list of tokens corresponding to the specified authorization identifier.
///
diff --git a/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs b/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs
index 2b9564ff..0a3e298c 100644
--- a/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs
+++ b/src/OpenIddict.Core/Stores/OpenIddictApplicationStore.cs
@@ -411,46 +411,6 @@ namespace OpenIddict.Core
return Task.FromResult(ImmutableArray.Create(uris));
}
- ///
- /// Retrieves the token identifiers 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 tokens associated with the application.
- ///
- public virtual async Task> GetTokensAsync([NotNull] TApplication application, CancellationToken cancellationToken)
- {
- if (application == null)
- {
- throw new ArgumentNullException(nameof(application));
- }
-
- IQueryable Query(IQueryable applications)
- {
- return from entity in applications
- where entity.Id.Equals(application.Id)
- from token in entity.Tokens
- select token.Id;
- }
-
- var identifiers = await ListAsync(Query, cancellationToken);
- if (identifiers.IsDefaultOrEmpty)
- {
- return ImmutableArray.Create();
- }
-
- var builder = ImmutableArray.CreateBuilder(identifiers.Length);
-
- foreach (var identifier in identifiers)
- {
- builder.Add(ConvertIdentifierToString(identifier));
- }
-
- return builder.ToImmutable();
- }
-
///
/// Executes the specified query.
///
diff --git a/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs b/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs
index 71dd8fe6..7b8d0754 100644
--- a/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs
+++ b/src/OpenIddict.Core/Stores/OpenIddictTokenStore.cs
@@ -82,6 +82,27 @@ namespace OpenIddict.Core
/// A that can be used to monitor the asynchronous operation.
public abstract Task DeleteAsync([NotNull] TToken token, CancellationToken cancellationToken);
+ ///
+ /// Retrieves the list of tokens corresponding to the specified application identifier.
+ ///
+ /// The application identifier associated with the tokens.
+ /// The that can be used to abort the operation.
+ ///
+ /// A that can be used to monitor the asynchronous operation,
+ /// whose result returns the tokens corresponding to the specified application.
+ ///
+ public virtual Task> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
+ {
+ if (string.IsNullOrEmpty(identifier))
+ {
+ throw new ArgumentException("The identifier cannot be null or empty.", nameof(identifier));
+ }
+
+ var key = ConvertIdentifierFromString(identifier);
+
+ return ListAsync(tokens => tokens.Where(token => token.Application.Id.Equals(key)), cancellationToken);
+ }
+
///
/// Retrieves the list of tokens corresponding to the specified authorization identifier.
///