argos/dmp-backend/web/src/main/java/eu/eudat/configurations/WebMVCConfiguration.java

43 lines
1.8 KiB
Java
Raw Normal View History

2017-12-15 17:57:41 +01:00
package eu.eudat.configurations;
2018-03-05 17:18:45 +01:00
import eu.eudat.controllers.interceptors.RequestInterceptor;
2018-06-27 12:29:21 +02:00
import eu.eudat.logic.handlers.PrincipalArgumentResolver;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
2017-12-19 10:02:25 +01:00
import org.springframework.beans.factory.annotation.Autowired;
2017-12-15 17:57:41 +01:00
import org.springframework.context.annotation.Configuration;
2018-02-07 10:56:30 +01:00
import org.springframework.scheduling.annotation.EnableAsync;
2017-12-15 17:57:41 +01:00
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
2018-03-05 17:18:45 +01:00
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
2017-12-15 17:57:41 +01:00
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.List;
2018-02-07 10:56:30 +01:00
@EnableAsync
2017-12-15 17:57:41 +01:00
@Configuration
public class WebMVCConfiguration extends WebMvcConfigurerAdapter {
private ApiContext apiContext;
2018-03-05 17:18:45 +01:00
private AuthenticationService verifiedUserAuthenticationService;
private AuthenticationService nonVerifiedUserAuthenticationService;
2018-03-05 17:18:45 +01:00
@Autowired
public WebMVCConfiguration(ApiContext apiContext, AuthenticationService verifiedUserAuthenticationService, AuthenticationService nonVerifiedUserAuthenticationService) {
this.apiContext = apiContext;
this.verifiedUserAuthenticationService = verifiedUserAuthenticationService;
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
}
2018-02-16 11:34:02 +01:00
@Autowired
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new PrincipalArgumentResolver(verifiedUserAuthenticationService, nonVerifiedUserAuthenticationService));
}
2018-03-05 17:18:45 +01:00
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new RequestInterceptor(this.apiContext.getHelpersService().getLoggerService()));
}
2017-12-15 17:57:41 +01:00
}