Browse Source

Use static usings for the OpenIddict exceptions

pull/1480/head
Kévin Chalet 4 years ago
parent
commit
026a4b4fbd
  1. 39
      src/OpenIddict.Client/OpenIddictClientService.cs
  2. 9
      src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
  3. 5
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  4. 5
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  5. 5
      src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
  6. 5
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs
  7. 5
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs
  8. 5
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs
  9. 5
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs
  10. 5
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs
  11. 5
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs
  12. 5
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs
  13. 5
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs
  14. 5
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs
  15. 5
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs
  16. 5
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs
  17. 5
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs
  18. 27
      src/OpenIddict.Validation/OpenIddictValidationService.cs

39
src/OpenIddict.Client/OpenIddictClientService.cs

@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using OpenIddict.Extensions; using OpenIddict.Extensions;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.Client; namespace OpenIddict.Client;
@ -86,7 +87,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0148(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0148(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -108,7 +109,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0149(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0149(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -132,7 +133,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0150(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0150(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -159,7 +160,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0151(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0151(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -245,7 +246,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0152(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0152(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -267,7 +268,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0153(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0153(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -291,7 +292,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0154(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0154(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -318,7 +319,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0155(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0155(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -391,7 +392,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0319(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0319(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -483,7 +484,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0319(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0319(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -568,7 +569,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0319(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0319(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -668,7 +669,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0320(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0320(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -691,7 +692,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0321(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0321(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -716,7 +717,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0322(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0322(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -744,7 +745,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0323(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0323(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -839,7 +840,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0324(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0324(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -862,7 +863,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0325(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0325(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -887,7 +888,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0326(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0326(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -916,7 +917,7 @@ public class OpenIddictClientService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0327(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0327(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }

9
src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs

@ -16,6 +16,7 @@ using System.Text.Json;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.Extensions; using OpenIddict.Extensions;
using ValidationException = OpenIddict.Abstractions.OpenIddictExceptions.ValidationException;
#if !SUPPORTS_KEY_DERIVATION_WITH_SPECIFIED_HASH_ALGORITHM #if !SUPPORTS_KEY_DERIVATION_WITH_SPECIFIED_HASH_ALGORITHM
using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto;
@ -166,7 +167,7 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
builder.AppendLine(result.ErrorMessage); builder.AppendLine(result.ErrorMessage);
} }
throw new OpenIddictExceptions.ValidationException(builder.ToString(), results); throw new ValidationException(builder.ToString(), results);
} }
await Store.CreateAsync(application, cancellationToken); await Store.CreateAsync(application, cancellationToken);
@ -1035,7 +1036,7 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
builder.AppendLine(result.ErrorMessage); builder.AppendLine(result.ErrorMessage);
} }
throw new OpenIddictExceptions.ValidationException(builder.ToString(), results); throw new ValidationException(builder.ToString(), results);
} }
await Store.UpdateAsync(application, cancellationToken); await Store.UpdateAsync(application, cancellationToken);
@ -1446,13 +1447,13 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
static bool VerifyHashedSecret(string hash, string secret) static bool VerifyHashedSecret(string hash, string secret)
{ {
var payload = new ReadOnlySpan<byte>(Convert.FromBase64String(hash)); var payload = new ReadOnlySpan<byte>(Convert.FromBase64String(hash));
if (payload.Length == 0) if (payload.Length is 0)
{ {
return false; return false;
} }
// Verify the hashing format version. // Verify the hashing format version.
if (payload[0] != 0x01) if (payload[0] is not 0x01)
{ {
return false; return false;
} }

5
src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs

@ -13,6 +13,7 @@ using System.Text.Json;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using static OpenIddict.Abstractions.OpenIddictExceptions; using static OpenIddict.Abstractions.OpenIddictExceptions;
using ValidationException = OpenIddict.Abstractions.OpenIddictExceptions.ValidationException;
namespace OpenIddict.Core; namespace OpenIddict.Core;
@ -124,7 +125,7 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
builder.AppendLine(result.ErrorMessage); builder.AppendLine(result.ErrorMessage);
} }
throw new OpenIddictExceptions.ValidationException(builder.ToString(), results); throw new ValidationException(builder.ToString(), results);
} }
await Store.CreateAsync(authorization, cancellationToken); await Store.CreateAsync(authorization, cancellationToken);
@ -1077,7 +1078,7 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
builder.AppendLine(result.ErrorMessage); builder.AppendLine(result.ErrorMessage);
} }
throw new OpenIddictExceptions.ValidationException(builder.ToString(), results); throw new ValidationException(builder.ToString(), results);
} }
await Store.UpdateAsync(authorization, cancellationToken); await Store.UpdateAsync(authorization, cancellationToken);

5
src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs

@ -12,6 +12,7 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using ValidationException = OpenIddict.Abstractions.OpenIddictExceptions.ValidationException;
namespace OpenIddict.Core; namespace OpenIddict.Core;
@ -117,7 +118,7 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
builder.AppendLine(result.ErrorMessage); builder.AppendLine(result.ErrorMessage);
} }
throw new OpenIddictExceptions.ValidationException(builder.ToString(), results); throw new ValidationException(builder.ToString(), results);
} }
await Store.CreateAsync(scope, cancellationToken); await Store.CreateAsync(scope, cancellationToken);
@ -858,7 +859,7 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
builder.AppendLine(result.ErrorMessage); builder.AppendLine(result.ErrorMessage);
} }
throw new OpenIddictExceptions.ValidationException(builder.ToString(), results); throw new ValidationException(builder.ToString(), results);
} }
await Store.UpdateAsync(scope, cancellationToken); await Store.UpdateAsync(scope, cancellationToken);

5
src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs

@ -13,6 +13,7 @@ using System.Text.Json;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using static OpenIddict.Abstractions.OpenIddictExceptions; using static OpenIddict.Abstractions.OpenIddictExceptions;
using ValidationException = OpenIddict.Abstractions.OpenIddictExceptions.ValidationException;
namespace OpenIddict.Core; namespace OpenIddict.Core;
@ -132,7 +133,7 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
builder.AppendLine(result.ErrorMessage); builder.AppendLine(result.ErrorMessage);
} }
throw new OpenIddictExceptions.ValidationException(builder.ToString(), results); throw new ValidationException(builder.ToString(), results);
} }
await Store.CreateAsync(token, cancellationToken); await Store.CreateAsync(token, cancellationToken);
@ -1206,7 +1207,7 @@ public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TTok
builder.AppendLine(result.ErrorMessage); builder.AppendLine(result.ErrorMessage);
} }
throw new OpenIddictExceptions.ValidationException(builder.ToString(), results); throw new ValidationException(builder.ToString(), results);
} }
await Store.UpdateAsync(token, cancellationToken); await Store.UpdateAsync(token, cancellationToken);

5
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs

@ -16,6 +16,7 @@ using System.Text.Json;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.EntityFramework.Models; using OpenIddict.EntityFramework.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.EntityFramework; namespace OpenIddict.EntityFramework;
@ -201,7 +202,7 @@ public class OpenIddictEntityFrameworkApplicationStore<TApplication, TAuthorizat
Context.Entry(token).State = EntityState.Unchanged; Context.Entry(token).State = EntityState.Unchanged;
} }
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0239), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0239), exception);
} }
} }
@ -986,7 +987,7 @@ public class OpenIddictEntityFrameworkApplicationStore<TApplication, TAuthorizat
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(application).State = EntityState.Unchanged; Context.Entry(application).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0239), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0239), exception);
} }
} }

5
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs

@ -15,6 +15,7 @@ using System.Text.Json;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.EntityFramework.Models; using OpenIddict.EntityFramework.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.EntityFramework; namespace OpenIddict.EntityFramework;
@ -176,7 +177,7 @@ public class OpenIddictEntityFrameworkAuthorizationStore<TAuthorization, TApplic
Context.Entry(token).State = EntityState.Unchanged; Context.Entry(token).State = EntityState.Unchanged;
} }
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0241), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0241), exception);
} }
} }
@ -857,7 +858,7 @@ public class OpenIddictEntityFrameworkAuthorizationStore<TAuthorization, TApplic
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(authorization).State = EntityState.Unchanged; Context.Entry(authorization).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0241), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0241), exception);
} }
} }

5
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs

@ -15,6 +15,7 @@ using System.Text.Json;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.EntityFramework.Models; using OpenIddict.EntityFramework.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.EntityFramework; namespace OpenIddict.EntityFramework;
@ -124,7 +125,7 @@ public class OpenIddictEntityFrameworkScopeStore<TScope, TContext, TKey> : IOpen
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(scope).State = EntityState.Unchanged; Context.Entry(scope).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0245), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0245), exception);
} }
} }
@ -686,7 +687,7 @@ public class OpenIddictEntityFrameworkScopeStore<TScope, TContext, TKey> : IOpen
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(scope).State = EntityState.Unchanged; Context.Entry(scope).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0245), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0245), exception);
} }
} }

5
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs

@ -14,6 +14,7 @@ using System.Text.Json;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.EntityFramework.Models; using OpenIddict.EntityFramework.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.EntityFramework; namespace OpenIddict.EntityFramework;
@ -139,7 +140,7 @@ public class OpenIddictEntityFrameworkTokenStore<TToken, TApplication, TAuthoriz
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(token).State = EntityState.Unchanged; Context.Entry(token).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0247), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0247), exception);
} }
} }
@ -884,7 +885,7 @@ public class OpenIddictEntityFrameworkTokenStore<TToken, TApplication, TAuthoriz
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(token).State = EntityState.Unchanged; Context.Entry(token).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0247), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0247), exception);
} }
} }

5
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs

@ -15,6 +15,7 @@ using System.Text.Json;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.EntityFrameworkCore.Models; using OpenIddict.EntityFrameworkCore.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.EntityFrameworkCore; namespace OpenIddict.EntityFrameworkCore;
@ -243,7 +244,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<TApplication, TAuthor
Context.Entry(token).State = EntityState.Unchanged; Context.Entry(token).State = EntityState.Unchanged;
} }
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0239), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0239), exception);
} }
} }
@ -1027,7 +1028,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<TApplication, TAuthor
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(application).State = EntityState.Unchanged; Context.Entry(application).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0239), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0239), exception);
} }
} }

5
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs

@ -14,6 +14,7 @@ using System.Text.Json;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.EntityFrameworkCore.Models; using OpenIddict.EntityFrameworkCore.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.EntityFrameworkCore; namespace OpenIddict.EntityFrameworkCore;
@ -212,7 +213,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore<TAuthorization, TAp
Context.Entry(token).State = EntityState.Unchanged; Context.Entry(token).State = EntityState.Unchanged;
} }
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0241), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0241), exception);
} }
} }
@ -943,7 +944,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore<TAuthorization, TAp
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(authorization).State = EntityState.Unchanged; Context.Entry(authorization).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0241), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0241), exception);
} }
} }

5
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs

@ -14,6 +14,7 @@ using System.Text.Json;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.EntityFrameworkCore.Models; using OpenIddict.EntityFrameworkCore.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.EntityFrameworkCore; namespace OpenIddict.EntityFrameworkCore;
@ -140,7 +141,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore<TScope, TContext, TKey> : I
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(scope).State = EntityState.Unchanged; Context.Entry(scope).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0245), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0245), exception);
} }
} }
@ -702,7 +703,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore<TScope, TContext, TKey> : I
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(scope).State = EntityState.Unchanged; Context.Entry(scope).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0245), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0245), exception);
} }
} }

5
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs

@ -13,6 +13,7 @@ using System.Text.Json;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.EntityFrameworkCore.Models; using OpenIddict.EntityFrameworkCore.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.EntityFrameworkCore; namespace OpenIddict.EntityFrameworkCore;
@ -159,7 +160,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore<TToken, TApplication, TAuth
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(token).State = EntityState.Unchanged; Context.Entry(token).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0247), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0247), exception);
} }
} }
@ -954,7 +955,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore<TToken, TApplication, TAuth
// Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing. // Reset the state of the entity to prevents future calls to SaveChangesAsync() from failing.
Context.Entry(token).State = EntityState.Unchanged; Context.Entry(token).State = EntityState.Unchanged;
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0247), exception); throw new ConcurrencyException(SR.GetResourceString(SR.ID0247), exception);
} }
} }

5
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs

@ -12,6 +12,7 @@ using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.MongoDb.Models; using OpenIddict.MongoDb.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.MongoDb; namespace OpenIddict.MongoDb;
@ -93,7 +94,7 @@ public class OpenIddictMongoDbApplicationStore<TApplication> : IOpenIddictApplic
entity.Id == application.Id && entity.Id == application.Id &&
entity.ConcurrencyToken == application.ConcurrencyToken, cancellationToken)).DeletedCount == 0) entity.ConcurrencyToken == application.ConcurrencyToken, cancellationToken)).DeletedCount == 0)
{ {
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0239)); throw new ConcurrencyException(SR.GetResourceString(SR.ID0239));
} }
// Delete the authorizations associated with the application. // Delete the authorizations associated with the application.
@ -661,7 +662,7 @@ public class OpenIddictMongoDbApplicationStore<TApplication> : IOpenIddictApplic
entity.Id == application.Id && entity.Id == application.Id &&
entity.ConcurrencyToken == timestamp, application, null as ReplaceOptions, cancellationToken)).MatchedCount == 0) entity.ConcurrencyToken == timestamp, application, null as ReplaceOptions, cancellationToken)).MatchedCount == 0)
{ {
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0239)); throw new ConcurrencyException(SR.GetResourceString(SR.ID0239));
} }
} }
} }

5
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs

@ -11,6 +11,7 @@ using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.MongoDb.Models; using OpenIddict.MongoDb.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.MongoDb; namespace OpenIddict.MongoDb;
@ -92,7 +93,7 @@ public class OpenIddictMongoDbAuthorizationStore<TAuthorization> : IOpenIddictAu
entity.Id == authorization.Id && entity.Id == authorization.Id &&
entity.ConcurrencyToken == authorization.ConcurrencyToken, cancellationToken)).DeletedCount == 0) entity.ConcurrencyToken == authorization.ConcurrencyToken, cancellationToken)).DeletedCount == 0)
{ {
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0241)); throw new ConcurrencyException(SR.GetResourceString(SR.ID0241));
} }
// Delete the tokens associated with the authorization. // Delete the tokens associated with the authorization.
@ -721,7 +722,7 @@ public class OpenIddictMongoDbAuthorizationStore<TAuthorization> : IOpenIddictAu
entity.Id == authorization.Id && entity.Id == authorization.Id &&
entity.ConcurrencyToken == timestamp, authorization, null as ReplaceOptions, cancellationToken)).MatchedCount == 0) entity.ConcurrencyToken == timestamp, authorization, null as ReplaceOptions, cancellationToken)).MatchedCount == 0)
{ {
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0241)); throw new ConcurrencyException(SR.GetResourceString(SR.ID0241));
} }
} }
} }

5
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs

@ -12,6 +12,7 @@ using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.MongoDb.Models; using OpenIddict.MongoDb.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.MongoDb; namespace OpenIddict.MongoDb;
@ -93,7 +94,7 @@ public class OpenIddictMongoDbScopeStore<TScope> : IOpenIddictScopeStore<TScope>
entity.Id == scope.Id && entity.Id == scope.Id &&
entity.ConcurrencyToken == scope.ConcurrencyToken, cancellationToken)).DeletedCount == 0) entity.ConcurrencyToken == scope.ConcurrencyToken, cancellationToken)).DeletedCount == 0)
{ {
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0245)); throw new ConcurrencyException(SR.GetResourceString(SR.ID0245));
} }
} }
@ -513,7 +514,7 @@ public class OpenIddictMongoDbScopeStore<TScope> : IOpenIddictScopeStore<TScope>
entity.Id == scope.Id && entity.Id == scope.Id &&
entity.ConcurrencyToken == timestamp, scope, null as ReplaceOptions, cancellationToken)).MatchedCount == 0) entity.ConcurrencyToken == timestamp, scope, null as ReplaceOptions, cancellationToken)).MatchedCount == 0)
{ {
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0245)); throw new ConcurrencyException(SR.GetResourceString(SR.ID0245));
} }
} }
} }

5
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbTokenStore.cs

@ -11,6 +11,7 @@ using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using OpenIddict.MongoDb.Models; using OpenIddict.MongoDb.Models;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.MongoDb; namespace OpenIddict.MongoDb;
@ -92,7 +93,7 @@ public class OpenIddictMongoDbTokenStore<TToken> : IOpenIddictTokenStore<TToken>
entity.Id == token.Id && entity.Id == token.Id &&
entity.ConcurrencyToken == token.ConcurrencyToken, cancellationToken)).DeletedCount == 0) entity.ConcurrencyToken == token.ConcurrencyToken, cancellationToken)).DeletedCount == 0)
{ {
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0247)); throw new ConcurrencyException(SR.GetResourceString(SR.ID0247));
} }
} }
@ -808,7 +809,7 @@ public class OpenIddictMongoDbTokenStore<TToken> : IOpenIddictTokenStore<TToken>
entity.Id == token.Id && entity.Id == token.Id &&
entity.ConcurrencyToken == timestamp, token, null as ReplaceOptions, cancellationToken)).MatchedCount == 0) entity.ConcurrencyToken == timestamp, token, null as ReplaceOptions, cancellationToken)).MatchedCount == 0)
{ {
throw new OpenIddictExceptions.ConcurrencyException(SR.GetResourceString(SR.ID0247)); throw new ConcurrencyException(SR.GetResourceString(SR.ID0247));
} }
} }
} }

27
src/OpenIddict.Validation/OpenIddictValidationService.cs

@ -9,6 +9,7 @@ using System.Security.Claims;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using static OpenIddict.Abstractions.OpenIddictExceptions;
namespace OpenIddict.Validation; namespace OpenIddict.Validation;
@ -76,7 +77,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0148(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0148(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -96,7 +97,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0149(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0149(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -118,7 +119,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0150(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0150(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -143,7 +144,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0151(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0151(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -220,7 +221,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0152(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0152(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -240,7 +241,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0153(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0153(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -262,7 +263,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0154(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0154(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -286,7 +287,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0155(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0155(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -382,7 +383,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0158(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0158(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -402,7 +403,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0159(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0159(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -424,7 +425,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0160(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0160(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -450,7 +451,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0161(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0161(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }
@ -513,7 +514,7 @@ public class OpenIddictValidationService
if (context.IsRejected) if (context.IsRejected)
{ {
throw new OpenIddictExceptions.ProtocolException( throw new ProtocolException(
SR.FormatID0163(context.Error, context.ErrorDescription, context.ErrorUri), SR.FormatID0163(context.Error, context.ErrorDescription, context.ErrorUri),
context.Error, context.ErrorDescription, context.ErrorUri); context.Error, context.ErrorDescription, context.ErrorUri);
} }

Loading…
Cancel
Save