-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consistent implementation of ValidateExpClaim and ValidateNbfClaim (#397
) * Added TokenNotYetValidException * Updated JwtValidator to throw it * Updated tests * Bumped version to 9.0.2 Co-authored-by: Alexander Batishchev <[email protected]>
- Loading branch information
1 parent
7fc7908
commit 6d14b6d
Showing
4 changed files
with
56 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
#if NET35 || NET40 | ||
using IReadOnlyPayloadDictionary = System.Collections.Generic.IDictionary<string, object>; | ||
#else | ||
using IReadOnlyPayloadDictionary = System.Collections.Generic.IReadOnlyDictionary<string, object>; | ||
#endif | ||
|
||
namespace JWT.Exceptions | ||
{ | ||
/// <summary> | ||
/// Represents an exception thrown when a token is not yet valid. | ||
/// </summary> | ||
public class TokenNotYetValidException : SignatureVerificationException | ||
{ | ||
private const string PayloadDataKey = "PayloadData"; | ||
private const string NotBeforeKey = "NotBefore"; | ||
|
||
/// <summary> | ||
/// Creates an instance of <see cref="TokenNotYetValidException" /> | ||
/// </summary> | ||
/// <param name="message">The error message</param> | ||
public TokenNotYetValidException(string message) | ||
: base(message) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// The payload. | ||
/// </summary> | ||
public IReadOnlyPayloadDictionary PayloadData | ||
{ | ||
get => GetOrDefault<Dictionary<string, object>>(PayloadDataKey); | ||
internal set => this.Data.Add(PayloadDataKey, value); | ||
} | ||
|
||
/// <summary> | ||
/// The not before DateTime of the token. | ||
/// </summary> | ||
public DateTime? NotBefore | ||
{ | ||
get => GetOrDefault<DateTime?>(NotBeforeKey); | ||
internal set => this.Data.Add(NotBeforeKey, value); | ||
} | ||
} | ||
} |
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
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
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