@Test(expected = AccessDeniedException.class) @WithMockUser(authorities = "REVOKE_API_KEY") public void listApiKeysWrongAuthority() { apiKeysController.list(); verify(publicApiKeyDataConverter, times(0)).convert(Collections.singleton(any())); }
@RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") public ResponseEntity<Collection<PublicApiKeyData>> list() { Collection<PersistentApiKeyType> keys = apiKeyService.listAll(); return new ResponseEntity<>(publicApiKeyDataConverter.convert(keys), HttpStatus.OK); }
ApiKeysController { @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") public ResponseEntity<Collection<PublicApiKeyData>> list() { Collection<PersistentApiKeyType> keys = apiKeyService.listAll(); return new ResponseEntity<>(publicApiKeyDataConverter.convert(keys), HttpStatus.OK); } }
ApiKeysController { @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") public ResponseEntity<Collection<PublicApiKeyData>> list() { Collection<PersistentApiKeyType> keys = apiKeyService.listAll(); return new ResponseEntity<>(publicApiKeyDataConverter.convert(keys), HttpStatus.OK); } @Autowired  ApiKeysController(ApiKeyService apiKeyService, PublicApiKeyDataConverter publicApiKeyDataConverter); }
ApiKeysController { @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") public ResponseEntity<Collection<PublicApiKeyData>> list() { Collection<PersistentApiKeyType> keys = apiKeyService.listAll(); return new ResponseEntity<>(publicApiKeyDataConverter.convert(keys), HttpStatus.OK); } @Autowired  ApiKeysController(ApiKeyService apiKeyService, PublicApiKeyDataConverter publicApiKeyDataConverter); @PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @AuditEventMethod(event = API_KEY_CREATE) @PreAuthorize("hasAuthority('CREATE_API_KEY')") ResponseEntity<PublicApiKeyData> createKey(@RequestBody List<String> roles); @PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @AuditEventMethod(event = API_KEY_UPDATE) @PreAuthorize("hasAuthority('UPDATE_API_KEY')") ResponseEntity<PublicApiKeyData> updateKey(@PathVariable("id") long id,
            @RequestBody List<String> roles); @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") ResponseEntity<Collection<PublicApiKeyData>> list(); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") ResponseEntity revoke(@PathVariable("id") long id); }
ApiKeysController { @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") public ResponseEntity<Collection<PublicApiKeyData>> list() { Collection<PersistentApiKeyType> keys = apiKeyService.listAll(); return new ResponseEntity<>(publicApiKeyDataConverter.convert(keys), HttpStatus.OK); } @Autowired  ApiKeysController(ApiKeyService apiKeyService, PublicApiKeyDataConverter publicApiKeyDataConverter); @PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @AuditEventMethod(event = API_KEY_CREATE) @PreAuthorize("hasAuthority('CREATE_API_KEY')") ResponseEntity<PublicApiKeyData> createKey(@RequestBody List<String> roles); @PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @AuditEventMethod(event = API_KEY_UPDATE) @PreAuthorize("hasAuthority('UPDATE_API_KEY')") ResponseEntity<PublicApiKeyData> updateKey(@PathVariable("id") long id,
            @RequestBody List<String> roles); @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasAuthority('VIEW_API_KEYS')") ResponseEntity<Collection<PublicApiKeyData>> list(); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @AuditEventMethod(event = API_KEY_REMOVE) @PreAuthorize("hasAuthority('REVOKE_API_KEY')") ResponseEntity revoke(@PathVariable("id") long id); static final String API_KEYS_V1_PATH; }