shiro简单学习

来源:互联网 发布:淘宝产品规划方案 编辑:程序博客网 时间:2024/06/07 22:03
<?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/beans                           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"      default-lazy-init="true">      <description>Shiro Configuration</description>      <!-- Shiro's main business-tier object for web-enabled applications -->      <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">          <property name="realm" ref="myShiroRealm" />          <property name="cacheManager" ref="cacheManager" />      </bean>      <!-- 項目自定义的Realm -->      <bean id="myShiroRealm" class="com.luo.shiro.realm.MyShiroRealm">          <property name="cacheManager" ref="cacheManager" />      </bean>      <!-- Shiro Filter -->      <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">          <property name="securityManager" ref="securityManager" />          <property name="loginUrl" value="/login.jhtml" />          <property name="successUrl" value="/loginsuccess.jhtml" />          <property name="unauthorizedUrl" value="/error.jhtml" />          <property name="filterChainDefinitions">              <value>                  /index.jhtml = authc                  /login.jhtml = anon                /checkLogin.json = anon                  /loginsuccess.jhtml = anon                  /logout.json = anon                  /** = authc              </value>          </property>      </bean>      <!-- 用户授权信息Cache -->      <bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />      <!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->      <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />      <!-- AOP式方法级权限检查 -->      <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"          depends-on="lifecycleBeanPostProcessor">          <property name="proxyTargetClass" value="true" />      </bean>      <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">          <property name="securityManager" ref="securityManager" />      </bean>  </beans>  

原创粉丝点击