• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Declarative security : mapping user to security roles

 
Pushker Chaubey
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pushker Chaubey
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bosun!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic