I want to implement a velocity tool that provides a method in order to find out weather a user is logged in or not. I'm using the VelocityLayoutServlet in order to render the templates on each request.
My velocity-tools.xml looks like this:
<tools>
<toolbox scope="request">
<tool key="user" class="UserTool"/>
</toolbox>
</tools>
My tool class:
public class UserTool{
// How do I get this object?
private HttpServletRequest request;
public boolean isLoggedIn(){
return !request.getUserPrincipal().getName().isEmpty();
}
}
How do I get the HttpServletRequest
object within my tool?
FYI: I'm using container managed authentication.