Short version: How do I get HttpServletRequest.getRemoteUser() to return a username when I use a custom authentication filter?
Long version:
I am modifying a Tomcat application that currently uses declarative protection (web.xml and tomcat-users.xml) instead of using a custom (written by me) authentication filter (derived from javax.servlet.Filter). There is a lot of information on how to do this, and it looks very simple.
However, an existing application calls HttpServletRequest.getRemoteUser() , and I assume that if I don't do something to set this property in my filter, it will return null. I can not find information on how to populate the getRemoteUser() property in the filter (no setRemoteUser() ). I found a message there in which it is recommended to wrap the request object in a filter. I will do this if necessary, but I hope it will be a less invasive way to achieve this.
Can anyone help?
java servlets servlet-filters
John fitzpatrick
source share