• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Declarative security : mapping user to security roles

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bosun!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic