class TokensApiController implements TokensApi {

    @PreAuthorize("hasAuthority('GENERATE_KEY')")
    @Override
    @AuditEventMethod(event = GENERATE_KEY)
    public ResponseEntity<Key> addKey(String tokenId, KeyLabel keyLabel) {
        try {
            KeyInfo keyInfo = keyService.addKey(tokenId, keyLabel.getLabel());
            Key key = keyConverter.convert(keyInfo);
            return ApiUtil.createCreatedResponse("/api/keys/{keyId}", key, key.getId());
        } catch (TokenNotFoundException e) {
            throw new ResourceNotFoundException(e);
        } catch (ActionNotPossibleException e) {
            throw new ConflictException(e);
        }
    }

    @Autowired public  TokensApiController(KeyConverter keyConverter, KeyService keyService,
            TokenService tokenService,
            TokenConverter tokenConverter,
            ClientConverter clientConverter,
            KeyAndCertificateRequestService keyAndCertificateRequestService);

}