I am creating some sort of RESTful API with basic auth. To handle the auth information I added a custom ContainerRequestFilter. This works quite good, but I want to set global information like the "username" of the caller. How can I set global/request-specific information or properties and get them within a "Controller" method?
//some filter
public class AuthFilter implements ContainerRequestFilter{
//...
@Override
public void filter( ContainerRequestContext requestContext ) throws IOException {
requestContext.setProperty("username", "someusername");
}
//...
}
//example "route-handler"
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Event> getEvents() {
//HOW to get the username property?!
}