class AuthRest {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @ApiOperation("Gets the current user token")
    public Response getCurrentUser(@Context ContainerRequestContext context) {
        String token = tokenManager.getTokenString(context);
        Optional<SignedJWT> tokenOptional = tokenManager.verifyToken(token);
        if (tokenOptional.isPresent()) {
            log.debug("Token found and verified.");
            log.debug("Writing payload to response.");
            SignedJWT signedToken = tokenOptional.get();
            return Response.ok(signedToken.getPayload().toString()).build();
        } else {
            log.debug("Token missing or unverified. Generating unauthenticated token.");
            SignedJWT signedToken = tokenManager.generateUnauthToken();
            log.debug("Writing payload to response.");
            return createResponse(signedToken);
        }
    }

}