-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IssuerSigningKeyValidationError and updated its use within the …
…signing key validation
- Loading branch information
Showing
3 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...rosoft.IdentityModel.Tokens/Validation/Results/Details/IssuerSigningKeyValidationError.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
|
||
using System.Diagnostics; | ||
using System; | ||
|
||
#nullable enable | ||
namespace Microsoft.IdentityModel.Tokens | ||
{ | ||
internal class IssuerSigningKeyValidationError : ValidationError | ||
{ | ||
internal IssuerSigningKeyValidationError( | ||
MessageDetail messageDetail, | ||
Type exceptionType, | ||
StackFrame stackFrame, | ||
SecurityKey? invalidSigningKey, | ||
ValidationFailureType? failureType = null, | ||
Exception? innerException = null) | ||
: base(messageDetail, exceptionType, stackFrame, failureType ?? ValidationFailureType.SigningKeyValidationFailed, innerException) | ||
{ | ||
InvalidSigningKey = invalidSigningKey; | ||
} | ||
|
||
internal override Exception GetException() | ||
{ | ||
if (ExceptionType == typeof(SecurityTokenInvalidSigningKeyException)) | ||
{ | ||
SecurityTokenInvalidSigningKeyException? exception = new(MessageDetail.Message, InnerException) | ||
{ | ||
SigningKey = InvalidSigningKey | ||
}; | ||
exception.SetValidationError(this); | ||
|
||
return exception; | ||
} | ||
|
||
return base.GetException(); | ||
} | ||
|
||
|
||
internal static new IssuerSigningKeyValidationError NullParameter(string parameterName, StackFrame stackFrame) => new( | ||
MessageDetail.NullParameter(parameterName), | ||
typeof(SecurityTokenArgumentNullException), | ||
stackFrame, | ||
null, // InvalidSigningKey | ||
ValidationFailureType.NullArgument); | ||
|
||
protected SecurityKey? InvalidSigningKey { get; set; } | ||
} | ||
} | ||
#nullable restore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters