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

51 lines
2.1 KiB
Java
Raw Normal View History

2017-12-15 17:57:41 +01:00
package eu.eudat.configurations;
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-15 17:57:41 +01:00
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
2018-02-07 10:56:30 +01:00
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
2017-12-15 17:57:41 +01:00
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
2018-03-05 17:18:45 +01:00
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
2017-12-15 17:57:41 +01:00
import java.util.List;
2018-02-07 10:56:30 +01:00
@EnableAsync
2017-12-15 17:57:41 +01:00
@Configuration
@EnableScheduling
public class WebMVCConfiguration implements WebMvcConfigurer {
2017-12-15 17:57:41 +01:00
private ApiContext apiContext;
2018-03-05 17:18:45 +01:00
private final AuthenticationService verifiedUserAuthenticationService;
private final AuthenticationService nonVerifiedUserAuthenticationService;
2018-03-05 17:18:45 +01:00
private final Environment environment;
public WebMVCConfiguration(ApiContext apiContext, AuthenticationService verifiedUserAuthenticationService, AuthenticationService nonVerifiedUserAuthenticationService, Environment environment) {
this.apiContext = apiContext;
this.verifiedUserAuthenticationService = verifiedUserAuthenticationService;
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
this.environment = environment;
}
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/api/**").allowedOrigins(this.environment.getProperty("dmp.domain"));
}
2018-02-16 11:34:02 +01:00
@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
}