@Test @WithMockUser(authorities = { "VIEW_KEYS" }) public void getTokens() { ResponseEntity<List<Token>> response = tokensApiController.getTokens(); assertEquals(HttpStatus.OK, response.getStatusCode()); List<Token> tokens = response.getBody(); assertEquals(allTokens.size(), tokens.size()); Token token = tokens.iterator().next(); assertEquals(TokenStatus.OK, token.getStatus()); assertEquals("friendly-name", token.getName()); }
@PreAuthorize("hasAuthority('VIEW_KEYS')") @Override public ResponseEntity<List<Token>> getTokens() { List<TokenInfo> tokenInfos = tokenService.getAllTokens(); List<Token> tokens = tokenConverter.convert(tokenInfos); return new ResponseEntity<>(tokens, HttpStatus.OK); }
TokensApiController implements TokensApi { @PreAuthorize("hasAuthority('VIEW_KEYS')") @Override public ResponseEntity<List<Token>> getTokens() { List<TokenInfo> tokenInfos = tokenService.getAllTokens(); List<Token> tokens = tokenConverter.convert(tokenInfos); return new ResponseEntity<>(tokens, HttpStatus.OK); } }
TokensApiController implements TokensApi { @PreAuthorize("hasAuthority('VIEW_KEYS')") @Override public ResponseEntity<List<Token>> getTokens() { List<TokenInfo> tokenInfos = tokenService.getAllTokens(); List<Token> tokens = tokenConverter.convert(tokenInfos); return new ResponseEntity<>(tokens, HttpStatus.OK); } @Autowired  TokensApiController(KeyConverter keyConverter, KeyService keyService,
            TokenService tokenService,
            TokenConverter tokenConverter,
            ClientConverter clientConverter,
            KeyAndCertificateRequestService keyAndCertificateRequestService); }
TokensApiController implements TokensApi { @PreAuthorize("hasAuthority('VIEW_KEYS')") @Override public ResponseEntity<List<Token>> getTokens() { List<TokenInfo> tokenInfos = tokenService.getAllTokens(); List<Token> tokens = tokenConverter.convert(tokenInfos); return new ResponseEntity<>(tokens, HttpStatus.OK); } @Autowired  TokensApiController(KeyConverter keyConverter, KeyService keyService,
            TokenService tokenService,
            TokenConverter tokenConverter,
            ClientConverter clientConverter,
            KeyAndCertificateRequestService keyAndCertificateRequestService); @PreAuthorize("hasAuthority('VIEW_KEYS')") @Override ResponseEntity<List<Token>> getTokens(); @Override @PreAuthorize("hasAuthority('VIEW_KEYS')") ResponseEntity<Token> getToken(String id); @PreAuthorize("hasAuthority('ACTIVATE_DEACTIVATE_TOKEN')") @Override @AuditEventMethod(event = LOGIN_TOKEN) ResponseEntity<Token> loginToken(String id, TokenPassword tokenPassword); @PreAuthorize("hasAuthority('ACTIVATE_DEACTIVATE_TOKEN')") @Override @AuditEventMethod(event = LOGOUT_TOKEN) ResponseEntity<Token> logoutToken(String id); @PreAuthorize("hasAuthority('EDIT_TOKEN_FRIENDLY_NAME')") @Override @AuditEventMethod(event = UPDATE_TOKEN_NAME) ResponseEntity<Token> updateToken(String id, TokenName tokenName); @PreAuthorize("hasAuthority('GENERATE_KEY')") @Override @AuditEventMethod(event = GENERATE_KEY) ResponseEntity<Key> addKey(String tokenId, KeyLabel keyLabel); @Override @PreAuthorize("hasAuthority('GENERATE_KEY') " + " and (hasAuthority('GENERATE_AUTH_CERT_REQ') or hasAuthority('GENERATE_SIGN_CERT_REQ'))") @AuditEventMethod(event = GENERATE_KEY_AND_CSR) ResponseEntity<KeyWithCertificateSigningRequestId> addKeyAndCsr(String tokenId,
            KeyLabelWithCsrGenerate keyLabelWithCsrGenerate); }
TokensApiController implements TokensApi { @PreAuthorize("hasAuthority('VIEW_KEYS')") @Override public ResponseEntity<List<Token>> getTokens() { List<TokenInfo> tokenInfos = tokenService.getAllTokens(); List<Token> tokens = tokenConverter.convert(tokenInfos); return new ResponseEntity<>(tokens, HttpStatus.OK); } @Autowired  TokensApiController(KeyConverter keyConverter, KeyService keyService,
            TokenService tokenService,
            TokenConverter tokenConverter,
            ClientConverter clientConverter,
            KeyAndCertificateRequestService keyAndCertificateRequestService); @PreAuthorize("hasAuthority('VIEW_KEYS')") @Override ResponseEntity<List<Token>> getTokens(); @Override @PreAuthorize("hasAuthority('VIEW_KEYS')") ResponseEntity<Token> getToken(String id); @PreAuthorize("hasAuthority('ACTIVATE_DEACTIVATE_TOKEN')") @Override @AuditEventMethod(event = LOGIN_TOKEN) ResponseEntity<Token> loginToken(String id, TokenPassword tokenPassword); @PreAuthorize("hasAuthority('ACTIVATE_DEACTIVATE_TOKEN')") @Override @AuditEventMethod(event = LOGOUT_TOKEN) ResponseEntity<Token> logoutToken(String id); @PreAuthorize("hasAuthority('EDIT_TOKEN_FRIENDLY_NAME')") @Override @AuditEventMethod(event = UPDATE_TOKEN_NAME) ResponseEntity<Token> updateToken(String id, TokenName tokenName); @PreAuthorize("hasAuthority('GENERATE_KEY')") @Override @AuditEventMethod(event = GENERATE_KEY) ResponseEntity<Key> addKey(String tokenId, KeyLabel keyLabel); @Override @PreAuthorize("hasAuthority('GENERATE_KEY') " + " and (hasAuthority('GENERATE_AUTH_CERT_REQ') or hasAuthority('GENERATE_SIGN_CERT_REQ'))") @AuditEventMethod(event = GENERATE_KEY_AND_CSR) ResponseEntity<KeyWithCertificateSigningRequestId> addKeyAndCsr(String tokenId,
            KeyLabelWithCsrGenerate keyLabelWithCsrGenerate);  }