简体   繁体   English

jsf 2.0过滤器替代

[英]jsf 2.0 filter alternative

since filter only work well when i use page-redirect=true on every commandbuttons' action, i am looking for a usable alternative. 由于过滤器仅在我在每个命令按钮的操作上使用page-redirect = true时才能很好地工作,因此我正在寻找可用的替代方法。

all i have now are two filters (which don't work well): 我现在所拥有的只是两个过滤器(效果不佳):

Filter A -> /pages/* (Filter checks if user is logged in) 过滤器A-> / pages / * (过滤器检查用户是否已登录)

Filter B -> /pages/restricted/* (filter checks if user has admin permissions) 过滤器B-> / pages / restricted / * (过滤器检查用户是否具有管理员权限)

because of the navigation-procedure by JSF they do not work, because the url is never changing. 由于JSF的导航过程,它们不起作用,因为url从未更改。

my question is: what is the best solution to restict page access without filters (is there a easy to use security (without complex roles etc.-> some users just have isAdmin=true)? or is there no problem at all when i use redirection? why does jsf then doesn't use it per default? 我的问题是: 什么是没有过滤器的限制页面访问的最佳解决方案 (有没有易于使用的安全性(没有复杂的角色等?->有些用户只是具有isAdmin = true)?或者当我使用时根本没有问题吗?重定向?为什么jsf默认不使用它?

Is using a prerenderview component an acceptible solution? 使用prerenderview组件是否可以接受? (if the user dosn't have enough rights, he should be navigated to a 404 page) (如果用户没有足够的权限,则应将他导航到404页面)

You're making a fundamental mistake. 您正在犯一个基本错误。 You should not be using command (POST) buttons/links for page-to-page navigation in first place, but you should be using direct (GET) buttons/links for that. 首先,您不应该使用命令(POST)按钮/链接进行页面间导航,而应该使用直接(GET)按钮/链接。

Long story short: 长话短说:

Considering this information and best practices, a servlet filter is still the best solution. 考虑到这些信息和最佳实践,servlet过滤器仍然是最佳解决方案。 All existing security frameworks are also based on the filter principle. 所有现有的安全框架也都基于过滤器原理。

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM