You know, I think it must have been 3 whole days since I've make a comment on why Do-It-Yourself security systems are not only an oxymoron, but expensive to boot.
OK. got that out of my system.
There are limits to what I can deduce here without having actual hands on the code and running app, but there are a couple of observations I can make.
One of which is that you're
testing for ".xhtml" strings. Normally, the URL doesn't have an "xhtml" in it, since that's a war resource file extension, not a URL component. My webapps normally end their JSF URLs with ".jsf", which web.xml has been instructed to resolve by locating and processing the corresponding ".xhtml" file. A lot of people confuse resource component names with URL component names, since syntactically, they're pretty much the same. However, functionally, they're as different as apples and tomatoes.
Which means, in short, that I'm not sure whether you're examining each and every URL that comes through the filter in your debugger. I think there should be some other indications than what you're reporting and I don't know if they're not there or if you simple don't see what you're not looking for. You might want to write all the URIs out to the log for debugging purposes.
Couple of basic programming hints, though. Doesn't affect behaviour but it makes code simpler.
1. If you say if( "yes".equals(authenticated) ), you'll save a few keysrtokes and a test, since "yes".equals(null) returns false. No need for a separate null test.
2.
You should be able to replace requestedPage.indexOf("pg2.xhtml")>-1 with requestedPage.endsWith("pg2.xhtml"). Again, a little tidier and perhaps a tad more efficient. However, as I said above, "xhtml" is normally a resource file suffix, not a URL component, so I'd expect this clause to always return false.