1
|
package eu.dnetlib.uoaadmintools;
|
2
|
|
3
|
import eu.dnetlib.uoaadmintools.handlers.AuthorizationHandler;
|
4
|
import org.apache.log4j.Logger;
|
5
|
import org.springframework.beans.factory.annotation.Value;
|
6
|
import org.springframework.context.annotation.Bean;
|
7
|
import org.springframework.context.annotation.Configuration;
|
8
|
import org.springframework.context.annotation.PropertySource;
|
9
|
import org.springframework.context.annotation.PropertySources;
|
10
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
11
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
12
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
13
|
|
14
|
import java.util.List;
|
15
|
|
16
|
/**
|
17
|
* Created by argirok on 23/2/2018.
|
18
|
*/
|
19
|
|
20
|
@Configuration
|
21
|
public class UoaAdminToolsConfiguration extends WebMvcConfigurerAdapter {
|
22
|
private final Logger log = Logger.getLogger(this.getClass());
|
23
|
|
24
|
@Value( "${admintool.userInfoUrl}" )
|
25
|
private String userInfoUrl = null;
|
26
|
|
27
|
@Value( "${admintool.originServer}" )
|
28
|
private String originServer= null;
|
29
|
|
30
|
@Value("#{'${post.allowed}'.split(',')}")
|
31
|
private List<String> allowedPostRequests;
|
32
|
|
33
|
@Bean
|
34
|
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
35
|
return new PropertySourcesPlaceholderConfigurer();
|
36
|
}
|
37
|
|
38
|
@Override
|
39
|
public void addInterceptors(InterceptorRegistry registry) {
|
40
|
registry.addInterceptor(new AuthorizationHandler(userInfoUrl,originServer, allowedPostRequests))
|
41
|
.addPathPatterns("/**");
|
42
|
|
43
|
}
|
44
|
|
45
|
}
|