我希望在用户登录系统后控制访问权限.
例如:
administrator : can add, delete and give rights to employee
employee : fill forms only
...
Run Code Online (Sandbox Code Playgroud)
因此,在知道用户具有哪些权限后,检查数据库,我想限制该用户可以看到和执行的操作.有一个简单的方法吗?
编辑
@WebFilter("/integra/user/*")
public class LoginFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
HttpServletRequest req = (HttpServletRequest) request;
Authorization authorization = (Authorization) req.getSession().getAttribute("authorization");
if (authorization != null && authorization.isLoggedIn()) {
// User is logged in, so just continue request.
chain.doFilter(request, response);
} else {
// User is not logged in, so redirect to …Run Code Online (Sandbox Code Playgroud) 我想根据用户访问权限限制对某些JSF页面的访问.如何在JSF中做到这一点?我找到了两个链接:通过直接更改JSF中的URL来限制用户访问页面.但答案没有提到如何阻止访问页面.用response.sendError?第二个链接:JSF:如何控制JSF中的访问权限和权限?
还有什么最好使用PhaseListener或使用ServletFilter?
我相信通过<login-config>+ <security-constraint>+ <security-role>和通过使用实现JSF应用程序的安全性<filter>是两种不同的方式!是吗?
我尝试通过上面的第一种方法(使用<login-config>+ <security-constraint>+ <security-role>)实现安全性, 但发现我使用受保护和未受保护的HTML组件的受保护网页甚至向未经身份验证的用户提供了不受保护的资源.
我需要完全保护URL,以便受保护的URL甚至不会将该网页的任何部分泄露给未经身份验证的用户.我该怎么做?
而且,使用安全实施<filter>的web.xml一种自我管理的方式来处理安全性?我相信,然后您可以在筛选/捕获每个请求时自定义更细粒度的安全性?