Yesterday I asked a question about using tomcat authorization with httpd authentication. Here's the subject: "httpd authentication with tomcat authorization". I'm still awaiting a response, but I thought I'd come up with a solution anyway. I've got something working, but wanted to dig a bit deeper. Again, this is in Tomcat 6.0.41.
I overrode the UserDatabaseRealm to take advantage of its creation of the MemoryUserDatabase and all I needed to do was override the hasRole(). When asking it to print the database, I get a reasonable result: MemoryUserDatabase[id=UserDatabase,pathname=conf/tomcat-users.xml,groupCount=0,roleCount=11,userCount=9] And when asking it to give me users and roles with findUser() and findRole() it works fine. However, when I try to iterate over all the users and roles the iterator is always empty. This is true for the groups as well. Looking at the code from MemoryUserDatabase seems straight forward enough: public Iterator getUsers() { synchronized (users) { return (users.values().iterator()); } } But as I said, this iterator is always empty. I'm not sure how this is possible given the findUser(), that works, is equally simple: public User findUser(String username) { synchronized (users) { return ((User) users.get(username)); } } And the iterators seem to be empty either when first loaded from the UserDatabaseRealm in start() or when in the hasRole(). I'm not reporting a problem of my own, since I'm not using the iterators, but just wanted to report the strangeness that I'm seeing.