开发者

Best practice for the user authentication on JSF 2.0?

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_securi开发者_运维百科ty_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.


Just declare user as a session scoped managed bean and make use of the component's rendered attribute.

<h:inputText value="User Only Text" id="text" rendered="#{user != null}" />


But how can I use the j_security_check to check the the user from my database?

This article explains how to use HTTP FORM based authentication in conjunction with JDBC realms within Glassfish.

what is the best way to make a user login and show the valid user more options on the webpage than a non-user.

Basically, you need to check if the user has the appropriate role to see the "options". Have a look at ExternalContext#isUserInRole(String)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜