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;
|
2019-07-12 15:58:17 +02:00
|
|
|
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
2017-12-15 17:57:41 +01:00
|
|
|
import org.springframework.context.annotation.Configuration;
|
2022-04-18 17:32:25 +02:00
|
|
|
import org.springframework.core.env.Environment;
|
2018-02-07 10:56:30 +01:00
|
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
2020-02-14 17:40:34 +01:00
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
2017-12-15 17:57:41 +01:00
|
|
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
2022-04-18 17:32:25 +02:00
|
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
2018-03-05 17:18:45 +01:00
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
2022-04-18 17:32:25 +02:00
|
|
|
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
|
2020-02-14 17:40:34 +01:00
|
|
|
@EnableScheduling
|
2022-04-18 17:32:25 +02:00
|
|
|
public class WebMVCConfiguration implements WebMvcConfigurer {
|
2017-12-15 17:57:41 +01:00
|
|
|
|
2019-07-12 15:58:17 +02:00
|
|
|
private ApiContext apiContext;
|
2018-03-05 17:18:45 +01:00
|
|
|
|
2022-04-18 17:32:25 +02:00
|
|
|
private final AuthenticationService verifiedUserAuthenticationService;
|
|
|
|
private final AuthenticationService nonVerifiedUserAuthenticationService;
|
2018-03-05 17:18:45 +01:00
|
|
|
|
2022-04-18 17:32:25 +02:00
|
|
|
private final Environment environment;
|
|
|
|
|
|
|
|
public WebMVCConfiguration(ApiContext apiContext, AuthenticationService verifiedUserAuthenticationService, AuthenticationService nonVerifiedUserAuthenticationService, Environment environment) {
|
2019-07-12 15:58:17 +02:00
|
|
|
this.apiContext = apiContext;
|
|
|
|
this.verifiedUserAuthenticationService = verifiedUserAuthenticationService;
|
|
|
|
this.nonVerifiedUserAuthenticationService = nonVerifiedUserAuthenticationService;
|
2022-04-18 17:32:25 +02:00
|
|
|
this.environment = environment;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
|
|
registry.addMapping("/api/**").allowedOrigins(this.environment.getProperty("dmp.domain"));
|
2019-07-12 15:58:17 +02:00
|
|
|
}
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-07-12 15:58:17 +02:00
|
|
|
@Override
|
|
|
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
|
|
|
argumentResolvers.add(new PrincipalArgumentResolver(verifiedUserAuthenticationService, nonVerifiedUserAuthenticationService));
|
|
|
|
}
|
2018-03-05 17:18:45 +01:00
|
|
|
|
2019-07-12 15:58:17 +02:00
|
|
|
@Override
|
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
2020-01-28 17:33:50 +01:00
|
|
|
// registry.addInterceptor(new RequestInterceptor(this.apiContext.getHelpersService().getLoggerService()));
|
2019-07-12 15:58:17 +02:00
|
|
|
}
|
2017-12-15 17:57:41 +01:00
|
|
|
}
|