Revision 57907
Added by Ioannis Diplas over 4 years ago
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java | ||
---|---|---|
8 | 8 |
import eu.dnetlib.repo.manager.service.RepositoryServiceImpl; |
9 | 9 |
import io.swagger.annotations.Api; |
10 | 10 |
import org.json.JSONException; |
11 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
|
11 | 12 |
import org.springframework.beans.factory.annotation.Autowired; |
12 | 13 |
import org.springframework.http.MediaType; |
13 | 14 |
import org.springframework.security.access.prepost.PostAuthorize; |
14 | 15 |
import org.springframework.security.access.prepost.PreAuthorize; |
15 | 16 |
import org.springframework.security.core.Authentication; |
17 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
16 | 18 |
import org.springframework.web.bind.annotation.*; |
17 | 19 |
|
18 | 20 |
import java.io.IOException; |
... | ... | |
49 | 51 |
public List<RepositorySnippet> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail, |
50 | 52 |
@PathVariable("page") String page, |
51 | 53 |
@PathVariable("size") String size) throws JSONException, IOException { |
54 |
userEmail = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
52 | 55 |
return repositoryService.getRepositoriesSnippetOfUser(userEmail, page, size); |
53 | 56 |
} |
54 | 57 |
|
... | ... | |
172 | 175 |
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail, |
173 | 176 |
@PathVariable("page") String page, |
174 | 177 |
@PathVariable("size") String size) throws JSONException { |
178 |
userEmail = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
175 | 179 |
return repositoryService.getUrlsOfUserRepos(userEmail, page, size); |
176 | 180 |
} |
177 | 181 |
|
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/BrokerController.java | ||
---|---|---|
7 | 7 |
import io.swagger.annotations.Api; |
8 | 8 |
import io.swagger.annotations.ApiParam; |
9 | 9 |
import org.json.JSONException; |
10 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
|
10 | 11 |
import org.springframework.beans.factory.annotation.Autowired; |
11 | 12 |
import org.springframework.http.MediaType; |
12 | 13 |
import org.springframework.http.ResponseEntity; |
13 | 14 |
import org.springframework.security.access.prepost.PreAuthorize; |
15 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
14 | 16 |
import org.springframework.web.bind.annotation.*; |
15 | 17 |
|
16 | 18 |
import java.io.IOException; |
... | ... | |
35 | 37 |
@ApiParam(value = "Include shared datasources", required = true , defaultValue = "false") String includeShared, |
36 | 38 |
@RequestParam("includeByOthers") |
37 | 39 |
@ApiParam(value = "Include datasources of other", required = true,defaultValue = "false") String includeByOthers) throws JSONException { |
40 |
user = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
38 | 41 |
return brokerService.getDatasourcesOfUser(user, includeShared, includeByOthers); |
39 | 42 |
} |
40 | 43 |
|
... | ... | |
75 | 78 |
@ResponseBody |
76 | 79 |
@PreAuthorize("hasRole('ROLE_USER')") |
77 | 80 |
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException{ |
81 |
userEmail = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
78 | 82 |
return brokerService.getSimpleSubscriptionsOfUser(userEmail); |
79 | 83 |
} |
80 | 84 |
|
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/ValidatorController.java | ||
---|---|---|
12 | 12 |
import io.swagger.annotations.Api; |
13 | 13 |
import io.swagger.annotations.ApiParam; |
14 | 14 |
import org.json.JSONException; |
15 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
|
15 | 16 |
import org.springframework.beans.factory.annotation.Autowired; |
16 | 17 |
import org.springframework.http.MediaType; |
17 | 18 |
import org.springframework.http.ResponseEntity; |
18 | 19 |
import org.springframework.security.access.prepost.PreAuthorize; |
20 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
19 | 21 |
import org.springframework.web.bind.annotation.*; |
20 | 22 |
|
21 | 23 |
import java.util.List; |
... | ... | |
45 | 47 |
consumes = MediaType.APPLICATION_JSON_VALUE, |
46 | 48 |
produces = MediaType.APPLICATION_JSON_VALUE) |
47 | 49 |
@ResponseBody |
48 |
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
|
50 |
@PreAuthorize("hasRole('ROLE_USER')") |
|
49 | 51 |
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email, |
50 | 52 |
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException { |
53 |
email = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
51 | 54 |
return validatorService.reSubmitJobForValidation(email, jobId); |
52 | 55 |
} |
53 | 56 |
|
... | ... | |
87 | 90 |
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo, |
88 | 91 |
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus |
89 | 92 |
) throws ValidatorServiceException { |
93 |
user = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
90 | 94 |
return validatorService.getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus); |
91 | 95 |
} |
92 | 96 |
|
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java | ||
---|---|---|
7 | 7 |
import eu.dnetlib.repo.manager.service.RepositoryService; |
8 | 8 |
import io.swagger.annotations.Api; |
9 | 9 |
import org.json.JSONException; |
10 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
|
10 | 11 |
import org.springframework.beans.factory.annotation.Autowired; |
11 | 12 |
import org.springframework.http.MediaType; |
12 | 13 |
import org.springframework.security.access.prepost.PreAuthorize; |
14 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
13 | 15 |
import org.springframework.web.bind.annotation.*; |
14 | 16 |
|
15 | 17 |
import java.util.List; |
... | ... | |
38 | 40 |
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail, |
39 | 41 |
@PathVariable("page") String page, |
40 | 42 |
@PathVariable("size") String size) throws JSONException { |
43 |
userEmail = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
41 | 44 |
return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size); |
42 | 45 |
} |
43 | 46 |
|
... | ... | |
84 | 87 |
public BrokerSummary getBrokerSummary( |
85 | 88 |
@PathVariable("email") String email, |
86 | 89 |
@PathVariable("ds_name") String datasourceName) throws BrokerException { |
90 |
email = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
87 | 91 |
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(email), brokerService.getTopicsForDatasource(datasourceName)); |
88 | 92 |
} |
89 | 93 |
|
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/MonitorController.java | ||
---|---|---|
8 | 8 |
import io.swagger.annotations.ApiParam; |
9 | 9 |
import org.apache.log4j.Logger; |
10 | 10 |
import org.json.JSONException; |
11 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
|
11 | 12 |
import org.springframework.beans.factory.annotation.Autowired; |
12 | 13 |
import org.springframework.http.MediaType; |
13 | 14 |
import org.springframework.security.access.prepost.PreAuthorize; |
15 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
14 | 16 |
import org.springframework.web.bind.annotation.*; |
15 | 17 |
|
16 | 18 |
@RestController |
... | ... | |
37 | 39 |
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo, |
38 | 40 |
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = false) String validationStatus, |
39 | 41 |
@RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException { |
40 |
|
|
42 |
user = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
41 | 43 |
return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal); |
42 | 44 |
} |
43 | 45 |
|
... | ... | |
47 | 49 |
public int getJobsOfUserPerValidationStatus(@RequestBody String user, |
48 | 50 |
@RequestBody String jobType, |
49 | 51 |
@RequestBody String validationStatus) throws JSONException { |
52 |
user = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
50 | 53 |
return monitorService.getJobsOfUserPerValidationStatus(user, jobType, validationStatus); |
51 | 54 |
} |
52 | 55 |
|
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySnippet.java | ||
---|---|---|
3 | 3 |
|
4 | 4 |
import eu.dnetlib.domain.data.PiwikInfo; |
5 | 5 |
|
6 |
import java.util.Date; |
|
7 |
|
|
6 | 8 |
public class RepositorySnippet { |
7 | 9 |
|
8 | 10 |
private String id; |
... | ... | |
15 | 17 |
private String registrationdate; |
16 | 18 |
private String logoUrl; |
17 | 19 |
private String description; |
20 |
private String fullTextDownload; |
|
21 |
private String consentTermsOfUse; |
|
22 |
private Date consentTermsOfUseDate; |
|
18 | 23 |
|
19 | 24 |
|
20 | 25 |
private PiwikInfo piwikInfo; |
... | ... | |
108 | 113 |
public void setDescription(String description) { |
109 | 114 |
this.description = description; |
110 | 115 |
} |
116 |
|
|
117 |
public String getFullTextDownload() { |
|
118 |
return fullTextDownload; |
|
119 |
} |
|
120 |
|
|
121 |
public void setFullTextDownload(String fullTextDownload) { |
|
122 |
this.fullTextDownload = fullTextDownload; |
|
123 |
} |
|
124 |
|
|
125 |
public String getConsentTermsOfUse() { |
|
126 |
return consentTermsOfUse; |
|
127 |
} |
|
128 |
|
|
129 |
public void setConsentTermsOfUse(String consentTermsOfUse) { |
|
130 |
this.consentTermsOfUse = consentTermsOfUse; |
|
131 |
} |
|
132 |
|
|
133 |
public Date getConsentTermsOfUseDate() { |
|
134 |
return consentTermsOfUseDate; |
|
135 |
} |
|
136 |
|
|
137 |
public void setConsentTermsOfUseDate(Date consentTermsOfUseDate) { |
|
138 |
this.consentTermsOfUseDate = consentTermsOfUseDate; |
|
139 |
} |
|
111 | 140 |
} |
Also available in: Unified diff
New mapping for RepositorySnippet + Using SecurityContext to get the email of user