All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.jwt.JWTContextResolver Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha4
Show newest version
package org.jboss.resteasy.jwt;

import javax.ws.rs.ext.ContextResolver;

import org.jboss.resteasy.plugins.providers.jackson.WhiteListPolymorphicTypeValidatorBuilder;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

/**
 * Any class that extends JsonWebToken will use NON_DEFAULT inclusion
 *
 * @author Bill Burke
 * @version $Revision: 1 $
 */
public class JWTContextResolver implements ContextResolver
{
   protected ObjectMapper mapper = new ObjectMapper();

   public JWTContextResolver()
   {
      mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
      mapper.setPolymorphicTypeValidator(new WhiteListPolymorphicTypeValidatorBuilder().build());
   }

   public JWTContextResolver(final boolean indent)
   {
      this();
      if (indent)
      {
         mapper.enable(SerializationFeature.INDENT_OUTPUT);
      }
   }


   @Override
   public ObjectMapper getContext(Class type)
   {
      if (JsonWebToken.class.isAssignableFrom(type)) return mapper;
      return null;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy