applicationContext-shiro.xml 2.47 KB
<?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>