This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes implement Role based security in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "implement Role based security in JSF" Watch "implement Role based security in JSF" New topic
Author

implement Role based security in JSF

felix thomas
Ranch Hand

Joined: Jun 10, 2001
Posts: 89
hi,

Can anyone give me any example or idea how to implement role based user security in a web application using JSF. Any desgin pattern or articles will be highly appreciated.


Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

Most of my security is handled in a servlet filter. That basically controls who can visit what page. Now what you probably want to know more about is how to display or not display certain components on a form depending on the role of the user viewing the page. So the security filter has already been hit and now it's up to the components to decide if they will be visible or not.

Well, I don't use container managed roles and security. So the part of JSF that deals with that I cannot tell you about. What I do is I have a getRole() method or something similar in my User object or whatever you want to call it and I use an expression in my rendered attribute that determines the components rendered value of True or False. You can do this as fancy or as simple as you want to.

Is this in line with what you are wanting? Or am I totally off base?
felix thomas
Ranch Hand

Joined: Jun 10, 2001
Posts: 89
Hi,
You have got my point. But one question i have is the getRole() function that u call for each component(i.e. which have to be displayed or not), u call it everytime while the component is rendered , is it that way or some way else. Don't u think for calling getRole() simultaneous times will be slow if it databse is remote etc. Or is there any other method.

Can u shed light on the container managed security ?
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by felix thomas:
Don't u think for calling getRole() simultaneous times will be slow if it databse is remote etc.


Create a User object with an attribute "role" and getRole will return you the value from this attribute. You can create user object after successful user login/ authentication.
Don't make a database call in getRole().


- Varun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: implement Role based security in JSF
 
Similar Threads
JSF Security Issue
Security in JSF
Role Management in Struts
JSF/JSP
JSF, roles and security-constraint