Skip to content

Instantly share code, notes, and snippets.

@william-tran
Created February 19, 2015 01:34
Show Gist options
  • Save william-tran/a2c18521ce5bed63dcba to your computer and use it in GitHub Desktop.
Save william-tran/a2c18521ce5bed63dcba to your computer and use it in GitHub Desktop.
Method security annotation
@RestController
@RequestMapping("/identity-zones")
public class IdentityZoneEndpoints {
@PreAuthorize("#id != @uaaIdentityZone.id")
@RequestMapping(value="{id}", method = GET)
public IdentityZone getIdentityZone(@PathVariable String id) {
return zoneDao.retrieve(id);
}
@ExceptionHandler(AccessDeniedException.class)
public ResponseEntity<Void> handleAccessDeniedException(MethodArgumentNotValidException e) {
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment