i search for the best way how i can make a user authentication in my JSF Webproject. I have found this very good Example from BalusC at stockoverflow (by the way Thank you BalusC). But i dont understand this System.
I have written a registration page. After the registration the user is into my database. But who can i use the j_security_check to check the the user from my database?
In my webproject i don’t have a site for users and for non-users. When a user is loged in so he see more options for example he can post a text. Who can i check this? Can i save the User Class with the userdata at the login and check:
if(user != null){
<h:inputText value="User Only Text" id="text" />
}
But i think this way is not very elegant. Also my Question is what is the best way to make a user login and show the valid user more options on the webpage than a non-user.
Thank you and sorry for my bad english.
This article explains how to use HTTP FORM based authentication in conjunction with JDBC realms within Glassfish.
Basically, you need to check if the user has the appropriate role to see the “options”. Have a look at
ExternalContext#isUserInRole(String)