# Conflicts:
#	src/main/java/eu/dnetlib/repo/manager/service/security/AuthoritiesMapper.java
#	src/main/java/eu/dnetlib/repo/manager/service/security/AuthoritiesUpdater.java
This commit is contained in:
Lampros Smyrnaios 2023-01-13 12:22:28 +02:00
commit d4e4624a3f
36 changed files with 154 additions and 349 deletions

View File

@ -1,58 +0,0 @@
# This script can create the local "dnet-repository" and copy the "settings-dnet.xml" file there.
# It also builds the project, using the aforementioned settings file.
# Then it can run the project locally.
# By giving different options, the user can either install and run locally, just install (arg: 2) or just run (arg: 1) the project.
# For error-handling, we cannot use the "set -e" since: it has problems https://mywiki.wooledge.org/BashFAQ/105
# So we have our own function, for use when a single command fails.
handle_error () {
echo -e "$1"; exit $2
}
# Change the working directory to the script's directory, when running from another location.
cd "${0%/*}" || handle_error "Could not change-dir to this script's dir!" 1
if [[ $# -gt 1 ]]; then
echo -e "Wrong number of arguments given: ${#}\nPlease execute it like: installAndRun.sh <1 | 2 | 0 (optional)> "; exit 2
fi
justOneTask=0
if [[ $# -eq 1 ]]; then # If we have just 1 argument.
numbers_re='^[0-9]+$'
if ! [[ $1 =~ $numbers_re ]]; then # If the first argument is not numeric.
echo -e "Invalid, non-numeric argument given: ${1}\nPlease execute it like: installAndRun.sh <1 | 2 | 0 (optional)>"; exit 3
fi
if [[ $1 -lt 0 || $1 -gt 2 ]]; then # If the 1st argument does NOT equal to < 0 >, < 1 > or < 2 >.
echo -e "Invalid argument given: ${1}\nPlease execute it like: installAndRun.sh <1 | 2 | 0 (optional)>"; exit 4
fi
justOneTask=$1 # Assign <1>, <2> or <0>
fi
dnet_repo=~/.m2/repository-dnet45
settings_file=settings-dnet45.xml
if [[ justOneTask -eq 1 ]]; then
if [ ! -f ${dnet_repo}"/"${settings_file} ]; then
echo -e "The file \"${dnet_repo}/${settings_file}\" does not exist! Exiting.."; exit 5
fi
else
if [ ! -d ${dnet_repo} ]; then
mkdir ${dnet_repo} || exit 6
echo "Created the \"dnet_repo\": ${dnet_repo}"
fi
if [ ! -f ${dnet_repo}"/"${settings_file} ]; then
cp ${settings_file} ${dnet_repo}"/"${settings_file} || handle_error "The file \"${settings_file}\" could not be copied in directory \"${dnet_repo}\"! Exiting.." 7
echo "Copied the \"settings_file\" to: ${dnet_repo}/${settings_file}"
fi
mvn clean install -s ${dnet_repo}"/"${settings_file} || handle_error "The project could not be built. Exiting.." 8
fi
if [[ justOneTask -ne 2 ]]; then # If we do NOT want to "justInstall".
java -jar ./target/uoa-repository-manager-service.jar || handle_error "The project failed to execute or its execution was interrupted. Exiting.." 9
fi

136
pom.xml
View File

@ -22,7 +22,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
@ -30,15 +30,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
@ -47,11 +42,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
@ -60,20 +50,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.0.1</version>
</dependency>
-->
<!--
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
-->
<dependency>
<groupId>eu.dnetlib.dhp</groupId>
@ -123,36 +100,6 @@
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>-->
<!-- <artifactId>spring-webmvc</artifactId>-->
<!-- <version>${spring.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.hibernate</groupId>-->
<!-- <artifactId>hibernate-validator-annotation-processor</artifactId>-->
<!-- <version>4.1.0.Final</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>log4j</groupId>-->
<!-- <artifactId>log4j</artifactId>-->
<!-- <version>${log4j.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>eu.dnetlib</groupId>-->
<!-- <artifactId>uoa-domain</artifactId>-->
<!-- <version>[2.0.0-SNAPSHOT, 3.0.0)</version>-->
<!-- <exclusions>-->
<!-- <exclusion> &lt;!&ndash; declare the exclusion here &ndash;&gt;-->
<!-- <groupId>cglib</groupId>-->
<!-- <artifactId>cglib</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>log4j</groupId>-->
<!-- <artifactId>log4j</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-openaire-usage-stats-sushilite</artifactId>
@ -192,38 +139,6 @@
<version>2.7.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>xerces</groupId>-->
<!-- <artifactId>xercesImpl</artifactId>-->
<!-- <version>2.11.0</version>-->
<!-- </dependency>-->
<!--
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
<scope>compile</scope>
</dependency>
-->
<!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>-->
<!-- <artifactId>spring-context</artifactId>-->
<!-- <version>${spring.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>-->
<!-- <artifactId>spring-jdbc</artifactId>-->
<!-- <version>${spring.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
@ -265,13 +180,6 @@
<version>9.1-901.jdbc3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina -->
<!-- <dependency>-->
<!-- <groupId>org.apache.tomcat</groupId>-->
<!-- <artifactId>tomcat-catalina</artifactId>-->
<!-- <version>9.0.22</version>-->
<!-- </dependency>-->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
@ -293,14 +201,6 @@
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<version>2.5.1</version>
<type>pom</type>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency>
@ -324,13 +224,7 @@
<artifactId>cors-filter</artifactId>
<version>2.5</version>
</dependency>
<!--
<dependency>
<groupId>com.netflix.rxjava</groupId>
<artifactId>rxjava-core</artifactId>
<version>0.20.7</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
<dependency>
<groupId>javax.xml.ws</groupId>
@ -384,30 +278,6 @@
<scope>test</scope>
</dependency>
<!-- Enable micrometer >> -->
<!-- <dependency> &lt;!&ndash; TODO: remove this with ActuatorConfig class &ndash;&gt;-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-actuator</artifactId>-->
<!-- <version>1.3.5.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-actuator-autoconfigure</artifactId>-->
<!-- <version>2.1.18.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.micrometer</groupId>-->
<!-- <artifactId>micrometer-core</artifactId>-->
<!-- <version>1.7.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.7.2</version>
<scope>compile</scope>
</dependency>
<!-- << Enable micrometer -->
</dependencies>

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${env.HOME}/.m2/repository-dnet45</localRepository>
<pluginGroups>
<pluginGroup>org.apache.tomcat.maven</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>dnet4.0</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>dnet45-bootstrap-snapshot</id>
<name>D-Net 45 Bootstrap Snapshot</name>
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<layout>default</layout>
</repository>
<repository>
<id>dnet45-bootstrap-release</id>
<name>D-Net 45 Bootstrap Release</name>
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-release</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>
</settings>

View File

@ -1,6 +1,7 @@
package eu.dnetlib.repo.manager.config;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
@ -15,7 +16,7 @@ public class AsyncConfiguration implements AsyncConfigurer {
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return new AsyncUncaughtExceptionHandler() {
private final Logger logger = Logger.getLogger(getClass());
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {

View File

@ -1,7 +1,8 @@
package eu.dnetlib.repo.manager.config;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -12,7 +13,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
public class DatasourceConfiguration {
private static Logger logger = Logger.getLogger(DatasourceConfiguration.class);
private static Logger logger = LoggerFactory.getLogger(DatasourceConfiguration.class);
@Value("${services.provide.db.driverClassName}")
private String driverClassname;

View File

@ -1,8 +1,9 @@
package eu.dnetlib.repo.manager.config;
import com.google.gson.JsonParser;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
@ -22,10 +23,10 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
private String frontEndURI;
private static final Logger logger = Logger.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
private static final Logger logger = LoggerFactory.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
public void init() {
logger.debug("Front end uri : " + frontEndURI);
logger.debug("Front end uri : {}", frontEndURI);
}
@ -38,7 +39,7 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getEmail());
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getSub());
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
Matcher matcher = AUTH_REGEX.matcher(authOIDC.getAccessTokenValue());

View File

@ -3,9 +3,10 @@ package eu.dnetlib.repo.manager.config;
import com.google.gson.JsonArray;
import com.nimbusds.jwt.JWT;
import eu.dnetlib.repo.manager.service.security.AuthoritiesMapper;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
import org.mitre.openid.connect.model.UserInfo;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
@ -18,7 +19,7 @@ import java.util.Set;
@Component
public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
private static final Logger logger = Logger.getLogger(OpenAIREAuthoritiesMapper.class);
private static final Logger logger = LoggerFactory.getLogger(OpenAIREAuthoritiesMapper.class);
@Value("${services.provide.adminEmail}")
String adminEmail;
@ -33,7 +34,7 @@ public class OpenAIREAuthoritiesMapper implements OIDCAuthoritiesMapper {
} else if (userInfo.getSource().getAsJsonArray("eduperson_entitlement") != null) {
entitlements = userInfo.getSource().getAsJsonArray("eduperson_entitlement");
}
logger.debug("user info: " + userInfo + "\nentitlements: " + entitlements);
logger.debug("user info: {}\nentitlements: {}", userInfo, entitlements);
// FIXME: delete this if statement when super administrators are set
if (userInfo.getEmail() != null && userInfo.getEmail().equals(adminEmail)) {

View File

@ -1,6 +1,7 @@
package eu.dnetlib.repo.manager.config;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -15,7 +16,7 @@ import javax.annotation.PostConstruct;
@EnableRedisHttpSession
public class RedisConfiguration {
private static Logger logger = Logger.getLogger(RedisConfiguration.class);
private static final Logger logger = LoggerFactory.getLogger(RedisConfiguration.class);
@Value("${services.provide.redis.host}")
private String host;
@ -51,7 +52,7 @@ public class RedisConfiguration {
serializer.setCookieName("openAIRESession");
serializer.setCookiePath("/");
serializer.setDomainName(domain);
logger.info("Serializer : " + serializer);
logger.info("Cookie Serializer : {}", serializer);
return serializer;
}

View File

@ -6,9 +6,9 @@ import eu.dnetlib.repo.manager.exception.BrokerException;
import eu.dnetlib.repo.manager.exception.EndPointException;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.exception.ServerError;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.json.JSONException;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
@ -26,7 +26,7 @@ import java.net.UnknownHostException;
@Order(Ordered.HIGHEST_PRECEDENCE)
public class GenericControllerAdvice {
private Logger logger = LogManager.getLogger(GenericControllerAdvice.class);
private Logger logger = LoggerFactory.getLogger(GenericControllerAdvice.class);
@ResponseStatus(HttpStatus.NOT_FOUND)

View File

@ -6,9 +6,10 @@ import eu.dnetlib.repo.manager.domain.JobsOfUser;
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.json.JSONException;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
@ -20,7 +21,7 @@ import org.springframework.web.bind.annotation.*;
@Api(description = "Monitor API", tags = {"monitor"})
public class MonitorController {
private static final Logger logger = Logger.getLogger(MonitorController.class);
private static final Logger logger = LoggerFactory.getLogger(MonitorController.class);
@Autowired
private MonitorServiceImpl monitorService;

View File

@ -9,7 +9,8 @@ import eu.dnetlib.repo.manager.service.PiWikServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.MediaType;
@ -33,7 +34,7 @@ import java.util.List;
@Api(description = "Piwik API", tags = {"piwik"})
public class PiWikController {
private static final Logger logger = Logger.getLogger(PiWikController.class);
private static final Logger logger = LoggerFactory.getLogger(PiWikController.class);
@Autowired
private PiWikServiceImpl piWikService;

View File

@ -11,7 +11,8 @@ import io.micrometer.core.instrument.binder.system.UptimeMetrics;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.exporter.common.TextFormat;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
@ -24,7 +25,7 @@ import java.io.File;
@RestController
@RequestMapping("/actuator/prometheus")
public class PrometheusController { // TODO: remove this with migration to Spring Boot 2
private static final Logger logger = Logger.getLogger(PrometheusController.class);
private static final Logger logger = LoggerFactory.getLogger(PrometheusController.class);
private final PiWikService piWikService;
private final RepositoryService repositoryService;

View File

@ -11,9 +11,10 @@ import eu.dnetlib.repo.manager.service.RepositoryService;
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
import eu.dnetlib.repo.manager.utils.JsonUtils;
import io.swagger.annotations.Api;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.json.JSONException;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@ -35,7 +36,7 @@ import java.util.Map;
@Api(description = "Repository API", tags = {"repositories"})
public class RepositoryController {
private static final Logger logger = Logger.getLogger(RepositoryController.class);
private static final Logger logger = LoggerFactory.getLogger(RepositoryController.class);
private final RepositoryService repositoryService;

View File

@ -96,7 +96,7 @@ public class UserRoleController {
@RequestMapping(method = RequestMethod.GET, path = "/users/{email}/roles")
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER') and authentication.userInfo.email==#email")
public ResponseEntity<Collection<String>> getRolesByEmail(@PathVariable("email") String email) {
return ResponseEntity.ok(authorizationService.getUserRoles(email));
return ResponseEntity.ok(authorizationService.getUserRolesByEmail(email));
}

View File

@ -2,7 +2,8 @@ package eu.dnetlib.repo.manager.service;
import eu.dnetlib.enabling.datasources.common.AggregationInfo;
import eu.dnetlib.repo.manager.domain.AggregationHistoryResponse;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@ -20,7 +21,7 @@ import static eu.dnetlib.repo.manager.utils.DateUtils.getYear;
@Service("aggregationService")
public class AggregationServiceImpl implements AggregationService {
private static final Logger logger = Logger.getLogger(AggregationServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(AggregationServiceImpl.class);
@Value("${services.provide.clients.dsm}")

View File

@ -9,6 +9,8 @@ import eu.dnetlib.repo.manager.domain.broker.*;
import eu.dnetlib.repo.manager.exception.BrokerException;
import org.apache.commons.lang.NotImplementedException;
import org.json.JSONException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
@ -43,7 +45,7 @@ public class BrokerServiceImpl implements BrokerService {
@Value("${services.provide.topic_types.url}")
private String topicsURL;
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(BrokerServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(BrokerServiceImpl.class);
@Autowired
RestTemplate restTemplate;
@ -210,7 +212,7 @@ public class BrokerServiceImpl implements BrokerService {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
.queryParam("email", userEmail);
logger.debug(builder.build().encode().toUri());
logger.debug("{}", builder.build().encode().toUri());
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
try {
resp = restTemplate.exchange(

View File

@ -8,7 +8,8 @@ import eu.dnetlib.repo.manager.domain.broker.BrowseEntry;
import eu.dnetlib.repo.manager.exception.BrokerException;
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
import eu.dnetlib.repo.manager.utils.DateUtils;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -18,7 +19,7 @@ import java.util.List;
@Service("dashboardService")
public class DashboardServiceImpl implements DashboardService {
private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(DashboardServiceImpl.class);
@Autowired
private RepositoryService repositoryService;

View File

@ -6,8 +6,9 @@ import eu.dnetlib.repo.manager.domain.Repository;
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
import eu.dnetlib.utils.MailLibrary;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
@ -21,7 +22,7 @@ import java.util.stream.Collectors;
@Component("emailUtils")
public class EmailUtilsImpl implements EmailUtils {
private final static Logger logger = Logger.getLogger(EmailUtilsImpl.class);
private final static Logger logger = LoggerFactory.getLogger(EmailUtilsImpl.class);
private final MailLibrary mailLibrary;
private final RepositoryService repositoryService;

View File

@ -7,10 +7,11 @@ import eu.dnetlib.repo.manager.domain.Constants;
import eu.dnetlib.repo.manager.domain.JobsOfUser;
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
import gr.uoa.di.driver.util.ServiceLocator;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.eurocris.openaire.cris.validator.model.Job;
import org.eurocris.openaire.cris.validator.service.MapJobDao;
import org.json.JSONException;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -22,7 +23,7 @@ import java.util.stream.Collectors;
@Service("monitorService")
public class MonitorServiceImpl implements MonitorService {
private static final Logger logger = Logger.getLogger(MonitorServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(MonitorServiceImpl.class);
@Autowired
private MapJobDao crisJobs;
@ -53,9 +54,6 @@ public class MonitorServiceImpl implements MonitorService {
String validationStatus,
String includeJobsTotal) throws JSONException, ValidatorServiceException {
logger.debug("Getting jobs of user : " + user
+ "\n" + user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal);
/////////////////////////////////////////////////////////////////////////////////////////
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
/////////////////////////////////////////////////////////////////////////////////////////
@ -162,7 +160,7 @@ public class MonitorServiceImpl implements MonitorService {
try {
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
} catch (ValidatorServiceException e) {
logger.error(e);
logger.error(e.getMessage(), e);
}
return 0;
}
@ -175,7 +173,7 @@ public class MonitorServiceImpl implements MonitorService {
try {
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
} catch (ValidatorServiceException e) {
logger.error(e);
logger.error(e.getMessage(), e);
}
/////////////////////////////////////////////////////////////////////////////////////////
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //

View File

@ -7,7 +7,8 @@ import eu.dnetlib.repo.manager.domain.OrderByType;
import eu.dnetlib.repo.manager.domain.Repository;
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
@ -32,7 +33,7 @@ import java.util.Map;
@Service("piwikService")
public class PiWikServiceImpl implements PiWikService {
private static final Logger logger = Logger.getLogger(PiWikServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(PiWikServiceImpl.class);
@Autowired
@ -51,17 +52,19 @@ public class PiWikServiceImpl implements PiWikService {
private EmailUtils emailUtils;
private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;";
private static final String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;";
private final static String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)";
private static final String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)";
private final static String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site ";
private static final String UPDATE_PIWIK_INFO = "update piwik_site set siteid = ?, creationdate = now(), requestorname = ?, requestoremail = ?, validated = ?, repositoryname = ?, country = ?, authenticationtoken = ? where repositoryid = ?";
private final static String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
private static final String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site ";
private final static String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
private static final String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site ";
private RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"),
private static final String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
private final RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"),
rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"),
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
@ -79,9 +82,15 @@ public class PiWikServiceImpl implements PiWikService {
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority('REGISTERED_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
if (getPiwikSiteForRepo(piwikInfo.getRepositoryId()) == null) {
jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(),
piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()},
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
} else {
jdbcTemplate.update(UPDATE_PIWIK_INFO, new Object[]{piwikInfo.getSiteId(), piwikInfo.getRequestorName(), piwikInfo.getRequestorEmail(),
piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken(), piwikInfo.getRepositoryId()},
new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR});
}
return piwikInfo;
}

View File

@ -21,11 +21,12 @@ import eu.dnetlib.repo.manager.utils.Converter;
import eu.dnetlib.repo.manager.utils.DateUtils;
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
@ -49,7 +50,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Service("repositoryService")
public class RepositoryServiceImpl implements RepositoryService {
private static final Logger logger = Logger.getLogger(RepositoryServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(RepositoryServiceImpl.class);
private final AuthorizationService authorizationService;
private final RoleMappingService roleMappingService;
@ -339,8 +340,8 @@ public class RepositoryServiceImpl implements RepositoryService {
@Override
public List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException {
String userEmail = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail();
logger.debug("Retrieving repositories of authenticated user : " + userEmail);
logger.debug("Retrieving repositories of authenticated user : {}",
((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail());
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles());
return getRepositories(new ArrayList<>(repoIds));
}
@ -348,7 +349,7 @@ public class RepositoryServiceImpl implements RepositoryService {
@Override
public List<Repository> getRepositoriesOfUser(String userEmail, String page, String size) throws JSONException {
logger.debug("Retrieving repositories of authenticated user : " + userEmail);
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles(userEmail));
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRolesByEmail(userEmail));
return getRepositories(new ArrayList<>(repoIds));
}
@ -363,7 +364,7 @@ public class RepositoryServiceImpl implements RepositoryService {
int to = from + Integer.parseInt(size);
List<String> repoIds = new ArrayList<>();
if (userEmail != null && !"".equals(userEmail)) {
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles(userEmail)));
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRolesByEmail(userEmail)));
} else {
repoIds.addAll(roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles()));
}
@ -644,7 +645,7 @@ public class RepositoryServiceImpl implements RepositoryService {
.fromHttpUrl(baseAddress + "/ds/api/")
.path("/{id}")
.build().expand(id).encode();
logger.debug(uriComponents.toUri());
logger.debug("{}", uriComponents.toUri());
restTemplate.delete(uriComponents.toUri());
}

View File

@ -1,6 +1,7 @@
package eu.dnetlib.repo.manager.service;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
@ -19,7 +20,7 @@ import java.util.Objects;
@Service("statsService")
public class StatsServiceImpl implements StatsService {
private static final Logger logger = Logger.getLogger(StatsServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(StatsServiceImpl.class);
@Autowired
RestTemplate restTemplate;

View File

@ -3,6 +3,8 @@ package eu.dnetlib.repo.manager.service;
import eu.dnetlib.usagestats.sushilite.domain.Customer;
import eu.dnetlib.usagestats.sushilite.domain.ReportItem;
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
@ -25,7 +27,7 @@ public class SushiliteServiceImpl implements SushiliteService {
@Value("${services.provide.usagestats.sushiliteEndpoint}")
private String usagestatsSushiliteEndpoint;
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(SushiliteServiceImpl.class);
@Override

View File

@ -2,6 +2,8 @@ package eu.dnetlib.repo.manager.service;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.mitre.openid.connect.model.UserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.GrantedAuthority;
@ -16,8 +18,7 @@ import java.util.stream.Collectors;
@Service("userService")
public class UserServiceImpl implements UserService {
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
.getLogger(UserServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
@Override
public ResponseEntity<Object> login() {

View File

@ -12,11 +12,12 @@ import eu.dnetlib.repo.manager.exception.ValidationServiceException;
import eu.dnetlib.repo.manager.utils.CrisValidatorUtils;
import eu.dnetlib.repo.manager.utils.OaiTools;
import gr.uoa.di.driver.util.ServiceLocator;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.eurocris.openaire.cris.validator.model.Job;
import org.eurocris.openaire.cris.validator.service.JobExecutor;
import org.eurocris.openaire.cris.validator.service.MapJobDao;
import org.json.JSONException;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -58,7 +59,7 @@ public class ValidatorServiceImpl implements ValidatorService {
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
private static final Logger logger = Logger.getLogger(ValidatorServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(ValidatorServiceImpl.class);
@Autowired
private EmailUtils emailUtils;
@ -131,7 +132,7 @@ public class ValidatorServiceImpl implements ValidatorService {
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
} catch (ValidatorServiceException e) {
logger.error(e);
logger.error(e.getMessage(), e);
}
}
@ -161,7 +162,7 @@ public class ValidatorServiceImpl implements ValidatorService {
// this.getValidationService().submitValidationJob(jobForValidation);
} catch (Exception e) { // FIXME: replaced exception with log
// throw new ValidatorServiceException(e);
logger.error(e);
logger.error(e.getMessage(), e);
}
return jobForValidation;

View File

@ -7,8 +7,9 @@ import eu.dnetlib.repo.manager.domain.dto.Role;
import eu.dnetlib.repo.manager.domain.dto.User;
import eu.dnetlib.repo.manager.service.aai.registry.utils.RegistryUtils;
import eu.dnetlib.repo.manager.utils.HttpUtils;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.context.SecurityContextHolder;
@ -23,7 +24,7 @@ import java.util.Map;
@Service
public class RegistryCalls implements AaiRegistryService {
private static final Logger logger = Logger.getLogger(RegistryCalls.class);
private static final Logger logger = LoggerFactory.getLogger(RegistryCalls.class);
private final String coid;
public final HttpUtils httpUtils;

View File

@ -1,6 +1,7 @@
package eu.dnetlib.repo.manager.service.security;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
@ -14,7 +15,7 @@ import java.util.stream.Collectors;
@Service("roleMappingService")
public class AaiRoleMappingService implements RoleMappingService {
private static final Logger logger = Logger.getLogger(AaiRoleMappingService.class);
private static final Logger logger = LoggerFactory.getLogger(AaiRoleMappingService.class);
@Value("${services.provide.aai.registry.production:true}")
private boolean production;

View File

@ -2,10 +2,11 @@ package eu.dnetlib.repo.manager.service.security;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.nimbusds.jose.util.StandardCharset;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import com.nimbusds.jose.util.StandardCharset;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@ -15,7 +16,7 @@ import java.util.regex.Pattern;
public class AuthoritiesMapper {
private static final Logger logger = Logger.getLogger(AuthoritiesMapper.class);
private static final Logger logger = LoggerFactory.getLogger(AuthoritiesMapper.class);
private static final Pattern ENTITLEMENT_REGEX = Pattern.compile("urn:geant:openaire[.]eu:group:([^:]*):?(.*)?:role=member#aai[.]openaire[.]eu");
private AuthoritiesMapper() {

View File

@ -1,7 +1,8 @@
package eu.dnetlib.repo.manager.service.security;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
@ -21,7 +22,7 @@ import java.util.Map;
@Service
public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
private static final Logger logger = Logger.getLogger(AuthoritiesUpdater.class);
private static final Logger logger = LoggerFactory.getLogger(AuthoritiesUpdater.class);
@Autowired
FindByIndexNameSessionRepository sessions;
@ -30,7 +31,6 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
if (sessions != null) {
Map map = sessions.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, id);
if (map != null) {
logger.debug(map.values().toArray().length);
for ( Object sessionObject : map.values()) {
Session session = (Session) sessionObject;
logger.debug(session.getId());
@ -39,7 +39,6 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
Authentication authentication = securityContext.getAuthentication();
if (authentication instanceof OIDCAuthenticationToken) {
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
logger.debug(update.authorities(authOIDC.getAuthorities()));
securityContext.setAuthentication(new OIDCAuthenticationToken(authOIDC.getSub(), authOIDC.getIssuer(),
authOIDC.getUserInfo(), update.authorities(authOIDC.getAuthorities()), authOIDC.getIdToken(),
authOIDC.getAccessTokenValue(), authOIDC.getRefreshTokenValue()));
@ -65,7 +64,7 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth instanceof OIDCAuthenticationToken) {
OIDCAuthenticationToken oidcAuth = (OIDCAuthenticationToken) auth;
this.addRole(oidcAuth.getUserInfo().getEmail(), role);
this.addRole(oidcAuth.getUserInfo().getSub(), role);
} else {
throw new UnauthorizedClientException("User auth is not instance of OIDCAuthenticationToken");
}
@ -83,7 +82,7 @@ public class AuthoritiesUpdater extends HttpSessionSecurityContextRepository {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth instanceof OIDCAuthenticationToken) {
OIDCAuthenticationToken oidcAuth = (OIDCAuthenticationToken) auth;
this.removeRole(oidcAuth.getUserInfo().getEmail(), role);
this.removeRole(oidcAuth.getUserInfo().getSub(), role);
}
}

View File

@ -38,22 +38,22 @@ public interface AuthorizationService {
/**
* Add a user as admin to a resource.
*
* @param id Resource id
* @param resourceId Resource id
* @param email User email
* @return
* @throws ResourceNotFoundException
*/
boolean addAdmin(String id, String email) throws ResourceNotFoundException;
boolean addAdmin(String resourceId, String email) throws ResourceNotFoundException;
/**
* Remove user from resource admins.
*
* @param id Resource id
* @param resourceId Resource id
* @param email User email
* @return
* @throws ResourceNotFoundException
*/
boolean removeAdmin(String id, String email) throws ResourceNotFoundException;
boolean removeAdmin(String resourceId, String email) throws ResourceNotFoundException;
/**
@ -69,6 +69,6 @@ public interface AuthorizationService {
* @param email
* @return
*/
Collection<String> getUserRoles(String email);
Collection<String> getUserRolesByEmail(String email);
}

View File

@ -4,10 +4,10 @@ import com.google.gson.JsonElement;
import eu.dnetlib.repo.manager.domain.dto.User;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.mitre.openid.connect.model.UserInfo;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
@ -19,7 +19,7 @@ import java.util.List;
@Service("authorizationService")
public class AuthorizationServiceImpl implements AuthorizationService {
private static final Logger logger = LogManager.getLogger(AuthorizationServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(AuthorizationServiceImpl.class);
public static final String SUPER_ADMINISTRATOR = "SUPER_ADMINISTRATOR";
public static final String CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR = "CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR";
@ -70,7 +70,6 @@ public class AuthorizationServiceImpl implements AuthorizationService {
@Override
public List<User> getAdminsOfRepo(String repoId) {
List<String> userList = new ArrayList<>();
// find couId by role name
String role = roleMappingService.getRoleIdByRepoId(repoId);
@ -80,17 +79,17 @@ public class AuthorizationServiceImpl implements AuthorizationService {
@Override
public boolean addAdmin(String id, String email) throws ResourceNotFoundException {
public boolean addAdmin(String resourceId, String email) throws ResourceNotFoundException {
Integer coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
if (coPersonId != null) {
String role = roleMappingService.getRoleIdByRepoId(id);
String role = roleMappingService.getRoleIdByRepoId(resourceId);
Integer couId = aaiRegistryService.getCouId(role);
if (couId != null) {
Integer roleId = aaiRegistryService.getRoleId(coPersonId, couId);
aaiRegistryService.assignMemberRole(coPersonId, couId, roleId);
// Add role to user current authorities
authoritiesUpdater.addRole(email, roleMappingService.convertRepoIdToAuthority(id));
authoritiesUpdater.addRole(email, roleMappingService.convertRepoIdToAuthority(resourceId));
return true;
} else {
@ -102,10 +101,10 @@ public class AuthorizationServiceImpl implements AuthorizationService {
}
@Override
public boolean removeAdmin(String id, String email) throws ResourceNotFoundException {
public boolean removeAdmin(String resourceId, String email) throws ResourceNotFoundException {
Integer coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
if (coPersonId != null) {
String role = roleMappingService.getRoleIdByRepoId(id);
String role = roleMappingService.getRoleIdByRepoId(resourceId);
Integer couId = aaiRegistryService.getCouId(role);
Integer roleId = null;
if (couId != null) {
@ -115,7 +114,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
aaiRegistryService.removeMemberRole(coPersonId, couId, roleId);
// Remove role from user current authorities
authoritiesUpdater.removeRole(email, roleMappingService.convertRepoIdToAuthority(id));
authoritiesUpdater.removeRole(email, roleMappingService.convertRepoIdToAuthority(resourceId));
return true;
} else {
@ -130,14 +129,16 @@ public class AuthorizationServiceImpl implements AuthorizationService {
public Collection<String> getUserRoles() {
Collection<String> roles;
UserInfo userInfo = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo();
roles = getUserRoles(userInfo.getEmail());
roles = getUserRolesByEmail(userInfo.getEmail());
logger.debug(String.format("User Roles: %s", String.join(",", roles)));
if (logger.isDebugEnabled()) {
logger.debug("User Roles: {}", String.join(",", roles));
}
return roles;
}
@Override
public Collection<String> getUserRoles(String email) {
public Collection<String> getUserRolesByEmail(String email) {
int coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
List<Integer> list = new ArrayList<>();
for (JsonElement element : aaiRegistryService.getRolesWithStatus(coPersonId, AaiRegistryService.RoleStatus.ACTIVE)) {

View File

@ -1,13 +1,16 @@
package eu.dnetlib.repo.manager.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.repo.manager.domain.*;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
@ -20,12 +23,12 @@ import java.util.Objects;
@Component
public class Converter {
private static final Logger logger = Logger.getLogger(Converter.class);
private static final Logger logger = LoggerFactory.getLogger(Converter.class);
private final ObjectMapper objectMapper;
public Converter() {
objectMapper = new ObjectMapper();
objectMapper = new ObjectMapper()/*.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)*/;
}
public Repository toRepository(Object repositoryObject) {

View File

@ -2,7 +2,8 @@ package eu.dnetlib.repo.manager.utils;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -12,7 +13,7 @@ import java.util.Objects;
public class DateUtils {
private static final Logger logger = Logger.getLogger(DateUtils.class);
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
public static Date toDate(String date) {
@ -23,7 +24,7 @@ public class DateUtils {
try {
return formatter.parse(date);
} catch (ParseException e) {
logger.error(e);
logger.error(e.getMessage(), e);
}
return null;
}

View File

@ -4,7 +4,8 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
@ -16,7 +17,7 @@ import java.util.Map;
@Component
public class HttpUtils {
private static final Logger logger = Logger.getLogger(HttpUtils.class);
private static final Logger logger = LoggerFactory.getLogger(HttpUtils.class);
@Value("${services.provide.aai.registry.url}")
private String registryUrl;

View File

@ -1,7 +1,8 @@
package eu.dnetlib.repo.manager.utils;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.dom4j.io.DOMWriter;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import se.kb.oai.pmh.*;
@ -24,7 +25,7 @@ public class OaiTools {
disableSslVerification();
}
private static Logger logger = Logger.getLogger(OaiTools.class);
private static Logger logger = LoggerFactory.getLogger(OaiTools.class);
public static List<String> getSetsOfRepo(String baseUrl) throws Exception {
try {

View File

@ -6,11 +6,11 @@
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="LogToConsole"/>
</Root>
<Logger name="org.springframework.boot" level="error" additivity="false">
<AppenderRef ref="LogToConsole"/>
</Logger>
<Root level="error">
<AppenderRef ref="LogToConsole"/>
</Root>
</Loggers>
</Configuration>