Project

General

Profile

« Previous | Next » 

Revision 61371

1. changed user roles defined in the project to authorities given by the aai.
2. created method returning user roles with desired status (active, deleted).

View differences:

RepositoryController.java
63 63
    @RequestMapping(value = "/getRepositoriesOfUser/{page}/{size}", method = RequestMethod.GET,
64 64
            produces = MediaType.APPLICATION_JSON_VALUE)
65 65
    @ResponseBody
66
    @PreAuthorize("hasRole('ROLE_USER')")
66
    @PreAuthorize("hasAuthority('REGISTERED_USER')")
67 67
    public List<RepositorySnippet> getRepositoriesSnippetOfUser(
68 68
            @PathVariable("page") String page,
69 69
            @PathVariable("size") String size) throws JSONException, IOException {
......
73 73
    @RequestMapping(value = "/user/repositories/{page}/{size}", method = RequestMethod.GET,
74 74
            produces = MediaType.APPLICATION_JSON_VALUE)
75 75
    @ResponseBody
76
    @PreAuthorize("hasRole('ROLE_USER')")
76
    @PreAuthorize("hasAuthority('REGISTERED_USER')")
77 77
    public List<Repository> getRepositoriesOfUser(
78 78
            @PathVariable("page") String page,
79 79
            @PathVariable("size") String size) throws JSONException, IOException {
......
83 83
    @RequestMapping(value = "/searchRegisteredRepositories/{page}/{size}", method = RequestMethod.GET,
84 84
            produces = MediaType.APPLICATION_JSON_VALUE)
85 85
    @ResponseBody
86
    @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')")
86
    @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
87 87
    public List<RepositorySnippet> searchRegisteredRepositories(@RequestParam(name = "country", required = false) String country,
88 88
                                                                @RequestParam(name = "typology", required = false) String typology,
89 89
                                                                @RequestParam(name = "englishName", required = false) String englishName,
......
100 100
    @RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
101 101
            produces = MediaType.APPLICATION_JSON_VALUE)
102 102
    @ResponseBody
103
    @PostAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_PROVIDE_ADMIN') or @authorizationService.isMemberOf(#id) or (returnObject.registeredBy=='null' and hasRole('ROLE_USER'))")
103
    @PostAuthorize("hasAnyRole('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (returnObject.registeredBy=='null' and hasAuthority('REGISTERED_USER'))")
104 104
    public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException, ResourceNotFoundException {
105 105
        Repository repo = repositoryService.getRepositoryById(id);
106 106

  
......
137 137
    @RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
138 138
            produces = MediaType.APPLICATION_JSON_VALUE)
139 139
    @ResponseBody
140
    @PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or @authorizationService.isMemberOf(#id) or (@repositoryService.getRepositoryById(#id).registeredBy=='null' and hasRole('ROLE_USER'))")
140
    @PostAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (@repositoryService.getRepositoryById(#id).registeredBy=='null' and hasAuthority('REGISTERED_USER'))")
141 141
    public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
142 142
        return repositoryService.getRepositoryInterface(id);
143 143
    }
......
145 145
    @RequestMapping(value = "/addRepository", method = RequestMethod.POST,
146 146
            consumes = MediaType.APPLICATION_JSON_VALUE)
147 147
    @ResponseBody
148
//    @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole(@authorizationService.convertRepoIdToRoleId(#repository.id)) or hasRole(@authorizationService.convertRepoIdToRoleId(returnObject.id)))")
149
    @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or hasRole('ROLE_USER')")
148
//    @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority(@authorizationService.convertRepoIdToRoleId(#repository.id)) or hasAuthority(@authorizationService.convertRepoIdToRoleId(returnObject.id)))")
149
    @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER')")
150 150
    public Repository addRepository(@RequestParam("datatype") String datatype,
151 151
                                    @RequestBody Repository repository) throws Exception {
152 152

  
......
177 177
    @RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
178 178
            consumes = MediaType.APPLICATION_JSON_VALUE)
179 179
    @ResponseBody
180
    @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or @authorizationService.isMemberOf(#repository.id)")
180
    @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repository.id)")
181 181
    public Repository updateRepository(@RequestBody Repository repository, Authentication authentication) throws Exception {
182 182
        return repositoryService.updateRepository(repository, authentication);
183 183
    }
......
192 192
    @RequestMapping(value = "/addInterface", method = RequestMethod.POST,
193 193
            consumes = MediaType.APPLICATION_JSON_VALUE)
194 194
    @ResponseBody
195
    @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or @authorizationService.isMemberOf(#id)")
195
    @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
196 196
    public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
197 197
                                                      @RequestParam("id") String id,
198 198
                                                      @RequestParam("registeredBy") String registeredBy,
......
204 204
    @RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/", method = RequestMethod.GET,
205 205
            produces = MediaType.APPLICATION_JSON_VALUE)
206 206
    @ResponseBody
207
    @PreAuthorize("hasRole('ROLE_USER')")
207
    @PreAuthorize("hasAuthority('REGISTERED_USER')")
208 208
    public List<String> getUrlsOfUserRepos(@PathVariable("page") String page, @PathVariable("size") String size) {
209 209
        return repositoryService.getUrlsOfUserRepos(((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(), page, size);
210 210
    }
......
248 248
    @RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
249 249
            consumes = MediaType.APPLICATION_JSON_VALUE)
250 250
    @ResponseBody
251
    @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or @authorizationService.isMemberOf(#id)")
251
    @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
252 252
    public RepositoryInterface updateRepositoryInterface(@RequestParam("id") String id,
253 253
                                                         @RequestParam("registeredBy") String registeredBy,
254 254
                                                         @RequestParam(value = "comment", required = false) String comment,
......
264 264
     * Get all the admins of the repository
265 265
     */
266 266
    @RequestMapping(method = RequestMethod.GET, path = "{id}/admins")
267
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN', 'ROLE_PROVIDE_ADMIN') or @authorizationService.isMemberOf(#id)")
267
    @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
268 268
    public ResponseEntity<List<User>> getAdminsOfARepo(@PathVariable("id") String id) {
269 269
        return new ResponseEntity<>(authorizationService.getAdminsOfRepo(id), HttpStatus.OK);
270 270
    }
......
273 273
     * Subscribe to repo by email
274 274
     */
275 275
    @RequestMapping(method = RequestMethod.POST, path = "{id}/admins")
276
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN', 'ROLE_PROVIDE_ADMIN') or @authorizationService.isMemberOf(#id)")
276
    @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
277 277
    public Response subscribeByEmail(@PathVariable("id") String id, @RequestBody String email) throws ResourceNotFoundException {
278 278
        authorizationService.addAdmin(id, email);
279 279
        return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been assigned").toString()).type(javax.ws.rs.core.MediaType.APPLICATION_JSON).build();
......
283 283
     * Unsubscribe from repo by email
284 284
     */
285 285
    @RequestMapping(method = RequestMethod.DELETE, path = "{id}/admins/{email:.+}")
286
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN', 'ROLE_PROVIDE_ADMIN') or @authorizationService.isMemberOf(#id)")
286
    @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id)")
287 287
    public ResponseEntity<Void> unsubscribeByEmail(@PathVariable("id") String id, @PathVariable("email") String email) throws ResourceNotFoundException {
288 288
        authorizationService.removeAdmin(id, email);
289 289
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);

Also available in: Unified diff