标签:ring space pid 权限设置 res import rac dos url

<!-- shiro --><!-- apache shiro dependencies --><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-core</artifactId><version>${shiro.version}</version></dependency><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-web</artifactId><version>${shiro.version}</version></dependency><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-spring</artifactId><version>${shiro.version}</version></dependency><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-aspectj</artifactId><version>${shiro.version}</version></dependency>
<filter><filter-name>shiroFilter</filter-name><filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class></filter><filter-mapping><filter-name>shiroFilter</filter-name><url-pattern>*.action</url-pattern><url-pattern>*.html</url-pattern><url-pattern>*</url-pattern></filter-mapping>
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"><bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <!-- shiro框架的中央枢纽 --><property name="securityManager" ref="securityManager" /><!-- 如果访问页面或请求是没有当前登录人,会跳转到login.html中 --><property name="loginUrl" value="/login.html" /><!-- 如果当前登录人访问的页面或请求没有权限时,跳转到error.html --><property name="unauthorizedUrl" value="/error.html" /><property name="filterChainDefinitions"><value>/error.html = anon/*.html = authc</value></property></bean><!-- shiro框架的中央枢纽 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"></bean></beans>
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"><property name="realm" ref="erpRealm" ></property></bean><bean id="erpRealm" class="cn.itcast.erp.realm.ErpRealm" ><property name="empBiz" ref="empBiz" ></property></bean>
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 当实例化一个bean是,spring保证该Bean所依赖的其他bean已经初始化 --><bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean" depends-on="myPermsFilter"><!-- shiro框架的中央枢纽 --><property name="securityManager" ref="securityManager" /><!-- 如果访问页面或请求是没有当前登录人,会跳转到login.html中 --><property name="loginUrl" value="/login.html" /><!-- 如果当前登录人访问的页面或请求没有权限时,跳转到error.html --><property name="unauthorizedUrl" value="/error.html" /><property name="filters"><map><entry key="perms" value-ref="myPermsFilter"></entry></map></property><property name="filterChainDefinitions"><value>/error.html = anon/login_*.action=anon/emp_updatePwd.action= perms[]/pwd.html=perms["重置密码"]/emp_updatePwd_reset.action=perms["重置密码"]/orders.html= perms["采购申请","采购订单查询","采购审核","采购确认","采购入库","销售订单录入","销售订单查询","销售订单出库"]/orders_add.action= perms["采购申请","销售订单录入"]/goods_list.action= perms["采购申请","销售订单录入","库存查询","库存变动记录"]/supplier_list.action= perms["采购申请","销售订单录入"]/orders_listByPage.action= perms["采购申请","采购订单查询","采购审核","采购确认","采购入库","销售订单录入","销售订单查询","销售订单出库"]/orders_doCheck.action=perms["采购审核"]/orders_doStart.action=perms["采购确认"]/store_mylist.action= perms["采购入库","销售订单出库"]/orderdetail_doInstore.action=perms["采购入库"]/orderdetail_doOutstore.action=perms["销售订单出库"]/storedetail.html= perms["库存查询"]/store_*.action= perms["仓库"]/goods_get.action= perms["库存查询","库存变动记录"]/store_list.action= perms["库存查询","库存变动记录"]/store_get.action= perms["库存查询","库存变动记录"]/storedetail_listByPage.action= perms["库存查询"]/storeoper_listByPage.action= perms["库存查询"]/storeoper.html= perms["库存变动记录"]/storeoper_listByPage.action= perms["库存变动记录"]/emp_list.action= perms["库存变动记录"]/emp_get.action= perms["库存变动记录"]/store.html= perms["仓库"]/orderReport.html= perms["销售统计表"]/report_orderReport*.action= perms["销售统计表"]/orderTrend.html= perms["销售趋势分析"]/report_orderTrend*.action= perms["销售趋势分析"]/roleMenuSet.html=perms["角色权限设置"]/role_list.action=perms["角色权限设置"]/role_readRoleMenus.action=perms["角色权限设置"]/role_updateRoleMenus.action=perms["角色权限设置"]/empRoleSet.html=perms["用户角色设置"]/emp_list.action=perms["用户角色设置"]/emp_readEmpRoles.action=perms["用户角色设置"]/emp_updateEmpRoles.action=perms["用户角色设置"]/role.html= perms["角色设置"]/role_*.action= perms["角色设置"]/goodstype.html= perms["商品类型"]/goodstype_*.action= perms["商品类型"]/goods.html= perms["商品"]/goods_*.action= perms["商品"]/supplier.html = perms["供应商","客户"]/supplier_*.action = perms["供应商","客户"]/emp.html= perms["员工"]/emp_*.action= perms["员工"]/dep_list.action=perms["员工"]/dep.html= perms["部门"]/dep_*.action= perms["部门"]</value></property></bean><!-- shiro框架的中央枢纽 --><bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"><property name="realm" ref="erpRealm"></property></bean><bean id="erpRealm" class="cn.itcast.erp.realm.ErpRealm"><property name="empBiz" ref="empBiz"></property><property name="menuBiz" ref="menuBiz"></property></bean><bean id="myPermsFilter" class="cn.itcast.erp.filter.MyPermsFilter"></bean></beans>
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();Emp emp = (Emp) principals.getPrimaryPrincipal();List<Menu> list = menuBiz.getMenuListByEmpuuid(emp.getUuid());for (Menu menu : list) {info.addStringPermission("部门");}return info;}
package cn.itcast.myerp.filter;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import org.apache.shiro.subject.Subject;import org.apache.shiro.web.filter.authz.AuthorizationFilter;public class myPermsFilter extends AuthorizationFilter {@Overrideprotected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)throws Exception {Subject subject = getSubject(request, response);String [] perms=(String[]) mappedValue;if (perms!=null&&perms.length>0) {for(int i=0;i<perms.length;i++){if (subject.isPermitted(perms[i])) {return true;}}return false;}else {return false;}}}
标签:ring space pid 权限设置 res import rac dos url
原文地址:http://www.cnblogs.com/qinhelili/p/6985975.html