Struts 权限控制filter role RequestProcessor

1, 基础filter, 模块化
2, 基于role
a, struct-config中的action定义role角色
b, RequestProcessor中process方法会调用processLocale
c1,默认情况下, struts调用request.isUserInRole来检查
   (一些安全框架如acegi通过重写request.isUserInRole的方法来结合struts做权限控制的
    不同的容器实现自己的HttpServletRequest接口,在其中实现了各自不同的isUserInRole方法,也就达到了用容器特有特性来控制权限的目的
    也可以用装饰器模式来修改request,以实现自己控制isUserInRole的方法,HttpServletRequestWrapper
    )

c2,编写类RoleRequestProcessor继承RequestProcessor, 重写processRoles, 在这方法里面从Session中引入自己定义权限,并进行控制
   <action forward="/pages/roles/Admin.jsp" path="/roles/Admin" roles="admin"/>

<controller processorClass="com.compname.appname.common.struts.RoleRequestProcessor"/>

猜你喜欢

转载自desert3.iteye.com/blog/1388917