Project

General

Profile

« Previous | Next » 

Revision 57909

Replacing XML with Java configuration

View differences:

modules/uoa-repository-manager-service/trunk/src/test/resources/application-context.xml
8 8

  
9 9
    <context:annotation-config/>
10 10
    <context:component-scan base-package="eu.dnetlib.repo.manager.service.*"/>
11
    <tx:annotation-driven transaction-manager="txManager"/>
12 11

  
13 12
    <bean class="eu.dnetlib.repo.manager.config.CascadingPropertyLoader"
14 13
          id="propertyLoader">
......
27 26
                <value>classpath*:/eu/**/springContext-*.properties</value>
28 27

  
29 28
                <value>classpath*:/application.properties</value>
30
                <value>classpath*:/email-texts.properties</value>
29
                <value>classpath*:email-texts.properties</value>
31 30

  
32
<!--                <value>classpath*:dnet-site-wizard.properties</value>-->
33
<!--                <value>classpath*:dnet-site-override.properties</value>-->
34
<!--                <value>classpath*:dnet-wizard.properties</value>-->
35
<!--                <value>classpath*:dnet-override-new.properties</value>-->
36
<!--                <value>classpath*:dnet-validator-wizard.properties</value>-->
37
<!--                <value>classpath*:dnet-validator-override.properties</value>-->
38
<!--                <value>classpath*:dnet-site-force-override.properties</value>-->
39
<!--                <value>classpath*:dnet-force-override.properties</value>-->
31
                <!--                <value>classpath*:dnet-site-wizard.properties</value>-->
32
                <!--                <value>classpath*:dnet-site-override.properties</value>-->
33
                <!--                <value>classpath*:dnet-wizard.properties</value>-->
34
                <!--                <value>classpath*:dnet-override.properties</value>-->
35
                <!--                <value>classpath*:dnet-validator-wizard.properties</value>-->
36
                <!--                <value>classpath*:dnet-validator-override.properties</value>-->
37
                <!--                <value>classpath*:dnet-site-force-override.properties</value>-->
38
                <!--                <value>classpath*:dnet-force-override.properties</value>-->
40 39
            </list>
41 40
        </property>
42 41
    </bean>
43

  
44
    <bean id="repomanager.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
45
        <property name="driverClassName" value="${repomanager.db.driverClassName}" />
46
        <property name="url" value="${repomanager.db.url}" />
47
        <property name="username" value="${repomanager.db.username}" />
48
        <property name="password" value="${repomanager.db.password}" />
49
        <property name="maxIdle" value="10" />
50
        <property name="maxActive" value="100" />
51
        <property name="maxWait" value="10000" />
52
        <property name="validationQuery" value="SELECT 1;" />
53
        <property name="testOnBorrow" value="true" />
54
        <property name="testOnReturn" value="true" />
55
        <property name="testWhileIdle" value="true" />
56
        <property name="timeBetweenEvictionRunsMillis" value="1200000" />
57
        <property name="minEvictableIdleTimeMillis" value="1800000" />
58
        <property name="numTestsPerEvictionRun" value="5" />
59
        <property name="poolPreparedStatements" value="true" />
60
        <property name="defaultAutoCommit" value="true" />
61
    </bean>
62

  
63
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
64
        <property name="dataSource" ref="repomanager.dataSource"/>
65
    </bean>
66

  
67 42
</beans>
modules/uoa-repository-manager-service/trunk/src/test/resources/applicationContext.xml
67 67
        </property>
68 68
    </bean>
69 69

  
70
    <bean id="repomanager.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
71
        <property name="driverClassName" value="${repomanager.db.driverClassName}" />
72
        <property name="url" value="${repomanager.db.url}" />
73
        <property name="username" value="${repomanager.db.username}" />
74
        <property name="password" value="${repomanager.db.password}" />
75
        <property name="maxIdle" value="10" />
76
        <property name="maxActive" value="100" />
77
        <property name="maxWait" value="10000" />
78
        <property name="validationQuery" value="SELECT 1;" />
79
        <property name="testOnBorrow" value="true" />
80
        <property name="testOnReturn" value="true" />
81
        <property name="testWhileIdle" value="true" />
82
        <property name="timeBetweenEvictionRunsMillis" value="1200000" />
83
        <property name="minEvictableIdleTimeMillis" value="1800000" />
84
        <property name="numTestsPerEvictionRun" value="5" />
85
        <property name="poolPreparedStatements" value="true" />
86
        <property name="defaultAutoCommit" value="true" />
87
    </bean>
88

  
89
    <tx:annotation-driven transaction-manager="txManager"/>
90

  
91
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
92
        <property name="dataSource" ref="repomanager.dataSource"/>
93
    </bean>
94

  
95
    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
96
    <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
97
    <bean class="eu.dnetlib.repo.manager.config.SwaggerConfig"/>
98

  
99 70
</beans>
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/PiWikServiceImpl.java
32 32
@Service("piwikService")
33 33
public class PiWikServiceImpl implements PiWikService {
34 34

  
35
    @Qualifier("repomanager.dataSource")
36 35
    @Autowired
37 36
    private DataSource dataSource;
38 37

  
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/config/GlobalSecurityConfiguration.java
1
package eu.dnetlib.repo.manager.config;
2

  
3
import org.springframework.context.annotation.Bean;
4
import org.springframework.context.annotation.Configuration;
5
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
6
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
7
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
8

  
9
@Configuration
10
@EnableGlobalMethodSecurity(prePostEnabled = true,proxyTargetClass = true)
11
public class GlobalSecurityConfiguration extends GlobalMethodSecurityConfiguration {
12

  
13
    @Bean
14
    public CommonsMultipartResolver multipartResolver(){
15
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
16
        multipartResolver.setMaxUploadSize(268435456);
17
        return multipartResolver;
18
    }
19
}
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/config/DatasourceConfiguration.java
1
package eu.dnetlib.repo.manager.config;
2

  
3
import org.apache.commons.dbcp.BasicDataSource;
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.jdbc.datasource.DataSourceTransactionManager;
9
import org.springframework.transaction.annotation.EnableTransactionManagement;
10

  
11
@Configuration
12
@EnableTransactionManagement
13
public class DatasourceConfiguration {
14

  
15
    private static Logger LOGGER = Logger.getLogger(DatasourceConfiguration.class);
16

  
17
    @Value("${repomanager.db.driverClassName}")
18
    private String driverClassname;
19

  
20
    @Value("${repomanager.db.url}")
21
    private String URL;
22

  
23
    @Value("${repomanager.db.username}")
24
    private String username;
25

  
26
    @Value("${repomanager.db.password}")
27
    private String password;
28

  
29
    @Bean
30
    public BasicDataSource dataSource(){
31
        BasicDataSource basicDataSource = new BasicDataSource();
32
        basicDataSource.setDriverClassName(driverClassname);
33
        basicDataSource.setUrl(URL);
34
        basicDataSource.setUsername(username);
35
        basicDataSource.setPassword(password);
36
        basicDataSource.setMaxIdle(10);
37
        basicDataSource.setMaxActive(100);
38
        basicDataSource.setMaxWait(1000);
39
        basicDataSource.setValidationQuery("SELECT 1;");
40
        basicDataSource.setTestOnBorrow(true);
41
        basicDataSource.setTestOnReturn(true);
42
        basicDataSource.setTestWhileIdle(true);
43
        basicDataSource.setTimeBetweenEvictionRunsMillis(1200000);
44
        basicDataSource.setMinEvictableIdleTimeMillis(1800000);
45
        basicDataSource.setMinEvictableIdleTimeMillis(5);
46
        basicDataSource.setPoolPreparedStatements(true);
47
        basicDataSource.setDefaultAutoCommit(true);
48

  
49
        return basicDataSource;
50
    }
51

  
52
    @Bean
53
    public DataSourceTransactionManager txManager(){
54
        DataSourceTransactionManager txManager = new DataSourceTransactionManager();
55
        txManager.setDataSource(dataSource());
56
        return txManager;
57
    }
58

  
59
}
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/config/CascadingPropertyLoader.java
52 52
		
53 53
		this.properties = properties;
54 54
	}
55
}
55
}
56

  
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/config/AaiSecurityConfiguration.java
1
package eu.dnetlib.repo.manager.config;
2

  
3
import org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod;
4
import org.mitre.oauth2.model.RegisteredClient;
5
import org.mitre.openid.connect.client.OIDCAuthenticationFilter;
6
import org.mitre.openid.connect.client.OIDCAuthenticationProvider;
7
import org.mitre.openid.connect.client.service.impl.*;
8
import org.mitre.openid.connect.config.ServerConfiguration;
9
import org.springframework.beans.factory.annotation.Value;
10
import org.springframework.context.annotation.Bean;
11
import org.springframework.context.annotation.Configuration;
12
import org.springframework.security.authentication.AuthenticationManager;
13
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
14
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
15
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
16
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
17
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
18
import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
19

  
20
import java.util.Collections;
21
import java.util.HashMap;
22
import java.util.HashSet;
23
import java.util.Map;
24

  
25
@Configuration
26
@EnableWebSecurity
27
public class AaiSecurityConfiguration extends WebSecurityConfigurerAdapter {
28

  
29
    @Value("${webapp.dev.front}")
30
    private String logoutSuccessUrl;
31

  
32
    @Value("${oidc.issuer}")
33
    private String oidcIssuer;
34

  
35
    @Value("${oidc.id}")
36
    private String oidcId;
37

  
38
    @Value("${oidc.secret}")
39
    private String oidcSecret;
40

  
41
    @Value("${oidc.dev.home}")
42
    private String oidcDevHome;
43

  
44
    @Value("${webapp.dev.front}")
45
    private String webAppFrontEnd;
46

  
47
    private Map<String, String> userRoles = new HashMap<String, String>(){{
48
        put("urn:geant:openaire.eu:group:Super+Administrator#aai.openaire.eu", "ROLE_ADMIN");
49
        put("urn:geant:openaire.eu:group:Content+Provider+Dashboard+Administrator#aai.openaire.eu","ROLE_PROVIDE_ADMIN");
50
    }};
51

  
52
    @Bean
53
    @Override
54
    public AuthenticationManager authenticationManagerBean() throws Exception {
55
        return authenticationManager();
56
    }
57

  
58
    @Override
59
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
60
        auth.authenticationProvider(openIdConnectAuthenticationProvider());
61
    }
62

  
63
    @Override
64
    protected void configure(HttpSecurity http) throws Exception {
65
        http.csrf().disable()
66
                .anonymous().disable()
67
                .authorizeRequests()
68
                .anyRequest().authenticated()
69
                .and()
70
                    .httpBasic()
71
                    .authenticationEntryPoint(authenticationEntryPoint())
72
                .and()
73
                    .logout().logoutUrl("/openid_logout")
74
                    .invalidateHttpSession(true)
75
                    .deleteCookies("openAIRESession")
76
                    .logoutSuccessUrl(logoutSuccessUrl)
77
                .and()
78
                    .addFilterBefore(openIdConnectAuthenticationFilter(), AbstractPreAuthenticatedProcessingFilter.class)
79
        ;
80
    }
81

  
82
    @Bean
83
    public OIDCAuthenticationProvider openIdConnectAuthenticationProvider(){
84
        OIDCAuthenticationProvider oidcProvider = new OIDCAuthenticationProvider();
85
        oidcProvider.setAuthoritiesMapper(authoritiesMapper());
86
        return oidcProvider;
87
    }
88

  
89
    @Bean
90
    public OpenAireProviderAuthoritiesMapper authoritiesMapper(){
91
        OpenAireProviderAuthoritiesMapper authoritiesMapper = new OpenAireProviderAuthoritiesMapper(userRoles);
92
        return authoritiesMapper;
93
    }
94

  
95
    @Bean
96
    public StaticServerConfigurationService staticServerConfigurationService(){
97
        StaticServerConfigurationService staticServerConfigurationService = new StaticServerConfigurationService();
98
        Map<String, ServerConfiguration> servers = new HashMap<>();
99
        servers.put(oidcIssuer, serverConfiguration());
100
        staticServerConfigurationService.setServers(servers);
101
        return staticServerConfigurationService;
102
    }
103

  
104
    @Bean
105
    public StaticClientConfigurationService staticClientConfigurationService(){
106
        StaticClientConfigurationService staticClientConfigurationService = new StaticClientConfigurationService();
107
        Map<String, RegisteredClient> clients = new HashMap<>();
108
        clients.put(oidcIssuer,registeredClient());
109
        staticClientConfigurationService.setClients(clients);
110
        return staticClientConfigurationService;
111
    }
112

  
113
    @Bean
114
    public RegisteredClient registeredClient(){
115
        RegisteredClient registeredClient = new RegisteredClient();
116
        registeredClient.setClientId(oidcId);
117
        registeredClient.setClientSecret(oidcSecret);
118
        registeredClient.setScope(new HashSet<>(Collections.singletonList("openid")));
119
        registeredClient.setTokenEndpointAuthMethod(AuthMethod.SECRET_BASIC);
120
        registeredClient.setRedirectUris(new HashSet<>(Collections.singletonList(oidcDevHome)));
121
        return registeredClient;
122
    }
123

  
124
    @Bean
125
    public StaticAuthRequestOptionsService staticAuthRequestOptionsService(){
126
        return new StaticAuthRequestOptionsService();
127
    }
128

  
129
    @Bean
130
    public PlainAuthRequestUrlBuilder plainAuthRequestUrlBuilder(){
131
        return new PlainAuthRequestUrlBuilder();
132
    }
133

  
134
    @Bean
135
    public ServerConfiguration serverConfiguration(){
136
        ServerConfiguration serverConfiguration = new ServerConfiguration();
137
        serverConfiguration.setIssuer(oidcIssuer);
138
        serverConfiguration.setAuthorizationEndpointUri(oidcIssuer+"authorize");
139
        serverConfiguration.setTokenEndpointUri(oidcIssuer+"token");
140
        serverConfiguration.setUserInfoUri(oidcIssuer+"userinfo");
141
        serverConfiguration.setJwksUri(oidcIssuer+"jwk");
142
        serverConfiguration.setRevocationEndpointUri(oidcIssuer+"revoke");
143
        return serverConfiguration;
144
    }
145

  
146
    @Bean
147
    public LoginUrlAuthenticationEntryPoint authenticationEntryPoint(){
148
        return new LoginUrlAuthenticationEntryPoint("/openid_connect_login");
149
    }
150

  
151

  
152
    @Bean
153
    public OIDCAuthenticationFilter openIdConnectAuthenticationFilter() throws Exception {
154
        OIDCAuthenticationFilter oidc = new OIDCAuthenticationFilter();
155
        oidc.setAuthenticationManager(authenticationManagerBean());
156
        oidc.setIssuerService(staticSingleIssuerService());
157
        oidc.setServerConfigurationService(staticServerConfigurationService());
158
        oidc.setClientConfigurationService(staticClientConfigurationService());
159
        oidc.setAuthRequestOptionsService(staticAuthRequestOptionsService());
160
        oidc.setAuthRequestUrlBuilder(plainAuthRequestUrlBuilder());
161
        oidc.setAuthenticationSuccessHandler(frontEndRedirect());
162
        return oidc;
163
    }
164

  
165
    @Bean
166
    public StaticSingleIssuerService staticSingleIssuerService(){
167
        StaticSingleIssuerService staticSingleIssuerService = new StaticSingleIssuerService();
168
        staticSingleIssuerService.setIssuer(oidcIssuer);
169
        return staticSingleIssuerService;
170
    }
171

  
172
    @Bean(initMethod = "init")
173
    public FrontEndLinkURIAuthenticationSuccessHandler frontEndRedirect(){
174
        FrontEndLinkURIAuthenticationSuccessHandler frontEnd = new FrontEndLinkURIAuthenticationSuccessHandler();
175
        frontEnd.setFrontEndURI(webAppFrontEnd);
176
        return frontEnd;
177
    }
178

  
179
}
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/config/RedisConfiguration.java
1
package eu.dnetlib.repo.manager.config;
2

  
3
import org.apache.log4j.Logger;
4
import org.springframework.beans.factory.annotation.Value;
5
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
6
import org.springframework.context.annotation.*;
7
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
8
import org.springframework.http.HttpHeaders;
9
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
10
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
11
import org.springframework.session.web.http.CookieSerializer;
12
import org.springframework.session.web.http.DefaultCookieSerializer;
13
import org.springframework.web.client.RestTemplate;
14

  
15
import javax.annotation.PostConstruct;
16

  
17
@Configuration
18
@EnableRedisHttpSession
19
@EnableAspectJAutoProxy
20
@EnableCircuitBreaker
21
@PropertySource(value = {"classpath:application.properties"} )
22
@ComponentScan(basePackages = {
23
        "org.eurocris.openaire.cris.validator.service",
24
        "eu.dnetlib.repo.manager.*"})
25
public class RedisConfiguration {
26

  
27
    private static Logger LOGGER = Logger.getLogger(RedisConfiguration.class);
28

  
29
    @Value("${redis.host}")
30
    private String host;
31

  
32
    @Value("${redis.port:6379}")
33
    private String port;
34

  
35
    @Value("${redis.password}")
36
    private String password;
37

  
38
    @Value("${aai.mode}")
39
    private String aai_mode;
40

  
41
    @PostConstruct
42
    private void init(){
43
        LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
44
    }
45

  
46
    @Bean
47
    public JedisConnectionFactory connectionFactory() {
48
        LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
49
        JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
50
        jedisConnectionFactory.setHostName(host);
51
        jedisConnectionFactory.setPort(Integer.parseInt(port));
52
        jedisConnectionFactory.setUsePool(true);
53
        if(password != null) jedisConnectionFactory.setPassword(password);
54
        return jedisConnectionFactory;
55
    }
56

  
57
    @Bean
58
    public CookieSerializer cookieSerializer() {
59
        DefaultCookieSerializer serializer = new DefaultCookieSerializer();
60
        serializer.setCookieName("openAIRESession");
61
        serializer.setCookiePath("/");
62
        if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
63
            serializer.setDomainName(".openaire.eu");
64
//        serializer.setDomainName(".athenarc.gr");
65
        LOGGER.info("Serializer : " + serializer);
66
        return serializer;
67
    }
68

  
69
    @Bean
70
    public RestTemplate restTemplate() {
71
        RestTemplate restTemplate = new RestTemplate();
72
        restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
73
        HttpHeaders httpHeaders = new HttpHeaders();
74
        httpHeaders.set("Content-Type", "application/json");
75
        return restTemplate;
76
    }
77

  
78

  
79
}
modules/uoa-repository-manager-service/trunk/src/main/resources/application-context.xml
8 8

  
9 9
    <context:annotation-config/>
10 10
    <context:component-scan base-package="eu.dnetlib.repo.manager.service.*"/>
11
    <tx:annotation-driven transaction-manager="txManager"/>
12 11

  
13 12
    <bean class="eu.dnetlib.repo.manager.config.CascadingPropertyLoader"
14 13
          id="propertyLoader">
......
29 28
                <value>classpath*:/application.properties</value>
30 29
                <value>classpath*:email-texts.properties</value>
31 30

  
32
<!--                <value>classpath*:dnet-site-wizard.properties</value>-->
33
<!--                <value>classpath*:dnet-site-override.properties</value>-->
34
<!--                <value>classpath*:dnet-wizard.properties</value>-->
35
<!--                <value>classpath*:dnet-override.properties</value>-->
36
<!--                <value>classpath*:dnet-validator-wizard.properties</value>-->
37
<!--                <value>classpath*:dnet-validator-override.properties</value>-->
38
<!--                <value>classpath*:dnet-site-force-override.properties</value>-->
39
<!--                <value>classpath*:dnet-force-override.properties</value>-->
31
                <!--                <value>classpath*:dnet-site-wizard.properties</value>-->
32
                <!--                <value>classpath*:dnet-site-override.properties</value>-->
33
                <!--                <value>classpath*:dnet-wizard.properties</value>-->
34
                <!--                <value>classpath*:dnet-override.properties</value>-->
35
                <!--                <value>classpath*:dnet-validator-wizard.properties</value>-->
36
                <!--                <value>classpath*:dnet-validator-override.properties</value>-->
37
                <!--                <value>classpath*:dnet-site-force-override.properties</value>-->
38
                <!--                <value>classpath*:dnet-force-override.properties</value>-->
40 39
            </list>
41 40
        </property>
42 41
    </bean>
43

  
44
    <bean id="repomanager.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
45
        <property name="driverClassName" value="${repomanager.db.driverClassName}" />
46
        <property name="url" value="${repomanager.db.url}" />
47
        <property name="username" value="${repomanager.db.username}" />
48
        <property name="password" value="${repomanager.db.password}" />
49
        <property name="maxIdle" value="10" />
50
        <property name="maxActive" value="100" />
51
        <property name="maxWait" value="10000" />
52
        <property name="validationQuery" value="SELECT 1;" />
53
        <property name="testOnBorrow" value="true" />
54
        <property name="testOnReturn" value="true" />
55
        <property name="testWhileIdle" value="true" />
56
        <property name="timeBetweenEvictionRunsMillis" value="1200000" />
57
        <property name="minEvictableIdleTimeMillis" value="1800000" />
58
        <property name="numTestsPerEvictionRun" value="5" />
59
        <property name="poolPreparedStatements" value="true" />
60
        <property name="defaultAutoCommit" value="true" />
61
    </bean>
62

  
63
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
64
        <property name="dataSource" ref="repomanager.dataSource"/>
65
    </bean>
66

  
67 42
</beans>
modules/uoa-repository-manager-service/trunk/src/main/resources/application.properties
141 141
search.api.baseAddress=https://beta.services.openaire.eu/search/v2/api
142 142
search.api.usagestats=https://services.openaire.eu/usagestats
143 143
search.api.usageEvents=http://beta.lbs.openaire.eu:8080/ajax/summary
144
api.baseAddress=http://beta.services.openaire.eu/openaire
144
api.baseAddress=https://dev-openaire.d4science.org/openaire
145 145
services.repo-manager.baseUrl=http://${container.hostname}:${container.port}/${container.context}
146 146
services.repo-manager.adminEmail=antleb@di.uoa.gr
147 147
services.repo-manager.repository.testing.mode=false
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/aai-security.xml
1
<beans xmlns="http://www.springframework.org/schema/beans"
2
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
       xmlns:security="http://www.springframework.org/schema/security"
4
       xmlns:util="http://www.springframework.org/schema/util"
5
       xsi:schemaLocation="http://www.springframework.org/schema/security
6
       http://www.springframework.org/schema/security/spring-security-3.2.xsd
7
		http://www.springframework.org/schema/beans
8
		http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
9
		http://www.springframework.org/schema/util
10
		http://www.springframework.org/schema/util/spring-util-4.1.xsd"
11
       default-autowire="byType">
12

  
13

  
14
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
15
        <property name="maxUploadSize" value="268435456"/>
16
    </bean>
17

  
18
    <!--<bean id="webexpressionHandler"
19
          class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>-->
20

  
21
    <security:global-method-security pre-post-annotations="enabled" proxy-target-class="true" authentication-manager-ref="authenticationManager"/>
22

  
23
    <security:http auto-config="false" use-expressions="true"
24
                   disable-url-rewriting="true" entry-point-ref="authenticationEntryPoint"
25
                   pattern="/**">
26

  
27
        <security:custom-filter before="PRE_AUTH_FILTER" ref="openIdConnectAuthenticationFilter" />
28

  
29
        <security:logout logout-url="/openid_logout" invalidate-session="true"
30
                         delete-cookies="openAIRESession" logout-success-url="${webapp.dev.front}"/>
31

  
32
    </security:http>
33

  
34

  
35
    <bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint" >
36
        <constructor-arg type="java.lang.String" value="/openid_connect_login"/>
37
    </bean>
38

  
39
    <security:authentication-manager alias="authenticationManager">
40
        <security:authentication-provider ref="openIdConnectAuthenticationProvider" />
41
    </security:authentication-manager>
42

  
43
    <bean id="openIdConnectAuthenticationProvider" class="org.mitre.openid.connect.client.OIDCAuthenticationProvider">
44
        <property name="authoritiesMapper">
45
            <bean class="eu.dnetlib.repo.manager.config.OpenAireProviderAuthoritiesMapper">
46
                <constructor-arg name="userRoles" ref="userRoles"/>
47
            </bean>
48
        </property>
49
    </bean>
50

  
51
    <util:map id="userRoles">
52
        <entry key="urn:geant:openaire.eu:group:Super+Administrator#aai.openaire.eu" value="ROLE_ADMIN"/>
53
        <entry key="urn:geant:openaire.eu:group:Content+Provider+Dashboard+Administrator#aai.openaire.eu" value="ROLE_PROVIDE_ADMIN"/>
54
    </util:map>
55

  
56

  
57
    <bean class="eu.dnetlib.repo.manager.config.FrontEndLinkURIAuthenticationSuccessHandler" id="frontEndRedirect"
58
          init-method="init">
59
        <property name="frontEndURI" value="${webapp.dev.front}"/>
60
    </bean>
61

  
62
    <!--
63
      -
64
      - The authentication filter
65
      -
66
      -->
67
    <bean id="openIdConnectAuthenticationFilter" class="org.mitre.openid.connect.client.OIDCAuthenticationFilter">
68
        <property name="authenticationManager" ref="authenticationManager" />
69

  
70
        <property name="issuerService" ref="staticIssuerService" />
71
        <property name="serverConfigurationService" ref="staticServerConfigurationService" />
72
        <property name="clientConfigurationService" ref="staticClientConfigurationService" />
73
        <property name="authRequestOptionsService" ref="staticAuthRequestOptionsService" />
74
        <property name="authRequestUrlBuilder" ref="plainAuthRequestUrlBuilder" />
75
        <property name="authenticationSuccessHandler" ref="frontEndRedirect"/>
76

  
77
    </bean>
78

  
79
    <!--
80
        Static issuer service, returns the same issuer for every request.
81
    -->
82
    <bean class="org.mitre.openid.connect.client.service.impl.StaticSingleIssuerService" id="staticIssuerService">
83
        <property name="issuer" value="${oidc.issuer}" />
84
    </bean>
85

  
86
    <!--
87
        Dynamic server configuration, fetches the server's information using OIDC Discovery.
88
    -->
89
    <bean class="org.mitre.openid.connect.client.service.impl.StaticServerConfigurationService" id="staticServerConfigurationService">
90
        <property name="servers">
91
            <map>
92
                <entry key="${oidc.issuer}">
93
                    <bean class="org.mitre.openid.connect.config.ServerConfiguration">
94
                        <property name="issuer" value="${oidc.issuer}" />
95
                        <property name="authorizationEndpointUri"	value="${oidc.issuer}authorize" />
96
                        <property name="tokenEndpointUri"	value="${oidc.issuer}token" />
97
                        <property name="userInfoUri" value="${oidc.issuer}userinfo" />
98
                        <property name="jwksUri" value="${oidc.issuer}jwk" />
99
                        <property name="revocationEndpointUri" value="${oidc.issuer}revoke" />
100
                    </bean>
101
                </entry>
102
            </map>
103
        </property>
104
    </bean>
105

  
106

  
107
    <!--
108
       Static Client Configuration. Configures a client statically by storing configuration on a per-issuer basis.
109
    -->
110
    <bean class="org.mitre.openid.connect.client.service.impl.StaticClientConfigurationService" id="staticClientConfigurationService">
111
        <property name="clients">
112
            <map>
113
                <entry key="${oidc.issuer}">
114
                    <bean class="org.mitre.oauth2.model.RegisteredClient">
115
                        <property name="clientId" value="${oidc.id}" />
116
                        <property name="clientSecret" value="${oidc.secret}" />
117
                        <property name="scope">
118
                            <set value-type="java.lang.String">
119
                                <value>openid</value>
120
                            </set>
121
                        </property>
122
                        <property name="tokenEndpointAuthMethod" value="SECRET_BASIC" />
123
                        <property name="redirectUris">
124
                            <set>
125
                                <value>${oidc.dev.home}</value>
126
                            </set>
127
                        </property>
128
                    </bean>
129
                </entry>
130
            </map>
131
        </property>
132
    </bean>
133

  
134

  
135
    <!--
136
      -
137
      -	Auth request options service: returns the optional components of the request
138
      -
139
      -->
140
    <bean class="org.mitre.openid.connect.client.service.impl.StaticAuthRequestOptionsService" id="staticAuthRequestOptionsService">
141
        <property name="options">
142
            <map>
143
                <!-- Entries in this map are sent as key-value parameters to the auth request -->
144
                <!--
145
                <entry key="display" value="page" />
146
                <entry key="max_age" value="30" />
147
                <entry key="prompt" value="none" />
148
                -->
149
            </map>
150
        </property>
151
    </bean>
152

  
153
    <!--
154
        Plain authorization request builder, puts all options as query parameters on the GET request
155
    -->
156
    <bean class="org.mitre.openid.connect.client.service.impl.PlainAuthRequestUrlBuilder" id="plainAuthRequestUrlBuilder" />
157
</beans>
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/applicationContext.xml
67 67
        </property>
68 68
    </bean>
69 69

  
70
    <bean id="repomanager.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
71
        <property name="driverClassName" value="${repomanager.db.driverClassName}" />
72
        <property name="url" value="${repomanager.db.url}" />
73
        <property name="username" value="${repomanager.db.username}" />
74
        <property name="password" value="${repomanager.db.password}" />
75
        <property name="maxIdle" value="10" />
76
        <property name="maxActive" value="100" />
77
        <property name="maxWait" value="10000" />
78
        <property name="validationQuery" value="SELECT 1;" />
79
        <property name="testOnBorrow" value="true" />
80
        <property name="testOnReturn" value="true" />
81
        <property name="testWhileIdle" value="true" />
82
        <property name="timeBetweenEvictionRunsMillis" value="1200000" />
83
        <property name="minEvictableIdleTimeMillis" value="1800000" />
84
        <property name="numTestsPerEvictionRun" value="5" />
85
        <property name="poolPreparedStatements" value="true" />
86
        <property name="defaultAutoCommit" value="true" />
87
    </bean>
88

  
89
    <tx:annotation-driven transaction-manager="txManager"/>
90

  
91
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
92
        <property name="dataSource" ref="repomanager.dataSource"/>
93
    </bean>
94

  
95 70
    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
96 71
    <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
97 72
    <bean class="eu.dnetlib.repo.manager.config.SwaggerConfig"/>
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/web.xml
9 9
        <param-name>contextConfigLocation</param-name>
10 10
        <param-value>
11 11
            /WEB-INF/applicationContext.xml
12
            /WEB-INF/aai-security.xml
13 12
        </param-value>
14 13
    </context-param>
15 14
    <context-param>

Also available in: Unified diff