Question

I'm using JAAS to authenticate a client for a web app running on Tomcat.

I have a filter setup at that does some initialization of a user on the session at login. Nothing too overly complicated a simple is if user is not null type thing.

My understanding is JAAS will be called first, then my filter will be checked and then my JSP will be rendered

My question is, is there a way to match a url-pattern in a filter-mapping, to only run after a successful JAAS login?

<filter-mapping>
    <filter-name>MyFilter</filter-name>
    <url-pattern>/some/url/pattern/*</url-pattern>
</filter-mapping>

So in the above fileter-mapping what would go in the url-pattern? Or is this not possible?

Was it helpful?

Solution

A LoginModule placed at the end of your JAAS configuration) would allow you to execute extra actions on a successful login. The only drawback is that the way to retrieve the session from a LoginModule is not standard and depends on your application server.

Or you could simply make a test at the beginning of your filter to check if your user is connected and if your setup has already been done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top