spring-shiro.xml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="
  6. http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  8. http://www.springframework.org/schema/context
  9. http://www.springframework.org/schema/context/spring-context-4.0.xsd">
  10. <bean id="jdbcRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
  11. <property name="dataSource" ref="dataSource" />
  12. <property name="authenticationQuery" value="select userpwd from t_user where userid = ?" />
  13. <property name="userRolesQuery"
  14. value="SELECT ROLEID FROM t_user_role inner join t_user on t_user.keyid=t_user_role.userid WHERE t_user.USERID=?" />
  15. <property name="permissionsQuery"
  16. value="SELECT PERMID FROM t_role_perm WHERE ROLEID=?" />
  17. <property name="permissionsLookupEnabled" value="true" />
  18. </bean>
  19. <!-- 缓存管理器使用Ehcache实现 -->
  20. <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
  21. <property name="cacheManagerConfigFile" value="classpath:ehcache.xml" />
  22. </bean>
  23. <bean id="myRealm" class="com.fsm.core.UserRealm"/>
  24. <!-- 安全管理器 -->
  25. <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
  26. <property name="realm" ref="myRealm" />
  27. </bean>
  28. <!-- Shiro 的Web过滤器 -->
  29. <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
  30. <property name="securityManager" ref="securityManager" />
  31. <property name="loginUrl" value="/myconsole/login" />
  32. <property name="unauthorizedUrl" value="/myconsole/unauthorized" />
  33. <property name="filterChainDefinitions">
  34. <value>
  35. /** = anon
  36. </value>
  37. </property>
  38. </bean>
  39. </beans>