Apache MyFaces 2.0 authentication and authorization

两盒软妹~` 提交于 2019-12-10 12:16:50

问题


I need to create a webapp that has a login system. the user should authenticate against a database. I want to save the userrole in session - or are there other (better) ways?

Furthermore there are areas for user access. Guest area, user area, admin area.

The question now is. How can I easily implement the authorization with jsf2.0? I don't want to test on each site, if the user is permitted to acces the site or not.

Is there a configuration in web.xml or faces-config.xml that test the cases?

Can someone show me a tutorial or sample code?

Thanks and best regards veote


回答1:


You can also look at options (Framewroks)

  1. Spring Security
  2. Apache Shiro
  3. Java EE Security Tutorial
  4. As already suggested Application Server provided Authentication/Authorization.
  5. Implement a Filter (Custom home grown logic for Authentication/Authorization)

Blogs covering AnA in JSF

  1. User session filter
  2. Access Control in JSF using a PhaseListener

Hope this helps




回答2:


I am not familiar with Websphere, but since it is a Java EE 6 compliant application server, you can create a JDBCRealm for this purpose. See this chapter of the Java EE 6 tutorial.




回答3:


You can try this approach, it uses PhaseListener to check if user has rights for accessing current site during the RESTORE_VIEW phase. It is quite easy to implement it and it's portable between different servers(opposite from realms)



来源:https://stackoverflow.com/questions/9738114/apache-myfaces-2-0-authentication-and-authorization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!