﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-liuzheng-文章分类-Acegi</title><link>http://www.blogjava.net/liuzheng/category/34854.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 26 Sep 2008 10:35:56 GMT</lastBuildDate><pubDate>Fri, 26 Sep 2008 10:35:56 GMT</pubDate><ttl>60</ttl><item><title>Acegi验证授权的数据库设计</title><link>http://www.blogjava.net/liuzheng/articles/231338.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Fri, 26 Sep 2008 09:24:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/231338.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/231338.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/231338.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/231338.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/231338.html</trackback:ping><description><![CDATA[<pre>CREATE DATABASE acegi;<br />
<br />
USE acegi;<br />
<br />
<br />
<br />
CREATE TABLE USERS(  <br />
<br />
USERNAME VARCHAR(50) NOT NULL PRIMARY KEY,  <br />
<br />
PASSWORD VARCHAR(50) NOT NULL,  <br />
<br />
ENABLED BIT NOT NULL<br />
<br />
);<br />
<br />
<br />
<br />
INSERT INTO USERS(username,password,enabled) values('caterpillar' ,'123456', 1);<br />
<br />
INSERT INTO USERS(username,password,enabled) values('user1' ,'user1pwd', 1);<br />
<br />
INSERT INTO USERS(username,password,enabled) values('user2' ,'user2pwd', 0);<br />
<br />
<br />
<br />
CREATE TABLE AUTHORITIES(  <br />
<br />
USERNAME VARCHAR( 50 ) NOT NULL,  <br />
<br />
AUTHORITY VARCHAR( 50 ) NOT NULL,  <br />
<br />
CONSTRAINT FK_AUTHORITIES_USERS FOREIGN KEY(USERNAME) REFERENCES USERS(USERNAME)  <br />
<br />
);  <br />
<br />
<br />
<br />
INSERT INTO AUTHORITIES(USERNAME,AUTHORITY) values( 'caterpillar' , 'ROLE_SUPERVISOR');<br />
<br />
INSERT INTO AUTHORITIES(USERNAME,AUTHORITY) values( 'user1', 'ROLE_USER');  <br />
<br />
INSERT INTO AUTHORITIES(USERNAME,AUTHORITY) values( 'user2', 'ROLE_USER');</pre>
<img src ="http://www.blogjava.net/liuzheng/aggbug/231338.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2008-09-26 17:24 <a href="http://www.blogjava.net/liuzheng/articles/231338.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>从业务流程中取出Acegi的SecurityContext</title><link>http://www.blogjava.net/liuzheng/articles/231333.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Fri, 26 Sep 2008 09:06:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/231333.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/231333.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/231333.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/231333.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/231333.html</trackback:ping><description><![CDATA[<br />
SecurityContext context = SecurityContextHolder.getContext();<br />
就可以得到了context<br />
<img src ="http://www.blogjava.net/liuzheng/aggbug/231333.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2008-09-26 17:06 <a href="http://www.blogjava.net/liuzheng/articles/231333.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Acegi系统元件</title><link>http://www.blogjava.net/liuzheng/articles/231330.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Fri, 26 Sep 2008 09:01:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/231330.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/231330.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/231330.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/231330.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/231330.html</trackback:ping><description><![CDATA[入门Acegi最重要的是了解基本架构，如此就不会被一堆设定档案搞的混头转向，从先前&#8220;第一个Acegi程式&#8221;，可以看到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物件弃置，例如&#8220;第一个Acegi程式&#8221;中所使用的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: #000000;">/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; &lt;property name="authenticationEntryPoint"&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;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;bean
class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint"&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;property name="loginFormUrl" 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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;property name="forceHttps" value="false"/&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;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/bean&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;/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;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name="accessDeniedHandler"&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;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;bean class="org.acegisecurity.ui.AccessDeniedHandlerImpl"&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;property name="errorPage" value="/accessDenied.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;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/bean&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;/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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></div>
<br />
<ul>
    <li>Logout Processing Filter</li>
</ul>
<div style="margin-left: 40px;">管理登出的处理，实际的登出处理会交给Handler，您可以设置登出后的显示页面来源，在 <a href="http://caterpillar.onlyfun.net/GossipCN/AcegiGossip/FirstAcegLogoutCookies.html">第一个Acegi 程式 -&nbsp;登出、自动Cookies登入</a> 中，使用了SecurityContextLogoutHandler来让Session交效。</div>
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp; &lt;!-- 登出处理 --&gt;&nbsp; </span><br style="font-weight: bold; font-family: Courier New,Courier,monospace;" />
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp; &lt;bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter"&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;constructor-arg value="/acegilogin.jsp"/&gt; &lt;!-- 登出后的显示页面 --&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;&nbsp;&nbsp;&nbsp;&nbsp; &lt;constructor-arg&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;list&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;bean
class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler"/&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/list&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;/constructor-arg&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 />
<ul>
    <li>Interceptor filters</li>
</ul>
<div style="margin-left: 40px;">用来决定是否授权，验证与授权是一体的，所以在Authentication
Processing Filter之后必须设定Interceptor filters，Interceptor
filters使用您所设定的存取控制策略（access control
policy）来决定是否授权，一个使用者的存取控制策略定义了使用者、密码、角色等资讯：<br />
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">caterpillar=123456,ROLE_SUPERVISOR</span></div>
<br />
<div style="margin-left: 40px;">您使用Interceptor filters来进行存取控制策略的设定，设定验证管理者与存取决策理员（Access Decision Manager），受保护的资源可存取之角色，存取决策管理员会以投票方式决定资源是否授权，例如：<br />
</div>
<span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp;&nbsp; &lt;!-- FilterSecurityInterceptor 对 URI 进行保护 --&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="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;&nbsp; class="org.acegisecurity.intercept.web.FilterSecurityInterceptor"&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;!-- 验证管理员 --&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;</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="accessDecisionManager" ref="accessDecisionManager" /&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="objectDefinitionSource"&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;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON</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;&nbsp;&nbsp;&nbsp;&nbsp; PATTERN_TYPE_APACHE_ANT</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;&nbsp;&nbsp;&nbsp;&nbsp;
/protected/**=ROLE_SUPERVISOR,ROLE_USER</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; &lt;/value&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&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&gt;</span>
<img src ="http://www.blogjava.net/liuzheng/aggbug/231330.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2008-09-26 17:01 <a href="http://www.blogjava.net/liuzheng/articles/231330.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Acegi架构</title><link>http://www.blogjava.net/liuzheng/articles/231331.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Fri, 26 Sep 2008 09:01:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/231331.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/231331.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/231331.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/231331.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/231331.html</trackback:ping><description><![CDATA[<br />
下图为Acegi的架构流程简图：<br />
<img style="width: 533px; height: 266px;" alt="" src="http://caterpillar.onlyfun.net/GossipCN/AcegiGossip/images/AcegiArchitecture-1.jpg" /><br />
<br />
<br />
<ol>
    <li>浏览器发出请求。</li>
    <li>容器将请求包装为请求物件与回应物件，然后呼叫Acegi的Filter Chain Proxy，将请求物件与回应物件传递给它。</li>
    <li>Filter Chain Proxy呼叫Filter Chain的第一个Filter，通常是Session Integration Filter，将请求物件与回应物件传递给它。</li>
    <li>Session Integration Filter检查Session物件是否存在，并且包括Security
    Context物件，如果否则建立Security Context物件并将之放入security context
    holder之中，一个存在于application scope的物件。</li>
    <li>每个Filter完成后会呼叫下一个Filter。</li>
    <li>每
    个Filter会读取或变更Security Context，每个Filter处理完成之后，最后控制权再度回到Session
    Integration Filter后，Session Integration Filter检查Security
    Context是否有变更，如果有变更，使用Security Context中的资讯更新Session物件。</li>
    <li>完成Filter Chain，控制权进入应用程式，开始处理请求并准备回应。</li>
    <li>将结果回应传回至浏览器。</li>
</ol>
<img src ="http://www.blogjava.net/liuzheng/aggbug/231331.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2008-09-26 17:01 <a href="http://www.blogjava.net/liuzheng/articles/231331.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Acegi基本配置 -信息放在数据库中</title><link>http://www.blogjava.net/liuzheng/articles/231327.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Fri, 26 Sep 2008 09:00:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/231327.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/231327.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/231327.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/231327.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/231327.html</trackback:ping><description><![CDATA[在先前的设定中，inMemoryDaoImpl将使用者讯息设定在userMap之中：<br />
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp; &lt;bean id="inMemoryDaoImpl" class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl"&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="userMap"&gt;&nbsp;&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; &lt;value&gt;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp; caterpillar=123456,ROLE_SUPERVISOR</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;&nbsp;&nbsp;&nbsp;&nbsp; user1=user1pwd,ROLE_USER</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;&nbsp;&nbsp;&nbsp;&nbsp;
user2=user2pwd,disabled,ROLE_USER&nbsp;&nbsp;&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; &lt;/value&gt;&nbsp;&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; &lt;/property&gt;&nbsp;&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; &lt;/bean&gt; </span><br />
</div>
<br />
您可以撰写一个属性档案/WEB-INF/users.properties：<br />
<ul>
    <li>users.properties</li>
</ul>
<pre>caterpillar=123456,ROLE_SUPERVISOR<br />
user1=user1pwd,ROLE_USER<br />
user2=user2pwd,disabled,ROLE_USER</pre>
<br />
然后改设定inMemoryDaoImpl的userProperties：<br />
<div style="margin-left: 40px;"><span style="font-weight: bold; font-family: Courier New,Courier,monospace;">&nbsp;&nbsp; &lt;bean id="inMemoryDaoImpl" class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl"&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; &lt;property name="userProperties"&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;&nbsp;&nbsp;&nbsp;
&lt;bean
class="org.springframework.beans.factory.config.PropertiesFactoryBean"&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;property name="location" value="/WEB-INF/users.properties" /&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;&nbsp;&nbsp;&nbsp; &lt;/bean&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; &lt;/property&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; &lt;/bean&gt;</span><br />
</div>
<br />
如此在需要使用者讯息时，就可以从users.properties中提取。<br />
<br />
如果想要将使用者的相关讯息储存在资料库中，例如使用以下的SQL在MySQL中建立使用者讯息：<br />
<ul>
    <li>users.sql</li>
</ul>
<pre>CREATE DATABASE acegi;<br />
USE acegi;<br />
<br />
CREATE TABLE USERS(  <br />
USERNAME VARCHAR(50) NOT NULL PRIMARY KEY,  <br />
PASSWORD VARCHAR(50) NOT NULL,  <br />
ENABLED BIT NOT NULL<br />
);<br />
<br />
INSERT INTO USERS(username,password,enabled) values('caterpillar' ,'123456', 1);<br />
INSERT INTO USERS(username,password,enabled) values('user1' ,'user1pwd', 1);<br />
INSERT INTO USERS(username,password,enabled) values('user2' ,'user2pwd', 0);<br />
<br />
CREATE TABLE AUTHORITIES(  <br />
USERNAME VARCHAR( 50 ) NOT NULL,  <br />
AUTHORITY VARCHAR( 50 ) NOT NULL,  <br />
CONSTRAINT FK_AUTHORITIES_USERS FOREIGN KEY(USERNAME) REFERENCES USERS(USERNAME)  <br />
);  <br />
<br />
INSERT INTO AUTHORITIES(USERNAME,AUTHORITY) values( 'caterpillar' , 'ROLE_SUPERVISOR');<br />
INSERT INTO AUTHORITIES(USERNAME,AUTHORITY) values( 'user1', 'ROLE_USER');  <br />
INSERT INTO AUTHORITIES(USERNAME,AUTHORITY) values( 'user2', 'ROLE_USER');</pre>
<br />
您可以使用org.acegisecurity.userdetails.jdbc.JdbcDaoImpl作为userDetailsService，它需要一个DataSource，这可以使用Spring的DriverManagerDataSource，例如：<br />
<ul>
    <li>acegi-config.xml</li>
</ul>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"&gt;<br />
&lt;beans&gt;<br />
<span style="font-weight: bold;">    &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">         &lt;property name="driverClassName"&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">             &lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;              </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">         &lt;/property&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">         &lt;property name="url"&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">             &lt;value&gt;jdbc:mysql://localhost:3306/acegi&lt;/value&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">         &lt;/property&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">         &lt;property name="username"&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">             &lt;value&gt;root&lt;/value&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">         &lt;/property&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">         &lt;property name="password"&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">             &lt;value&gt;123456&lt;/value&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">         &lt;/property&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">     &lt;/bean&gt;  </span><br />
<br />
&lt;!-- 验证处理，使用表单 --&gt;<br />
&lt;bean id="authenticationProcessingFilter" class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"&gt;  <br />
&lt;!-- 验证管理员，处理验证资讯提供者  --&gt;<br />
&lt;property name="authenticationManager" ref="authenticationManager"/&gt;  <br />
&lt;!-- 验证失败URL --&gt;<br />
&lt;property name="authenticationFailureUrl" value="/acegilogin.jsp"/&gt;  <br />
&lt;!-- 验证成功预设URL --&gt;<br />
&lt;property name="defaultTargetUrl" value="/protected/loginsuccess.jsp"/&gt;  <br />
&lt;!-- 验证处理的提交位址 --&gt;<br />
&lt;property name="filterProcessesUrl" value="/j_acegi_security_check"/&gt;  <br />
&lt;/bean&gt;<br />
<br />
&lt;!-- 验证管理员，管理验证资讯提供者 --&gt;<br />
&lt;bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager"&gt;  <br />
&lt;property name="providers"&gt;&lt;!-- 可有多个提供者,其中一个验证通过即可以了 --&gt;  <br />
&lt;list&gt;  <br />
&lt;ref local="daoAuthenticationProvider"/&gt; <br />
&lt;ref local="rememberMeAuthenticationProvider"/&gt;<br />
&lt;/list&gt;  <br />
&lt;/property&gt;  <br />
&lt;/bean&gt;<br />
<br />
&lt;!-- 验证提供者，指定使用资料库来源中的验证资讯 --&gt;<br />
&lt;bean id="daoAuthenticationProvider" class="org.acegisecurity.providers.dao.DaoAuthenticationProvider"&gt;  <br />
&lt;property name="userDetailsService" ref="<span style="font-weight: bold;">jdbcDaoImpl</span>"/&gt;<br />
&lt;/bean&gt; <br />
<br />
<span style="font-weight: bold;">   &lt;bean id="jdbcDaoImpl" class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl"&gt;  </span><br style="font-weight: bold;" />
<span style="font-weight: bold;">       &lt;property name="dataSource" ref="dataSource"/&gt;</span><br style="font-weight: bold;" />
<span style="font-weight: bold;">   &lt;/bean&gt;  </span><br />
<br />
&lt;!-- 发生验证错误或权限错误时的处理 --&gt;<br />
&lt;bean id="exceptionTranslationFilter" class="org.acegisecurity.ui.ExceptionTranslationFilter"&gt;  <br />
&lt;property name="authenticationEntryPoint"&gt;  <br />
&lt;bean class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint"&gt;  <br />
&lt;property name="loginFormUrl" value="/acegilogin.jsp"/&gt;  <br />
&lt;property name="forceHttps" value="false"/&gt;  <br />
&lt;/bean&gt;  <br />
&lt;/property&gt;  <br />
&lt;property name="accessDeniedHandler"&gt;  <br />
&lt;bean class="org.acegisecurity.ui.AccessDeniedHandlerImpl"&gt;  <br />
&lt;property name="errorPage" value="/accessDenied.jsp"/&gt;  <br />
&lt;/bean&gt;  <br />
&lt;/property&gt;  <br />
&lt;/bean&gt;    <br />
<br />
&lt;!-- FilterSecurityInterceptor 对 URI 进行保护 --&gt;<br />
&lt;bean id="filterSecurityInterceptor"<br />
class="org.acegisecurity.intercept.web.FilterSecurityInterceptor"&gt;<br />
&lt;!-- 验证管理员 --&gt;<br />
&lt;property name="authenticationManager" ref="authenticationManager" /&gt;<br />
&lt;!-- 授权管理员 --&gt;<br />
&lt;property name="accessDecisionManager" ref="accessDecisionManager" /&gt;<br />
&lt;property name="objectDefinitionSource"&gt;<br />
&lt;value&gt;<br />
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON<br />
PATTERN_TYPE_APACHE_ANT<br />
/protected/**=ROLE_SUPERVISOR,ROLE_USER<br />
&lt;/value&gt;<br />
&lt;/property&gt;<br />
&lt;/bean&gt;<br />
<br />
&lt;!-- 授权管理员 --&gt;<br />
&lt;bean id="accessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased"&gt;<br />
&lt;!-- 是否全部弃权时视为通过 --&gt;<br />
&lt;property name="allowIfAllAbstainDecisions" value="false" /&gt;<br />
&lt;property name="decisionVoters"&gt;<br />
&lt;list&gt;<br />
&lt;bean class="org.acegisecurity.vote.RoleVoter" /&gt;<br />
&lt;/list&gt;<br />
&lt;/property&gt;<br />
&lt;/bean&gt;        <br />
<br />
&lt;!-- 利用cookie自动登入 --&gt;  <br />
&lt;bean id="rememberMeProcessingFilter"  <br />
class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter"&gt;  <br />
&lt;property name="authenticationManager"  ref="authenticationManager"/&gt;  <br />
&lt;property name="rememberMeServices" ref="rememberMeServices"/&gt;  <br />
&lt;/bean&gt;      <br />
&lt;bean id="rememberMeServices"  <br />
class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices"&gt;  <br />
&lt;property name="userDetailsService" ref="<span style="font-weight: bold;">jdbcDaoImpl</span>"/&gt;  <br />
&lt;property name="key" value="javauser"/&gt;  <br />
&lt;/bean&gt;<br />
&lt;bean id="rememberMeAuthenticationProvider"  <br />
class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider"&gt;  <br />
&lt;property name="key" value="javauser"/&gt;  <br />
&lt;/bean&gt;   <br />
<br />
&lt;!-- 登出处理 --&gt;  <br />
&lt;bean id="logoutFilter" class="org.acegisecurity.ui.logout.LogoutFilter"&gt;  <br />
&lt;constructor-arg value="/acegilogin.jsp"/&gt; &lt;!-- 登出后的显示页面 --&gt;  <br />
&lt;constructor-arg&gt;  <br />
&lt;list&gt;  <br />
&lt;bean class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler"/&gt;  <br />
&lt;/list&gt;  <br />
&lt;/constructor-arg&gt;  <br />
&lt;/bean&gt; <br />
<br />
&lt;bean id="httpSessionContextIntegrationFilter"<br />
class="org.acegisecurity.context.HttpSessionContextIntegrationFilter" /&gt;<br />
<br />
&lt;!-- Filter Chain --&gt;<br />
&lt;bean id="filterChainProxy" class="org.acegisecurity.util.FilterChainProxy"&gt;  <br />
&lt;property name="filterInvocationDefinitionSource"&gt;  <br />
&lt;value&gt;  <br />
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON <br />
PATTERN_TYPE_APACHE_ANT <br />
/**=httpSessionContextIntegrationFilter,authenticationProcessingFilter,exceptionTranslationFilter,<br />
filterSecurityInterceptor,logoutFilter,rememberMeProcessingFilter<br />
&lt;/value&gt; <br />
&lt;/property&gt; <br />
&lt;/bean&gt;    <br />
&lt;/beans&gt;   </pre>
<br />
当然，别忘了在您的Web应用程式的lib中，加入JDBC驱动程式程式库。
<img src ="http://www.blogjava.net/liuzheng/aggbug/231327.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2008-09-26 17:00 <a href="http://www.blogjava.net/liuzheng/articles/231327.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Acegi学习笔记</title><link>http://www.blogjava.net/liuzheng/articles/231325.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Fri, 26 Sep 2008 08:59:00 GMT</pubDate><guid>http://www.blogjava.net/liuzheng/articles/231325.html</guid><wfw:comment>http://www.blogjava.net/liuzheng/comments/231325.html</wfw:comment><comments>http://www.blogjava.net/liuzheng/articles/231325.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuzheng/comments/commentRss/231325.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuzheng/services/trackbacks/231325.html</trackback:ping><description><![CDATA[很好的<br />
http://caterpillar.onlyfun.net/GossipCN/AcegiGossip/AcegiGossip.html<br />
<img src ="http://www.blogjava.net/liuzheng/aggbug/231325.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuzheng/" target="_blank">刘铮 </a> 2008-09-26 16:59 <a href="http://www.blogjava.net/liuzheng/articles/231325.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>