Project

General

Profile

« Previous | Next » 

Revision 57907

New mapping for RepositorySnippet + Using SecurityContext to get the email of user

View differences:

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

  

Also available in: Unified diff