⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acegi 元件.htm

📁 acegi+spring最新的分析
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0071)http://caterpillar.onlyfun.net/GossipCN/AcegiGossip/AcegiComponent.html -->
<HTML><HEAD><TITLE>Acegi 元件</TITLE><LINK href="Acegi 元件.files/stdlayout.css" 
type=text/css rel=stylesheet><LINK href="Acegi 元件.files/print.css" type=text/css 
rel=stylesheet>
<META http-equiv=content-type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.3199" name=GENERATOR></HEAD>
<BODY>
<H3><A 
href="http://caterpillar.onlyfun.net/GossipCN/index.html">http://caterpillar.onlyfun.net/GossipCN/index.html</A></H3>
<H1><A 
href="http://caterpillar.onlyfun.net/GossipCN/AcegiGossip/AcegiGossip.html">Acegi 
Gossip:&nbsp;Acegi 
元件</A></H1>入门Acegi最重要的是了解基本架构,如此就不会被一堆设定档案搞的混头转向,从先前“第一个Acegi程式”,可以看到Acegi系统包括的四个主要类型元件:Filter、Manager、Provider与Handler。<BR>
<UL>
  <LI>Filter </LI></UL>
<DIV 
style="MARGIN-LEFT: 40px">当一个请求到来时,在安全处理上最高层的元件,像是会话处理、验证、登出等,并呼叫对应的物件进行处理。</DIV>
<UL>
  <LI>Manager </LI></UL>
<DIV 
style="MARGIN-LEFT: 40px">真正处理验证、登出等安全服务之元件,Manager管理Provider所提供的安全相关资讯。</DIV>
<UL>
  <LI>Provider </LI></UL>
<DIV 
style="MARGIN-LEFT: 40px">提供安全相关资讯给Manager,安全资讯来源可能是记忆体中的物件、档案、资料库等储存媒介,安全资讯包括了使用者名称、密码、角色等讯息。</DIV>
<UL>
  <LI>Handler </LI></UL>
<DIV 
style="MARGIN-LEFT: 40px">有时会将一个安全服务分作数个小任务来进行,每个小任务由一个Handler来进行处理,如此在处理安全服务或设定Acegi时可以更有弹性,例如依需求处理登出时Session的失效与Cookie的失效。</DIV><BR>Acegi使用Filter来对请求进行验证与授权等安全服务:<BR><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp; 
&nbsp; &lt;!-- Filter Chain --&gt;</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;bean id="filterChainProxy" 
class="org.acegisecurity.util.FilterChainProxy"&gt;&nbsp;&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;property name="filterInvocationDefinitionSource"&gt;&nbsp;&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;value&gt;&nbsp;&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
PATTERN_TYPE_APACHE_ANT&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
/**=</SPAN><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">httpSessionContextIntegrationFilter,</SPAN><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">authenticationProcessingFilter,<BR>&nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp;exceptionTranslationFilter,filterSecurityInterceptor</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;/value&gt;&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;/property&gt;&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp; 
&lt;/bean&gt;</SPAN><BR><BR>以下介绍主要的几个Filter:<BR>
<UL>
  <LI>Session Integration Filter </LI></UL>
<DIV style="MARGIN-LEFT: 40px">通常是Filter Chain中第一个Filter,会建立Security Context 
物件用以储存安全相关资讯,后续的Filter若有需要储存或取得安全相关资讯,即可利用Security Context 物件,如果Security 
Context物件中的资讯有所变动,Session Integration Filter会将变动储存至Session物件之中,否则将Security 
Context物件弃置,例如“第一个Acegi程式”中所使用的Authentication Processing Filter,即利用Security 
Context物件来储存使用者名称、密码等使用者资讯。</DIV><BR>
<UL>
  <LI>Authentication Processing Filter </LI></UL>
<DIV style="MARGIN-LEFT: 40px">当使用者存取受保护资源而需要登入时,Authentication Processing 
Filter可提供表单来源给使用者,之后从使用者的请求(物件)中取得名称、密码并建立authentication 
token以储存资讯,接着将之交给验证管理员(authentication manager)进行以进行使用者的比对,所以基本上,Authentication 
Processing Filter需要设定以下的资讯:</DIV>
<DIV style="MARGIN-LEFT: 40px"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&lt;!-- 
验证处理,使用表单 --&gt;</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp; 
&lt;bean id="authenticationProcessingFilter" </SPAN><BR><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp; 
&nbsp; &nbsp; &nbsp; 
&nbsp;&nbsp;class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"&gt;&nbsp; 
</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;!-- 验证管理员,处理验证资讯提供者&nbsp; --&gt;</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;property name="authenticationManager" ref="authenticationManager"/&gt;&nbsp; 
</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;!-- 验证失败URL --&gt;</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;property name="authenticationFailureUrl" value="/acegilogin.jsp"/&gt;&nbsp; 
</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;!-- 验证成功预设URL --&gt;</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;property name="defaultTargetUrl" value="/protected/userinfo.jsp"/&gt;&nbsp; 
</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;!-- 验证处理的提交位址 --&gt;</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&lt;property name="filterProcessesUrl" value="<SPAN 
style="COLOR: rgb(0,0,0)">/j_acegi_security_check</SPAN>"/&gt;&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp; 
&lt;/bean&gt;</SPAN><BR></DIV><BR>
<DIV style="MARGIN-LEFT: 40px">当验证管理员进行使用者的比对、取得细节资讯并返回Authentication Processing 
Filter后,Authentication Processing Filter会建立Authentication并将取得的使用者资讯储存在Security 
Context物件中,然后交给下一个Filter继续进行处理。</DIV><BR>
<UL>
  <LI>Exception Translation Filter </LI></UL>
<DIV style="MARGIN-LEFT: 40px">当验证或授权过程中发生例外时,Exception Translation 
Filter处理例外。<BR><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp; 
&lt;!-- 发生验证错误或权限错误时的处理 --&gt;</SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp; 
&lt;bean id="exceptionTranslationFilter" 
class="org.acegisecurity.ui.ExceptionTranslationFilter"&gt;&nbsp; </SPAN><BR 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace"><SPAN 
style="FONT-WEIGHT: bold; FONT-FAMILY: Courier New,Courier,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -