图片区小说区国产精品视频,国产经典一区二区,亚洲国产一区二区在线观看http://www.aygfsteel.com/walwal/category/43985.html我的門戶zh-cnThu, 25 Feb 2010 10:06:41 GMTThu, 25 Feb 2010 10:06:41 GMT60Acegi 配置指南(4)http://www.aygfsteel.com/walwal/archive/2010/02/25/313915.htmlxuyangxuyangThu, 25 Feb 2010 10:02:00 GMThttp://www.aygfsteel.com/walwal/archive/2010/02/25/313915.htmlhttp://www.aygfsteel.com/walwal/comments/313915.htmlhttp://www.aygfsteel.com/walwal/archive/2010/02/25/313915.html#Feedback0http://www.aygfsteel.com/walwal/comments/commentRss/313915.htmlhttp://www.aygfsteel.com/walwal/services/trackbacks/313915.html

認(rèn)證模式配置(二)

表單認(rèn)證

表單認(rèn)證利用開發(fā)者開發(fā)的登錄頁面搜集用戶名和密碼,下面是登錄頁面的基本代碼:

<form action="j_acegi_security_check" method="post">

    用戶名:<input name="j_username"><br>

    密 碼:<input name="j_password" type="password"><br>

    14天之內(nèi)免登錄<input name="_acegi_security_remember_me" type="checkbox"><br>

    <input type="submit" value="登錄">

</form>

同時,還加入了退出、免登錄和匿名三個過濾器。

代碼:

<!-- 退出過濾器 -->

<bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter">

    <constructor-arg value="/index.jsp" />

    <constructor-arg>

       <list>

           <ref local="rememberMeServices" />

           <ref local="securityContextLogoutHandler" />

       </list>

    </constructor-arg>

</bean>

<!-- 安全上下文退出句柄 -->

<bean id="securityContextLogoutHandler" class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler">

    <property name="invalidateHttpSession" value="true" />

</bean>

<!-- ================

        認(rèn)證部分

     ================ -->

<!-- 表單認(rèn)證過濾器 -->

<bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">

    <property name="authenticationManager" ref="authenticationManager" />

    <property name="authenticationFailureUrl" value="/login.jsp?error=1" />

    <property name="defaultTargetUrl" value="/" />

    <property name="alwaysUseDefaultTargetUrl" value="true" />

    <property name="filterProcessesUrl" value="/j_acegi_security_check" />

    <property name="rememberMeServices" ref="rememberMeServices" />

</bean>

<!-- 認(rèn)證管理器 -->

<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">

    <property name="providers">

       <list>

           <ref local="daoAuthenticationProvider" />

           <ref local="anonymousAuthenticationProvider" />

           <ref local="rememberMeAuthenticationProvider" />

       </list>

    </property>

</bean>

<!-- DAO認(rèn)證源提供者 -->

<bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">

    <property name="userDetailsService" ref="inMemDaoImpl" />

</bean>

<!-- 用戶信息源(內(nèi)存) -->

<bean id="inMemDaoImpl" class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl">

    <property name="userMap">

       <value>

           admin=password,ROLE_ADMIN,ROLE_USER

           user1=password,ROLE_USER

       </value>

    </property>

</bean>

<!-- 免登錄認(rèn)證過濾器 -->

<bean id="rememberMeProcessingFilter" class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter">

    <property name="authenticationManager" ref="authenticationManager" />

    <property name="rememberMeServices" ref="rememberMeServices"></property>

</bean>

<!-- 免登錄服務(wù) -->

<bean id="rememberMeServices" class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices">

    <property name="userDetailsService" ref="inMemDaoImpl" />

    <property name="key" value="springRocks" />

    <property name="tokenValiditySeconds" value="1209600" />

    <property name="parameter" value="_acegi_security_remember_me" />

    <property name="cookieName" value="ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE" />

    <!--

    <property name="alwaysRemember" value="true" />

     -->

</bean>

<!-- 免登錄認(rèn)證源提供者 -->

<bean id="rememberMeAuthenticationProvider" class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider">

    <property name="key" value="springRocks" />

</bean>

<!-- 匿名認(rèn)證過濾器 -->

<bean id="anonymousProcessingFilter" class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter">

    <property name="key" value="foobar" />

    <property name="userAttribute" value="anonymousUser,ROLE_ANONYMOUS" />

</bean>

<!-- 匿名認(rèn)證源提供者 -->

<bean id="anonymousAuthenticationProvider" class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider">

    <property name="key" value="foobar" />

</bean>

<!-- 異常處理過濾器 -->

<bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter">

    <property name="authenticationEntryPoint" ref="authenticationProcessingFilterEntryPoint" />

    <property name="accessDeniedHandler" ref="accessDeniedHandlerImpl" />

</bean>

<!-- 表單認(rèn)證入口點 -->

<bean id="authenticationProcessingFilterEntryPoint" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">

    <property name="loginFormUrl" value="/login.jsp" />

    <property name="forceHttps" value="false" />

    <property name="serverSideRedirect" value="false" />

</bean>

<!-- 授權(quán)拒絕句柄 -->

<bean id="accessDeniedHandlerImpl" class="org.acegisecurity.ui.AccessDeniedHandlerImpl">

    <property name="errorPage" value="/accessDenied.jsp" />

</bean>

說明:

在基本認(rèn)證過濾器之前加入退出過濾器,之后加入免登錄過濾器和匿名過濾器。參數(shù):

Bean

參數(shù)

描述

logoutFilter
退出過濾器

構(gòu)造參數(shù)1

指定退出后的重定向url

構(gòu)造參數(shù)2

指派退出的執(zhí)行句柄,多值

退出免登錄服務(wù)

退出安全上下文

securityContextLogoutHandler
安全上下文退出句柄

invalidateHttpSession

是否讓HTTP會話失效

authenticationProcessingFilter
基本認(rèn)證過濾器

authenticationManager

指派認(rèn)證管理器

authenticationFailureUrl

認(rèn)證失敗的URL

defaultTargetUrl

認(rèn)證成功之后的缺省URL。兩種情況下使用:1. 用戶直接進(jìn)入登錄頁;2. alwaysUseDefaultTargetUrl設(shè)為true。(一般情況是用戶進(jìn)入受保護(hù)頁時,acegi會先跳轉(zhuǎn)到登錄頁,認(rèn)證成功之后再跳轉(zhuǎn)到用戶要訪問的頁面。如果用戶直接進(jìn)入登錄頁,認(rèn)證成功之后acegi不知道用戶要訪問的頁面是什么時,采用該值。)

alwaysUseDefaultTargetUrl

是否無論用戶要訪問的頁面是什么,認(rèn)證成功之后都跳轉(zhuǎn)到defaultTargetUrl

filterProcessesUrl

表單提交的Action,默認(rèn)值為
/j_acegi_security_check

rememberMeServices

指派免登錄服務(wù)

authenticationManager
認(rèn)證管理器

providers

指派認(rèn)證源提供者,多值

DAO認(rèn)證源提供者

免登錄認(rèn)證源提供者

匿名認(rèn)證源提供者

daoAuthenticationProvider
DAO
認(rèn)證源提供者

userDetailsService

指派用戶信息源

inMemDaoImpl
用戶信息源(內(nèi)存)

userMap

用戶信息

rememberMeProcessingFilter

免登錄過濾器

authenticationManager

指派認(rèn)證管理器

rememberMeServices

指派免登錄服務(wù)

rememberMeServices

免登錄服務(wù)

userDetailsService

指派用戶信息源

key

指定密鑰

tokenValiditySeconds

免登錄的時間段,單位為秒,缺省值為1209600,合14

parameter

在登錄表單中提交的參數(shù)名,acegi依據(jù)當(dāng)前值判斷用戶是否需要免登錄服務(wù),缺省值為:
_acegi_security_remember_me

cookieName

保存在瀏覽器的Cookie名,acegi依據(jù)cookie值完成自動登錄,達(dá)到用戶免登錄目的,缺省值為:
ACEGI_SECURITY_HASHED_
REMEMBER_ME_COOKIE

alwaysRemember

是否自動提供免登錄服務(wù),將該參數(shù)設(shè)為true時,無論用戶是否選擇都提供免登錄服務(wù),設(shè)為true時會覆蓋parameter的作用。(一般在HTTP基本認(rèn)證時采用,表單認(rèn)證時不用)

rememberMeAuthenticationProvider

免登錄認(rèn)證源提供者

key

指定密鑰,和免登錄服務(wù)的密鑰保持一致

anonymousProcessingFilter

匿名過濾器

userAttribute

指定匿名登錄的用戶和角色,格式:

uid,role

key

指定密鑰

anonymousAuthenticationProvider
匿名認(rèn)證源提供者

key

指定密鑰,和匿名過濾器的密鑰保持一致

exceptionTranslationFilter
異常處理過濾器

authenticationEntryPoint

指派認(rèn)證入口點

accessDeniedHandler

指派授權(quán)拒絕處理器

authenticationProcessingFilterEntryPoint
表單認(rèn)證入口點

loginFormUrl

指定登錄頁面,如:/login.jsp

forceHttps

是否強制使用https協(xié)議

serverSideRedirect

是否采用WEB服務(wù)器內(nèi)部跳轉(zhuǎn)到登錄頁面

accessDeniedHandlerImpl
授權(quán)拒絕處理器

errorPage

訪問無權(quán)限的頁面時,acegi跳轉(zhuǎn)的錯誤頁面

 Spring Bean關(guān)系圖:


說明:每個圖塊為一個Spring Bean斜體Bean和同名正體Bean為同一個Bean

問題:

在表單認(rèn)證下,加入了“退出”之后,是可以退出Acegi安全上下文的。因此之前HTTP基本認(rèn)證不能退出可能是Acegi的一個BUG



xuyang 2010-02-25 18:02 發(fā)表評論
]]>
Acegi配置指南(3)http://www.aygfsteel.com/walwal/archive/2010/02/23/313710.htmlxuyangxuyangTue, 23 Feb 2010 05:53:00 GMThttp://www.aygfsteel.com/walwal/archive/2010/02/23/313710.htmlhttp://www.aygfsteel.com/walwal/comments/313710.htmlhttp://www.aygfsteel.com/walwal/archive/2010/02/23/313710.html#Feedback0http://www.aygfsteel.com/walwal/comments/commentRss/313710.htmlhttp://www.aygfsteel.com/walwal/services/trackbacks/313710.html閱讀全文

xuyang 2010-02-23 13:53 發(fā)表評論
]]>
Acegi配置指南(2)http://www.aygfsteel.com/walwal/archive/2010/02/22/313656.htmlxuyangxuyangMon, 22 Feb 2010 09:46:00 GMThttp://www.aygfsteel.com/walwal/archive/2010/02/22/313656.htmlhttp://www.aygfsteel.com/walwal/comments/313656.htmlhttp://www.aygfsteel.com/walwal/archive/2010/02/22/313656.html#Feedback0http://www.aygfsteel.com/walwal/comments/commentRss/313656.htmlhttp://www.aygfsteel.com/walwal/services/trackbacks/313656.html閱讀全文

xuyang 2010-02-22 17:46 發(fā)表評論
]]>
Acegi配置指南(1)http://www.aygfsteel.com/walwal/archive/2010/02/21/313491.htmlxuyangxuyangSun, 21 Feb 2010 01:55:00 GMThttp://www.aygfsteel.com/walwal/archive/2010/02/21/313491.htmlhttp://www.aygfsteel.com/walwal/comments/313491.htmlhttp://www.aygfsteel.com/walwal/archive/2010/02/21/313491.html#Feedback0http://www.aygfsteel.com/walwal/comments/commentRss/313491.htmlhttp://www.aygfsteel.com/walwal/services/trackbacks/313491.html閱讀全文

xuyang 2010-02-21 09:55 發(fā)表評論
]]>
主站蜘蛛池模板: 乐东| 湘潭县| 永济市| 新余市| 唐河县| 项城市| 永春县| 岑溪市| 台中市| 平湖市| 贺州市| 安塞县| 文水县| 齐齐哈尔市| 延庆县| 墨江| 棋牌| 和政县| 同仁县| 潞西市| 荔波县| 东安县| 临邑县| 大余县| 新巴尔虎右旗| 赫章县| 华亭县| 涟源市| 和顺县| 耒阳市| 武强县| 芜湖市| 务川| 寻乌县| 云龙县| 扎赉特旗| 内丘县| 古丈县| 皋兰县| 道真| 三江|