final String sessionId = token.getPrincipal().toString();
response = api.get(UserResponse.class)
.path("/users/{0}", token.getUsername())
.session(sessionId)
.execute();
final User user = userFactory.fromResponse(response, sessionId);
UserService.setCurrent(user);
user.setSubject(new Subject.Builder(SecurityUtils.getSecurityManager())
.principals(new SimplePrincipalCollection(user.getName(), "REST realm"))
.authenticated(true)
.buildSubject());
} catch (IOException e) {
throw new Graylog2ServerUnavailableException("Could not connect to Graylog2 Server.", e);
} catch (APIException e) {