A JWT can carry three standard time claims: iat (issued at), nbf (not before), and exp (expiration). This exercise validates only those claims; assume the token's structure and signature have already been verified.
Design a JwtClaimValidator class:
JwtClaimValidator() creates a stateless validator.boolean isValid(int iat, int nbf, int exp, int now) returns whether the token is valid at now.
A token is valid exactly when all three conditions hold:
The not-before boundary is inclusive. The expiration boundary is exclusive. No clock-skew allowance is applied.
Example 1:
Input:
Output:
Explanation: At time 50, the token has been issued, its validity window has begun, and its expiration time is still in the future.
Example 2:
Input:
Output:
Explanation: A token is expired when now == exp, so the strict expiration check fails.
Constraints
0 <= iat, nbf, exp, now <= 2^31 - 1- Values are integer timestamps using the same unit.
nbf is inclusive and exp is exclusive.- Do not apply clock skew or validate signatures, audiences, issuers, or revocation.
- At most
100 calls are made to isValid.