久久天天躁狠狠躁夜夜免费观看,精品国产粉嫩内射白浆内射双马尾,久久国产欧美日韩精品,久久久久久性高,激情欧美成人久久综合

Shiro教程(六)Shiro整體的配置文件

JSON 2016-08-26 01:31:43 17546

shiro demo下載

Shiro + SSM(框架) + Freemarker(jsp)講解的權(quán)限控制Demo,還不趕快去下載?




因為 Shrio  和整體項目結(jié)合的話,細(xì)節(jié)問題還是比較多。我要側(cè)重講一些地方。下面我先把我整個項目的 Shiro  配置文件先貼出來,如果你需要哪個類的實現(xiàn)方式,你可以針對性的查找,或者問我。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

	<description>== Shiro Components ==</description>
    
 	 <!-- 會話ID生成器 -->
    <bean id="sessionIdGenerator" class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator"/>

    <!-- 會話Cookie模板 -->
    <bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
    	<!--cookie的name,我故意取名叫xxxxbaidu -->
        <constructor-arg value="v_v-s-baidu"/>
        <property name="httpOnly" value="true"/>
        <!--cookie的有效時間 -->
        <property name="maxAge" value="-1"/>
        <!-- 配置存儲Session Cookie的domain為 一級域名 -->
        <property name="domain" value=".itboy.net"/>
    </bean>
	<!-- custom shiro session listener -->
	<bean id="customSessionListener" class="com.sojson.core.shiro.listenter.CustomSessionListener">
	    <property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
	</bean>
	<!-- 用戶信息記住我功能的相關(guān)配置 -->
    <bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
        <constructor-arg value="v_v-re-baidu"/>
        <property name="httpOnly" value="true"/>
        <!-- 配置存儲rememberMe Cookie的domain為 一級域名 -->
        <property name="domain" value=".itboy.net"/>
        <property name="maxAge" value="2592000"/><!-- 30天時間,記住我30天 -->
    </bean>

    <!-- rememberMe管理器 -->
    <bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
        <!-- rememberMe cookie加密的密鑰 建議每個項目都不一樣 默認(rèn)AES算法 密鑰長度(128 256 512 位)-->
        <property name="cipherKey"
                  value="#{T(org.apache.shiro.codec.Base64).decode('4AvVhmFLUs0KTA3Kprsdag==')}"/>
        <property name="cookie" ref="rememberMeCookie"/>
    </bean>
 	
 	
 	 <!-- custom shiro session listener -->
    <bean id="customShiroSessionDAO" class="com.sojson.core.shiro.CustomShiroSessionDAO">
        <property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
         <property name="sessionIdGenerator" ref="sessionIdGenerator"/>
    </bean>
 
    <!-- 會話驗證調(diào)度器 -->
   <bean id="sessionValidationScheduler" class="org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler">
        <property name="interval" value="${session.validate.timespan}"/>
        <property name="sessionManager" ref="sessionManager"/>
    </bean>
	<!-- 安全管理器 -->
    <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
        <property name="realm" ref="sampleRealm"/>
        <property name="sessionManager" ref="sessionManager"/>
        <property name="rememberMeManager" ref="rememberMeManager"/>
        <property name="cacheManager" ref="customShiroCacheManager"/>
    </bean>
	<!-- 用戶緩存 -->
	<bean id="customShiroCacheManager" class="com.sojson.core.shiro.cache.impl.CustomShiroCacheManager">
	    <property name="shiroCacheManager" ref="jedisShiroCacheManager"/>
	</bean>
	
	<!-- shiro 緩存實現(xiàn),對ShiroCacheManager,我是采用redis的實現(xiàn) -->
	<bean id="jedisShiroCacheManager" class="com.sojson.core.shiro.cache.impl.JedisShiroCacheManager">
	    <property name="jedisManager" ref="jedisManager"/>
	</bean>
	<!-- redis 的緩存 -->
	<bean id="jedisManager" class="com.sojson.core.shiro.cache.JedisManager">
	    <property name="jedisPool" ref="jedisPool"/>
	</bean>
	<!-- 相當(dāng)于調(diào)用SecurityUtils.setSecurityManager(securityManager) -->
    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
        <property name="arguments" ref="securityManager"/>
    </bean>
	
	
	<!-- 授權(quán) 認(rèn)證 -->
	<bean id="sampleRealm" class="com.sojson.core.shiro.token.SampleRealm" ></bean>

  	<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
  	
	    <property name="sessionValidationInterval" value="1800000"/>  <!-- 相隔多久檢查一次session的有效性   -->
		<property name="globalSessionTimeout" value="1800000"/> <!-- session 有效時間為半小時 (毫秒單位)-->  
        <property name="sessionDAO" ref="customShiroSessionDAO"/>
        <property name="sessionListeners">
            <list>
                <ref bean="customSessionListener"/>
            </list>
        </property>
        <property name="sessionValidationScheduler" ref="sessionValidationScheduler"/>
        <property name="sessionValidationSchedulerEnabled" value="true"/>
        <property name="deleteInvalidSessions" value="true"/>
  	
        <property name="sessionIdCookie" ref="sessionIdCookie"/>
	</bean>
 
	<bean id="jedisShiroSessionRepository" class="com.sojson.core.shiro.cache.JedisShiroSessionRepository" >
		 <property name="jedisManager" ref="jedisManager"/>
	</bean>

	<!--
		自定義角色過濾器 支持多個角色可以訪問同一個資源 eg:/home.jsp = authc,roleOR[admin,user]
		用戶有admin或者user角色 就可以訪問
	-->
	
	<!-- 認(rèn)證數(shù)據(jù)庫存儲-->
    <bean id="shiroManager" class="com.sojson.core.shiro.service.impl.ShiroManagerImpl"/>
    <bean id="login" class="com.sojson.core.shiro.filter.LoginFilter"/>
    <bean id="role" class="com.sojson.core.shiro.filter.RoleFilter"/>
	
	
	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
		<property name="securityManager" ref="securityManager" />
		<property name="loginUrl" value="/u/login.shtml" />
		<!--	TODO 待提取	-->
		<property name="successUrl" value="/" />
		<property name="unauthorizedUrl" value="/?login" />
		
<!--	初始配置,現(xiàn)采用自定義	-->
<!--		<property name="filterChainDefinitions" >-->
<!--			<value>-->
<!--				/** = anon-->
<!--				/page/login.jsp = anon-->
<!--				/page/register/* = anon-->
<!--				/page/index.jsp = authc-->
<!--				/page/addItem* = authc,roles[數(shù)據(jù)管理員]-->
<!--				/page/file* = authc,roleOR[普通用戶,數(shù)據(jù)管理員]-->
<!--				/page/listItems* = authc,roleOR[數(shù)據(jù)管理員,普通用戶]-->
<!--				/page/showItem* = authc,roleOR[數(shù)據(jù)管理員,普通用戶]-->
<!--				/page/updateItem*=authc,roles[數(shù)據(jù)管理員]-->
<!--            </value>-->
<!--		</property>-->
		<!-- 讀取初始自定義權(quán)限內(nèi)容-->
       <property name="filterChainDefinitions" value="#{shiroManager.loadFilterChainDefinitions()}"/>   
       <property name="filters">
           <util:map>
              <entry key="login" value-ref="login"></entry>
              <entry key="role" value-ref="role"></entry>
           </util:map>
       </property>
	</bean>
	<!-- Shiro生命周期處理器-->
	<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
	
	
	<!-- ============================================================================ -->

</beans>

后面會每個類的實現(xiàn)方式提供出來。

版權(quán)所屬:SO JSON在線解析

原文地址:http://suancuo.cn/blog/136.html

轉(zhuǎn)載時必須以鏈接形式注明原始出處及本聲明。

本文主題:

如果本文對你有幫助,那么請你贊助我,讓我更有激情的寫下去,幫助更多的人。

關(guān)于作者
一個低調(diào)而悶騷的男人。
相關(guān)文章
Shiro教程Shiro 配置文件詳細(xì)解釋,Shiro自定義Filter配置
Shiro教程(四)Shiro + Redis配置
Shiro教程(十)Shiro 權(quán)限動態(tài)加載與配置精細(xì)講解
Elasticsearch教程,Elasticsearch配置文件 — elasticsearch.yml
Java有序讀取配置文件,有序讀取ini配置文件
Shiro教程(三)Shiro web.xml中Filter配置,配置注意事項
Shiro教程(七)Shiro Session共享配置以及實現(xiàn)
Shiro教程(八)Shiro Freemarker標(biāo)簽的使用。
Shiro教程(五)Shiro + Redis實現(xiàn)
Shiro教程(二)Maven管理Shrio Jar包
最新文章
計算機網(wǎng)絡(luò)的相關(guān)內(nèi)容 610
SOJSON V6 JavaScript 解密技巧與分析 6065
微信客服人工電話95068:如何快速解封微信賬號(2025最新指南) 12071
Java Http請求,HttpURLConnection HTTP請求丟失頭信息,Head信息丟失解決方案 5085
實用API合集分享:教你輕松獲取IP地址的API合集 8862
Linux I/O重定向 6723
Ruby 循環(huán) - while、for、until、break、redo 和 retry 3990
Node.js:全局對象 3614
如何使用終端檢查Linux上的內(nèi)存使用情況 3779
JavaScript對象詳細(xì)剖析 3280
最熱文章
免費天氣API,天氣JSON API,不限次數(shù)獲取十五天的天氣預(yù)報 746198
最新MyEclipse8.5注冊碼,有效期到2020年 (已經(jīng)更新) 703374
蘋果電腦Mac怎么恢復(fù)出廠系統(tǒng)?蘋果系統(tǒng)怎么重裝系統(tǒng)? 678486
Jackson 時間格式化,時間注解 @JsonFormat 用法、時差問題說明 561963
我為什么要選擇RabbitMQ ,RabbitMQ簡介,各種MQ選型對比 511842
Elasticsearch教程(四) elasticsearch head 插件安裝和使用 483725
Jackson 美化輸出JSON,優(yōu)雅的輸出JSON數(shù)據(jù),格式化輸出JSON數(shù)據(jù)... ... 299614
Java 信任所有SSL證書,HTTPS請求拋錯,忽略證書請求完美解決 246700
Elasticsearch教程(一),全程直播(小白級別) 232162
227542
支付掃碼

所有贊助/開支都講公開明細(xì),用于網(wǎng)站維護(hù):贊助名單查看

查看我的收藏

正在加載... ...