1. Add dependency for mails

2. Move preauthorize dependency to applicationContext
This commit is contained in:
Panagiotis Kanakakis 2018-03-30 10:18:24 +00:00
parent 0b62a37073
commit 4f5cab3a1f
7 changed files with 33 additions and 62 deletions

View File

@ -154,6 +154,12 @@
<version>20080701</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>

View File

@ -7,6 +7,7 @@ import eu.dnetlib.repo.manager.shared.*;
import io.swagger.annotations.Api;
import org.json.JSONException;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -17,11 +18,6 @@ import java.util.Map;
@RequestMapping(value = "/repository")
@Api(description = "Repository API", tags = {"repository"})
public interface RepositoryApi {
@RequestMapping(value = "/testAggregations", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
List<String> testAggregations() throws JSONException;
@RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody

View File

@ -125,49 +125,6 @@ public class RepositoryApiImpl implements RepositoryApi {
}
@Override
public List<String> testAggregations() throws JSONException {
int page = 0;
int size = 1000;
UriComponents uriComponents = UriComponentsBuilder
.fromHttpUrl(baseAddress + "/ds/list/")
.path("/{page}/{size}/")
.build().expand(page, size).encode();
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
List<String> ids = new ArrayList<>();
while (!rs.equals("[]")) {
ids.addAll(getIdsWithNonEmptyAggregations(rs));
LOGGER.debug("Checked " + (page + 1) * size + " records!");
page += 1;
uriComponents = UriComponentsBuilder
.fromHttpUrl(baseAddress + "/ds/list/")
.path("/{page}/{size}/")
.build().expand(page, size).encode();
rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
}
return ids;
}
private List<String> getIdsWithNonEmptyAggregations(String rs) throws JSONException {
JSONArray ids = new JSONArray(rs);
List<String> agg_ids = new ArrayList<>();
for (int i = 0; i < ids.length(); i++) {
String id = ids.getString(i);
Aggregations aggregations = getRepositoryAggregations(id);
if (aggregations.getAggregationHistory() != null)
agg_ids.add(id);
}
return agg_ids;
}
@Override
public Country[] getCountries() {
UriComponents uriComponents = UriComponentsBuilder
@ -348,6 +305,9 @@ public class RepositoryApiImpl implements RepositoryApi {
.build()
.encode();
String json_repository = Converter.repositoryObjectToJson(repository);
LOGGER.debug(json_repository);
HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
return repository;

View File

@ -35,9 +35,6 @@ public class UserApiImpl implements UserApi {
else
body.put("name",authentication.getUserInfo().getName());
for (GrantedAuthority authority : authentication.getAuthorities())
LOGGER.debug("Role: " + authority.getAuthority());
body.put("email",authentication.getUserInfo().getEmail());
List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
body.put("role",roles);

View File

@ -7,14 +7,15 @@
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"
default-autowire="byType">
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="268435456"/>
</bean>
<bean id="webexpressionHandler"
class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
<!--<bean id="webexpressionHandler"
class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>-->
<security:global-method-security pre-post-annotations="enabled" proxy-target-class="true" authentication-manager-ref="authenticationManager"/>
<!-- <security:global-method-security pre-post-annotations="enabled" proxy-target-class="true" authentication-manager-ref="authenticationManager"/>-->
<security:http auto-config="false" use-expressions="true"
disable-url-rewriting="true" entry-point-ref="authenticationEntryPoint"

View File

@ -4,6 +4,7 @@
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
@ -19,6 +20,7 @@
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
<bean id="maillib" class="eu.dnetlib.utils.MailLibrary" init-method="init">
<property name="mailhost" value="${services.validator.mail.host}"/>
<property name="smtpPort" value="${services.validator.mail.port}"/>

View File

@ -1,16 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"
>
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<security:global-method-security pre-post-annotations="enabled" proxy-target-class="true"
authentication-manager-ref="authenticationManager">
</security:global-method-security>
<bean id="webexpressionHandler"
class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
<context:annotation-config/>
<context:property-placeholder location="classpath*:/eu/**/application.properties" />
<context:component-scan base-package="eu.dnetlib.repo.manager.service.controllers"/>
<mvc:annotation-driven />
</beans:beans>
</beans>