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

48 lines
2.0 KiB
Java

package eu.eudat.configurations;
import eu.eudat.interceptors.tenant.TenantInterceptor;
import eu.eudat.interceptors.tenant.TenantScopeClaimInterceptor;
import eu.eudat.interceptors.tenant.TenantScopeHeaderInterceptor;
import eu.eudat.interceptors.user.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
@EnableAsync
@Configuration
@EnableScheduling
public class WebMVCConfiguration implements WebMvcConfigurer {
private final TenantInterceptor tenantInterceptor;
private final UserInterceptor userInterceptor;
private final TenantScopeHeaderInterceptor scopeHeaderInterceptor;
private final TenantScopeClaimInterceptor scopeClaimInterceptor;
@Autowired
public WebMVCConfiguration(TenantInterceptor tenantInterceptor, UserInterceptor userInterceptor, TenantScopeHeaderInterceptor scopeHeaderInterceptor, TenantScopeClaimInterceptor scopeClaimInterceptor) {
this.tenantInterceptor = tenantInterceptor;
this.userInterceptor = userInterceptor;
this.scopeHeaderInterceptor = scopeHeaderInterceptor;
this.scopeClaimInterceptor = scopeClaimInterceptor;
}
@Autowired
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
int order = 1;
registry.addWebRequestInterceptor(scopeHeaderInterceptor).order(order++);
registry.addWebRequestInterceptor(scopeClaimInterceptor).order(order++);
registry.addWebRequestInterceptor(userInterceptor).order(order++);
registry.addWebRequestInterceptor(tenantInterceptor).order(order++);
}
}