use of org.graylog2.rest.models.users.responses.TokenList in project graylog2-server by Graylog2.
the class UsersResource method listTokens.
@GET
@Path("{username}/tokens")
@RequiresPermissions(RestPermissions.USERS_TOKENLIST)
@ApiOperation("Retrieves the list of access tokens for a user")
public TokenList listTokens(@ApiParam(name = "username", required = true) @PathParam("username") String username) {
final User user = _tokensCheckAndLoadUser(username);
final ImmutableList.Builder<Token> tokenList = ImmutableList.builder();
for (AccessToken token : accessTokenService.loadAll(user.getName())) {
tokenList.add(Token.create(token.getName(), token.getToken(), token.getLastAccess()));
}
return TokenList.create(tokenList.build());
}
Aggregations