Merge branch 'master' into develop
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package it.integry.ems.configuration;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import it.integry.ems.adapter.JsonDateAdapterDeserializer;
|
||||
import it.integry.ems.adapter.JsonDateAdapterSerializer;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
@@ -14,14 +12,14 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
|
||||
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class JsonConfig implements WebMvcConfigurer {
|
||||
|
||||
|
||||
@Bean("jacksonResponseObjectMapper")
|
||||
@Bean
|
||||
public ResponseJSONObjectMapper jacksonResponseObjectMapper() {
|
||||
final ResponseJSONObjectMapper objectMapper = new ResponseJSONObjectMapper();
|
||||
|
||||
@@ -30,7 +28,10 @@ public class JsonConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
||||
configurer.defaultContentType(MediaType.APPLICATION_JSON);
|
||||
configurer.favorParameter(false)
|
||||
.ignoreAcceptHeader(true)
|
||||
.defaultContentType(new MediaType(MediaType.APPLICATION_JSON, StandardCharsets.UTF_8))
|
||||
.mediaType("json", new MediaType(MediaType.APPLICATION_JSON, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,7 +41,11 @@ public class JsonConfig implements WebMvcConfigurer {
|
||||
builder.deserializerByType(Date.class, new JsonDateAdapterDeserializer());
|
||||
builder.serializerByType(Date.class, new JsonDateAdapterSerializer());
|
||||
|
||||
converters.add(new MappingJackson2HttpMessageConverter(builder.build()));
|
||||
final MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(builder.build());
|
||||
mappingJackson2HttpMessageConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||
mappingJackson2HttpMessageConverter.setObjectMapper(jacksonResponseObjectMapper());
|
||||
|
||||
converters.add(mappingJackson2HttpMessageConverter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ public class EmsRestConstants {
|
||||
public static final String PATH_SPLIT_ORDER_SURGELATI = "splitOrderSurgelati";
|
||||
public static final String PATH_IMPORT_ORDER_ECOMMERCE = "importOrderEcommerce";
|
||||
public static final String APPLICATION_JSON_CHARSET_UTF_8 = "application/json; charset=UTF-8";
|
||||
public static final String TEXT_PLAIN_CHARSET_UTF_8 = "text/plain; charset=UTF-8";
|
||||
public static final String TYPE = "type";
|
||||
public static final String FORMAT = "format";
|
||||
public static final String USERNAME = "username";
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package it.integry.security.config;
|
||||
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
public class EncodingFilter extends GenericFilterBean {
|
||||
|
||||
@Override
|
||||
public void doFilter(
|
||||
ServletRequest request,
|
||||
ServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.web.access.channel.ChannelProcessingFilter;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
@EnableWebSecurity
|
||||
@@ -48,6 +49,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.csrf().disable()
|
||||
|
||||
// .addFilterBefore(corsFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.addFilterBefore(new EncodingFilter(), ChannelProcessingFilter.class)
|
||||
.addFilterBefore(new JWTFilter(accessTokenProvider, tokenCache), UsernamePasswordAuthenticationFilter.class)
|
||||
|
||||
.exceptionHandling()
|
||||
|
||||
Reference in New Issue
Block a user