- edited description
Change to use Instant instead of Date
Once Nimbus upgrades to Java 8, it would be helpful if JWTClaimsSet
used Instant
instead of Date
. For example,
Instant issuedAt = claims.getIssueTime();
or
Instant issuedAt = claims.getIssuedAt();
I think that Instant
is a better representation of a moment in time anyway in addition to being immutable.
Right now, we are using JWTClaimsSetTransformer
to make the accommodation, so we certainly have a workaround. It would just be nice to not have to do that.
As an alternative, I'd also be happy with:
Instant issuedAt = claims.getInstantClaim(JWTClaimsSet.ISSUED_AT)
Comments (5)
-
reporter -
reporter - edited description
-
Yep, that would be nice, but because of Android users we'll need to stay with Java 7 for now (see my comment in issue
#259). -
If this project every updates to use Instant, you should also have the ability to use a custom
Clock
inDefaultJWTClaimsVerifier
in order to get an instance ofnow
. For instance, instead of doingnow = new Date()
it would be preferable to donow = clock.instant()
.This would allow for easier testing of our application code because we can use our own Clock which would testing of time based claims more reproducible.
-
@Jose I suppose it’s possible to use a custom clock with the current java.util.Date arrangement. Feel free to submit a PR if you feel like exploring this.
- Log in to comment