你的位置:首页 > 软件开发 > Java > Apache Shiro 使用手册(五)Shiro 配置说明

Apache Shiro 使用手册(五)Shiro 配置说明

发布时间:2015-06-24 00:00:23
Apache Shiro的配置主要分为四部分: 对象和属性的定义与配置URL的过滤器配置静态用户配置静态角色配置其中,由于用户、角色一般由后台进行操作的动态数据,因此Shiro配置一般仅包含前两项的配置。Apache Shiro的大多数组件是基于POJO的,因此我们可以使用POJ ...

Apache Shiro的配置主要分为四部分:

  • 对象和属性的定义与配置
  • URL的过滤器配置
  • 静态用户配置
  • 静态角色配置

其中,由于用户、角色一般由后台进行操作的动态数据,因此Shiro配置一般仅包含前两项的配置。Apache Shiro的大多数组件是基于POJO的,因此我们可以使用POJO兼容的任何配置机制进行配置,例如:Java代码、Sping

  1. <bean id="securityManager" class="org.apache.shiro.mgt.DefaultSecurityManager">  
  2.         <property name="cacheManager" ref="cacheManager"/>  
  3.         <property name="sessionMode" value="native"/>  
  4.         <!-- Single realm app.  If you have multiple realms, use the 'realms' property instead. -->  
  5.         <property name="realm" ref="myRealm"/>  
  6.         <property name="sessionManager" ref="sessionManager"/>   
  7. </bean>  
Shiro过滤器的配置
  1. <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">  
  2.     <property name="securityManager" ref="securityManager"/>  
  3.     <property name="loginUrl" value="/login.jsp"/>  
  4.     <property name="successUrl" value="/home.jsp"/>  
  5.     <property name="unauthorizedUrl" value="/unauthorized.jsp"/> -->  
  6.     <property name="filterChainDefinitions">  
  7.         <value>  
  8.             # some example chain definitions:  
  9.             /admin/** = authc, roles[admin]  
  10.             /docs/** = authc, perms[document:read]  
  11.             /** = authc  
  12.             # more URL-to-FilterChain definitions here  
  13.         </value>  
  14.     </property>  
  15. </bean>  
URL表达式说明Filter Chain定义说明Shiro内置的FilterChain

原标题:Apache Shiro 使用手册(五)Shiro 配置说明

关键词:Apache

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录