I am using tomcat 5.0 for hosting my application. I want to use declarative security for my application. I want my users to be stored in database. I can not store users in tomcat-users.xml as I want to be able to register new users from a screen. In database I will have table which will map these users to a set of roles (which have same name as the declared roles). But, how can I associate users to the declared roles defined in web.xml)?
I suppose container will only recognize roles defined in web.xml. How the "user to Db roles mapping " will get transformed to container's "user to security role mapping" so that when I invoke request.IsUserInRole("RoleName") it performs the required check on associated role.
Thanks in advance! [ November 25, 2008: Message edited by: Pushker Chaubey ]
Tomcat implements container managed security by connecting to a realm and using the data stored there to authenticate users. In this case your database table will contain the realm definition (user names, passwords, and roles) that you defined in tomcat-users.xml
You will probably need two tables. One that will have the logon ID and passwords, and another one to have the logon ID and roles for that ID.
Then you just configure tomcat to use the realm. I am sure if you search the web you can find more detailed information.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley