Open petekaras opened 7 years ago
Unfortunately you cannot currently specify the ObjectMapper that the JwtBuilder will use to generate the resulting JSON. Yet. :)
We'll use this issue to track the work to allow you to do so :)
That said, would you say this issue should be classified as "Allow me to set my own ObjectMapper" ?
Or is the issue really "Please support Java8 Date/Time formats ?
Thoughts?
Thanks for the issue!
Hi Les, Yes, I think this is really about supporting Java8 formats. I would be happy to contribute to this project, but am short of time right now. Will let you know if I can help out in the future if you are looking for contributors ?
It would be nice to have overloaded methods e.g. in Claims
e.g.
public Claims setExpiration(LocalDateTime date);
public Claims setNotBefore(LocalDateTime date);
public Claims setIssuedAt(LocalDateTime date);
Would you accept a PR for that?
Depends on #308.
This ticket would add support for claims of type:
Anything else?
Can we add OffsetDateTime
to the list?
I would not support LocalDateTime
. LocalDateTime
is not an instant and therefore does not identify a point in time. You would need a time zone for that. Which means you don't know how much time has passed since a claim was issued which means that you don't know whether it is expired.
Even the JSR-310 expert group leader thinks LocalDateTime
is not generally useful.
https://github.com/tc39/proposal-temporal/issues/7#issuecomment-288997620
@marschall I completely agree. LocalDateTime
is ambiguous. However, Instant has far too many advantages over java.util.Date. I will check other tickets for progress on of deprecation of java.util.Date.
@RockyMM sure, Instant
, OffsetDateTime
and ZonedDateTime
are a great addition and completely fine.
Hi, it's 2023, any good news?
Once #279 is in, Java8 support is next!
What's the status of this issue?
@bartsopers Not yet implemented, but it will be, likely after the holidays. All of our energy was focused on 0.12.0, so now that it's out, we will focus on other 1.0 issues (like this one) soon.
Hi, Maybe I'm missing something so apologies if this is not an issue. I've configured my spring boot application to use jackson-datatype-jsr310 by including in pom.xml, all outgoing json is serialized correctly. however I am using a hashmap to set the payload of the the jwt token:
and this is being serialized in the Long LocalDateTimeFormat:
I had a similar issue in another spring boot application where I was using new ObjectMapper() and not using springBoots configured ObjectMapper. Any ideas how I could make jjwt pick up springboots ObjectMapper which would be configured correctly ? I'm using using jjwt version 0.7.0.
Thanks in advance for your help, Peter