This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit ae53fdd5 authored by Michael Breu's avatar Michael Breu
Browse files

Nochmals Hotfix für Access Check

parent e19a6a6f
1 merge request!251Development
...@@ -23,6 +23,8 @@ import java.net.MalformedURLException; ...@@ -23,6 +23,8 @@ import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.nio.file.Files; import java.nio.file.Files;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
...@@ -48,6 +50,7 @@ import org.springframework.web.bind.annotation.PathVariable; ...@@ -48,6 +50,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.HandlerMapping;
...@@ -396,14 +399,22 @@ public class ExerciseResource { ...@@ -396,14 +399,22 @@ public class ExerciseResource {
return ResponseEntity.ok(new URL(baseUrl + "/import/" + exerciseImportService.getTokenFromUrl(exerciseUrl)).toURI()); return ResponseEntity.ok(new URL(baseUrl + "/import/" + exerciseImportService.getTokenFromUrl(exerciseUrl)).toURI());
} }
@GetMapping("/exercises/source-authorization/{id}") @RequestMapping(value = "/exercises/source-authorization/**", method = RequestMethod.GET)
// @GetMapping("/exercises/source-authorization/{id}")
@SuppressWarnings("PMD.AvoidCatchingGenericException") @SuppressWarnings("PMD.AvoidCatchingGenericException")
public ResponseEntity<SearchResultDTO> getMembers(@PathVariable("id") String exerciseId) { public ResponseEntity<SearchResultDTO> getMembers(HttpServletRequest request) {
String exerciseId = "unknown";
try { try {
if (SecurityUtils.getCurrentUserLogin().isEmpty()) { if (SecurityUtils.getCurrentUserLogin().isEmpty()) {
ResponseEntity.status(HttpStatus.FORBIDDEN).build(); ResponseEntity.status(HttpStatus.FORBIDDEN).build();
} }
exerciseId =
URLDecoder.decode(
request.getRequestURL().toString().split("/exercises/source-authorization/")[1],
Charset.defaultCharset()
);
final Optional<SearchResultDTO> result = searchService.findExerciseById(ExerciseId.fromString(exerciseId)); final Optional<SearchResultDTO> result = searchService.findExerciseById(ExerciseId.fromString(exerciseId));
if (result.isEmpty()) { if (result.isEmpty()) {
return ResponseEntity.notFound().build(); return ResponseEntity.notFound().build();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment