11package com .auth0 .jwt .impl ;
22
3- import com .fasterxml .jackson .core .JsonGenerator ;
4- import com .fasterxml .jackson .databind .SerializerProvider ;
5- import com .fasterxml .jackson .databind .ser .std .StdSerializer ;
3+ import tools .jackson .core .JacksonException ;
4+ import tools .jackson .core .JsonGenerator ;
5+ import tools .jackson .databind .ser .std .StdSerializer ;
6+ import tools .jackson .databind .SerializationContext ;
67
7- import java .io .IOException ;
88import java .time .Instant ;
99import java .util .Date ;
1010import java .util .List ;
@@ -22,7 +22,7 @@ public ClaimsSerializer(Class<T> t) {
2222 }
2323
2424 @ Override
25- public void serialize (T holder , JsonGenerator gen , SerializerProvider provider ) throws IOException {
25+ public void serialize (T holder , JsonGenerator gen , SerializationContext provider ) throws JacksonException {
2626 gen .writeStartObject ();
2727 for (Map .Entry <String , Object > entry : holder .getClaims ().entrySet ()) {
2828 writeClaim (entry , gen );
@@ -37,14 +37,14 @@ public void serialize(T holder, JsonGenerator gen, SerializerProvider provider)
3737 *
3838 * @param entry The entry that corresponds to the JSON field to write
3939 * @param gen The {@code JsonGenerator} to use
40- * @throws IOException if there is either an underlying I/O problem or encoding issue at format layer
40+ * @throws JacksonException if there is either an underlying I/O problem or encoding issue at format layer
4141 */
42- protected void writeClaim (Map .Entry <String , Object > entry , JsonGenerator gen ) throws IOException {
43- gen .writeFieldName (entry .getKey ());
42+ protected void writeClaim (Map .Entry <String , Object > entry , JsonGenerator gen ) throws JacksonException {
43+ gen .writeName (entry .getKey ());
4444 handleSerialization (entry .getValue (), gen );
4545 }
4646
47- private static void handleSerialization (Object value , JsonGenerator gen ) throws IOException {
47+ private static void handleSerialization (Object value , JsonGenerator gen ) throws JacksonException {
4848 if (value instanceof Date ) {
4949 gen .writeNumber (dateToSeconds ((Date ) value ));
5050 } else if (value instanceof Instant ) { // EXPIRES_AT, ISSUED_AT, NOT_BEFORE, custom Instant claims
@@ -54,21 +54,21 @@ private static void handleSerialization(Object value, JsonGenerator gen) throws
5454 } else if (value instanceof List ) {
5555 serializeList ((List <?>) value , gen );
5656 } else {
57- gen .writeObject (value );
57+ gen .writePOJO (value );
5858 }
5959 }
6060
61- private static void serializeMap (Map <?, ?> map , JsonGenerator gen ) throws IOException {
61+ private static void serializeMap (Map <?, ?> map , JsonGenerator gen ) throws JacksonException {
6262 gen .writeStartObject ();
6363 for (Map .Entry <?, ?> entry : map .entrySet ()) {
64- gen .writeFieldName ((String ) entry .getKey ());
64+ gen .writeName ((String ) entry .getKey ());
6565 Object value = entry .getValue ();
6666 handleSerialization (value , gen );
6767 }
6868 gen .writeEndObject ();
6969 }
7070
71- private static void serializeList (List <?> list , JsonGenerator gen ) throws IOException {
71+ private static void serializeList (List <?> list , JsonGenerator gen ) throws JacksonException {
7272 gen .writeStartArray ();
7373 for (Object entry : list ) {
7474 handleSerialization (entry , gen );
0 commit comments