1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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.2.xsd"
default-lazy-init="true">
<description>Shiro安全配置</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="shiroDbRealm" />
<property name="cacheManager" ref="shiroEhcacheManager" />
</bean>
<!-- 項目自定义的Realm, 所有accountService依赖的dao都需要用depends-on声明 -->
<bean id="shiroDbRealm" class="com.hp.cmsz.service.account.ShiroDbRealm" depends-on="systemFunctionDao,roleInfoDao,userInfoDao,systemParameterDao">
<!-- <property name="accountService" ref="accountService"/> -->
</bean>
<!-- Shiro Filter -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager" />
<!-- 指定项目的首页 -->
<property name="loginUrl" value="/index" />
<property name="successUrl" value="/" />
<property name="filterChainDefinitions">
<value>
/index = authc
/AnalysisSupport/** = user
/AuthorityManage/** = user
/DataBackup/** = user
/DataManage/** = user
/error/** = user
/ModelManage/** = user
/MonitorOperation/** = user
/ParameterManage/** = user
/SelfMonitor/** = user
/SetupManage/** = user
/TaskManage/** = user
/static/** = anon
/tmp/** = anon
<!-- 4A对外发布的接口 -->
<!-- Add by Hudson on 20140715 begin -->
/services = anon
<!-- Add by Hudson on 20140715 end -->
/LoginSwitchService?wsdl = anon
/DepartmentService?wsdl = anon
/GroupService?wsdl = anon
/LogoutService?wsdl = anon
/UserServices?wsdl = anon
/logout = logout
</value>
</property>
</bean>
<!-- 用户授权信息Cache, 采用EhCache -->
<bean id="shiroEhcacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
<property name="cacheManagerConfigFile" value="classpath:ehcache/ehcache-shiro.xml"/>
</bean>
<!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
</beans>