﻿<?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-VIRGIN FOREST OF JAVA-文章分类-Acegi Security</title><link>http://www.blogjava.net/RR00/category/16366.html</link><description>不要埋头苦干，要学习，学习，再学习。。。。。
&lt;br&gt;
powered  by &lt;font color='orange'&gt;R.Zeus&lt;/font&gt;</description><language>zh-cn</language><lastBuildDate>Thu, 08 Mar 2007 06:43:23 GMT</lastBuildDate><pubDate>Thu, 08 Mar 2007 06:43:23 GMT</pubDate><ttl>60</ttl><item><title>acegi in spring</title><link>http://www.blogjava.net/RR00/articles/102379.html</link><dc:creator>R.Zeus</dc:creator><author>R.Zeus</author><pubDate>Wed, 07 Mar 2007 05:24:00 GMT</pubDate><guid>http://www.blogjava.net/RR00/articles/102379.html</guid><wfw:comment>http://www.blogjava.net/RR00/comments/102379.html</wfw:comment><comments>http://www.blogjava.net/RR00/articles/102379.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/RR00/comments/commentRss/102379.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/RR00/services/trackbacks/102379.html</trackback:ping><description><![CDATA[when read the acgi.xml and according source code,I found the way spring read the value ,on the other hand,how spring choose the editor to resolve the value.<br />for example,the "filterInvocationDefinitionSource" properties,Spring will choose the class "FilterInvocationDefinitionSourceEditor" to solve  the "filterInvocationDefinitionSource".u may notes that <br />the "FilterInvocationDefinitionSourceEditor" = "filterInvocationDefinitionSource" plus "editor" ignore the case.<br />That is exactly what Spring do.<br /><br />in acegi , "filterInvocationDefinitionSource"  use to store urls for filering,so when u understand the its struture ,u can <br />get the url for database,not explicitly.<br /><br />for the key word " CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON",it means u must <br />set the properties name lower case,otherwise will be error.<br /><br />and "  PATTERN_TYPE_APACHE_ANT" means use class PathBasedFilterInvocationDefinitionMap,default use<br />class RegExpBasedFilterInvocationDefinitionMap.<img src ="http://www.blogjava.net/RR00/aggbug/102379.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/RR00/" target="_blank">R.Zeus</a> 2007-03-07 13:24 <a href="http://www.blogjava.net/RR00/articles/102379.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>i18n-fuck the ReloadableResourceBundleMessageSource</title><link>http://www.blogjava.net/RR00/articles/76821.html</link><dc:creator>R.Zeus</dc:creator><author>R.Zeus</author><pubDate>Mon, 23 Oct 2006 12:11:00 GMT</pubDate><guid>http://www.blogjava.net/RR00/articles/76821.html</guid><wfw:comment>http://www.blogjava.net/RR00/comments/76821.html</wfw:comment><comments>http://www.blogjava.net/RR00/articles/76821.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/RR00/comments/commentRss/76821.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/RR00/services/trackbacks/76821.html</trackback:ping><description><![CDATA[
		<font style="BACKGROUND-COLOR: #ffffff" color="#0000ff"> &lt;bean id="messageSource"<br />          class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;<br />        &lt;property name="basename"&gt;<br />            &lt;value&gt;com/suzsoft/jportal/usermanagement/acegi/ApplicationMessages_zh_CN&lt;/value&gt;<br />        &lt;/property&gt;<br />        &lt;property name="alwaysUseMessageFormat" value="true"/&gt;<br />    &lt;/bean&gt;<br /><br /><br /><font color="#000000">this from the reference,but the ReloadableResourceBundleMessageSource seems never init and i don't konw how to make it work.<br /><br />at the last ,I use</font><br /><br />  &lt;bean id="messageSource"<br />          class="org.springframework.context.support.ResourceBundleMessageSource"&gt;<br />        &lt;property name="basename"&gt;<br />            &lt;value&gt;com.suzsoft.jportal.usermanagement.acegi.ApplicationMessages&lt;/value&gt;<br />        &lt;/property&gt;<br />        &lt;property name="alwaysUseMessageFormat" value="true"/&gt;<br /> &lt;/bean&gt;<br /><br /><font color="#ee82ee">ResourceBundleMessageSource:</font><br /><h3>setBasename</h3><pre>public void <b>setBasename</b>(<a title="class or interface in java.lang" href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html">String</a> basename)</pre><p>Set a single basename, following ResourceBundle conventions: It is a fully-qualified classname. If it doesn't contain a package qualifier (such as org.mypackage), it will be resolved from the classpath root. </p><p>Messages will normally be held in the /lib or /classes directory of a WAR. They can also be held in Jars on the class path. For example, a Jar in an application's manifest classpath could contain messages for the application. <br /><br /><font color="#ffc0cb">ReloadableResourceBundleMessageSource:</font><br /><br /></p><h3>setBasename</h3><pre>public void <b>setBasename</b>(<a title="class or interface in java.lang" href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html"><font color="#002c99">String</font></a> basename)</pre><dl><dd>Set a single basename, following the basic ResourceBundle convention of not specifying file extension or language codes, but in contrast to ResourceBundleMessageSource referring to a Spring resource location: e.g. "WEB-INF/messages" for "WEB-INF/messages.properties", "WEB-INF/messages_en.properties", etc. 
<p>As of Spring 1.2.2, XML properties files are also supported: e.g. "WEB-INF/messages" will find and load "WEB-INF/messages.xml", "WEB-INF/messages_en.xml", etc as well. Note that this will only work on JDK 1.5+. </p><p></p><br /></dd></dl></font>
<img src ="http://www.blogjava.net/RR00/aggbug/76821.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/RR00/" target="_blank">R.Zeus</a> 2006-10-23 20:11 <a href="http://www.blogjava.net/RR00/articles/76821.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>acegi security is so perfect for  login filter</title><link>http://www.blogjava.net/RR00/articles/76254.html</link><dc:creator>R.Zeus</dc:creator><author>R.Zeus</author><pubDate>Thu, 19 Oct 2006 13:14:00 GMT</pubDate><guid>http://www.blogjava.net/RR00/articles/76254.html</guid><wfw:comment>http://www.blogjava.net/RR00/comments/76254.html</wfw:comment><comments>http://www.blogjava.net/RR00/articles/76254.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/RR00/comments/commentRss/76254.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/RR00/services/trackbacks/76254.html</trackback:ping><description><![CDATA[
		<p>After use it first time in an project ,I found it so goodt!My project use struts+tiles+spring+acegi security+hibernate.<br />The below feature  make much effect in my project:<br /><br />1.when logout and then click 'back' button in the IE Toolbars  to the last page which will be expired and auto redirect to appointed URL.<br />2.if client login the system but do nothing too long ,the session will be detected and expired!but as far I don't know how did the Acegi Security implements this.(this feature is seems in spring or tomcat,after set the sessionRegistor in Acegi Security ,it is not validate)<br />3.Acegi Security can control How the same username can logined in different ip!e.g. the same username can login many from ip or just can only login once.for single login,there are two case:the next login will be forbided ; the next login is permited and the first login auto out fo session.it is depend on the<br />security level!<br /><br />one thing not resolved is that if there are two different user sign in on the same mache,the prev-user will auto session expired.How to achieve this?<br /><br />after set property "sessionController",below is the variety:<br />1.auto login; if there is one user sign ,and then open a new IE to address a url need auth ,the url will redirect to the loginfromurl.but befor set this property, the url will open a page with the signed user.<br />2.if there is a url needed auth on the IE address(this may be left by last login and not logout),after server restar,the <br />url will redirect to the loginfromurl.before this url will continuate with last authed user.<br />3.session will not auto expire after long time idlesse.</p>
<img src ="http://www.blogjava.net/RR00/aggbug/76254.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/RR00/" target="_blank">R.Zeus</a> 2006-10-19 21:14 <a href="http://www.blogjava.net/RR00/articles/76254.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Acegi Security and Struts</title><link>http://www.blogjava.net/RR00/articles/75582.html</link><dc:creator>R.Zeus</dc:creator><author>R.Zeus</author><pubDate>Tue, 17 Oct 2006 05:07:00 GMT</pubDate><guid>http://www.blogjava.net/RR00/articles/75582.html</guid><wfw:comment>http://www.blogjava.net/RR00/comments/75582.html</wfw:comment><comments>http://www.blogjava.net/RR00/articles/75582.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/RR00/comments/commentRss/75582.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/RR00/services/trackbacks/75582.html</trackback:ping><description><![CDATA[
		<p>Acegi Secutiry is for URL-ROLE,and in Struts every method is mapping to a URL,so they are integrating is so perfect!<br /><br />applicationContext-acegi-security.xml<br /><font style="BACKGROUND-COLOR: #ff1493">---------------------------------------------------------------------------------------------------------------<br /></font>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "<a href="http://www.springframework.org/dtd/spring-beans.dtd">http://www.springframework.org/dtd/spring-beans.dtd</a>"&gt;</p>
		<p>&lt;!--<br /> - A simple "base bones" Acegi Security configuration.<br /> -<br /> - The sample includes the "popular" features that people tend to use.<br /> - Specifically, form authentication, remember-me, and anonymous processing.<br /> - Other features aren't setup, as these can be added later by inserting<br /> - the relevant XML fragments as specified in the Reference Guide.<br /> -<br /> - To assist new users, the filters specified in the FilterChainProxy are<br /> - declared in the application context in the same order. Collaborators<br /> - required by those filters are placed at the end of the file.<br /> -<br /> - $Id: applicationContext-acegi-security.xml,v 1.1 2006/10/17 02:58:44 ronald.feng Exp $<br />--&gt;</p>
		<p>&lt;beans&gt;</p>
		<p>    &lt;bean id="filterChainProxy"<br />          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,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor<br />            &lt;/value&gt;<br />        &lt;/property&gt;<br />    &lt;/bean&gt;</p>
		<p>    &lt;bean id="httpSessionContextIntegrationFilter"<br />          class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"/&gt;</p>
		<p>    &lt;bean id="logoutFilter"<br />          class="org.acegisecurity.ui.logout.LogoutFilter"&gt;<br />        &lt;constructor-arg value="/login.jsp"/&gt;<br />        &lt;!-- URL redirected to after logout --&gt;<br />        &lt;constructor-arg&gt;<br />            &lt;list&gt;<br />                &lt;ref bean="rememberMeServices"/&gt;<br />                &lt;bean<br />                        class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler"/&gt;<br />            &lt;/list&gt;<br />        &lt;/constructor-arg&gt;<br />    &lt;/bean&gt;</p>
		<p>    &lt;bean id="authenticationProcessingFilter"<br />          class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"&gt;<br />        &lt;property name="authenticationManager"<br />                  ref="authenticationManager"/&gt;</p>
		<p>        &lt;property name="authenticationFailureUrl"<br />                  value="/login.jsp?login_error=1"/&gt;<br />        &lt;property name="defaultTargetUrl" value="/"/&gt;<br />        &lt;property name="filterProcessesUrl"<br />                  value="/j_acegi_security_check"/&gt;<br />        &lt;property name="rememberMeServices" ref="rememberMeServices"/&gt;</p>
		<p>    &lt;/bean&gt;</p>
		<p>    &lt;bean id="securityContextHolderAwareRequestFilter"<br />          class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter"/&gt;</p>
		<p>    &lt;bean id="rememberMeProcessingFilter"<br />          class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter"&gt;<br />        &lt;property name="authenticationManager"<br />                  ref="authenticationManager"/&gt;<br />        &lt;property name="rememberMeServices" ref="rememberMeServices"/&gt;<br />    &lt;/bean&gt;</p>
		<p>    &lt;bean id="anonymousProcessingFilter"<br />          class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter"&gt;<br />        &lt;property name="key" value="changeThis"/&gt;<br />        &lt;property name="userAttribute"<br />                  value="anonymousUser,ROLE_ANONYMOUS"/&gt;<br />    &lt;/bean&gt;</p>
		<p>    &lt;bean id="exceptionTranslationFilter"<br />          class="org.acegisecurity.ui.ExceptionTranslationFilter"&gt;<br />        &lt;property name="authenticationEntryPoint"&gt;<br />            &lt;bean<br />                    class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint"&gt;<br />                &lt;property name="loginFormUrl" value="/login.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<br />                    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;</p>
		<p>    &lt;bean id="filterInvocationInterceptor"<br />          class="org.acegisecurity.intercept.web.FilterSecurityInterceptor"&gt;</p>
		<p>        &lt;property name="authenticationManager"<br />                  ref="authenticationManager"/&gt;</p>
		<p>        &lt;property name="accessDecisionManager"&gt;<br />            &lt;bean class="org.acegisecurity.vote.AffirmativeBased"&gt;<br />                &lt;property name="allowIfAllAbstainDecisions"<br />                          value="false"/&gt;<br />                &lt;property name="decisionVoters"&gt;<br />                    &lt;list&gt;<br />                        &lt;bean class="org.acegisecurity.vote.RoleVoter"/&gt;<br />                        &lt;bean<br />                                class="org.acegisecurity.vote.AuthenticatedVoter"/&gt;<br />                    &lt;/list&gt;<br />                &lt;/property&gt;</p>
		<p>            &lt;/bean&gt;<br />        &lt;/property&gt;</p>
		<p>        &lt;property name="objectDefinitionSource"&gt;<br />            &lt;value&gt;<br />                CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON<br />                PATTERN_TYPE_APACHE_ANT<br />                /images/**=IS_AUTHENTICATED_ANONYMOUSLY<br />                /css/**=IS_AUTHENTICATED_ANONYMOUSLY<br />                /scripts/**=IS_AUTHENTICATED_ANONYMOUSLY<br />                /login.jsp=IS_AUTHENTICATED_ANONYMOUSLY<br />                /error.jsp=IS_AUTHENTICATED_ANONYMOUSLY</p>
		<p>             <font style="BACKGROUND-COLOR: #ffc0cb">   &lt;!-- this for .do url!remember acegi is only for url and can filter for any url! --&gt;<br /> &lt;!-- or  <font color="#0000ff">staff/searchstaff.do=ROLE_ADMIN_TEST</font> --&gt;<br />                /staff/**=ROLE_ADMIN_TEST<br /><br /></font>            &lt;/value&gt;<br />        &lt;/property&gt;<br />        </p>
		<p>    &lt;/bean&gt;</p>
		<p>    &lt;bean id="rememberMeServices"<br />          class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices"&gt;<br />        &lt;property name="userDetailsService" ref="userDetailsService"/&gt;<br />        &lt;property name="key" value="changeThis"/&gt;<br />    &lt;/bean&gt;</p>
		<p>    &lt;bean id="authenticationManager"<br />          class="org.acegisecurity.providers.ProviderManager"&gt;<br />        &lt;property name="providers"&gt;<br />            &lt;list&gt;<br />                &lt;ref local="daoAuthenticationProvider"/&gt;<br />                &lt;bean<br />                        class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider"&gt;<br />                    &lt;property name="key" value="changeThis"/&gt;<br />                &lt;/bean&gt;<br />                &lt;bean<br />                        class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider"&gt;<br />                    &lt;property name="key" value="changeThis"/&gt;<br />                &lt;/bean&gt;<br />            &lt;/list&gt;<br />        &lt;/property&gt;<br />    &lt;/bean&gt;</p>
		<p>    &lt;bean id="daoAuthenticationProvider"<br />          class="org.acegisecurity.providers.dao.DaoAuthenticationProvider"&gt;<br />        &lt;property name="userDetailsService" ref="userDetailsService"/&gt;<br />        &lt;property name="userCache"&gt;<br />            &lt;bean<br />                    class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache"&gt;<br />                &lt;property name="cache"&gt;<br />                    &lt;bean<br />                            class="org.springframework.cache.ehcache.EhCacheFactoryBean"&gt;<br />                        &lt;property name="cacheManager"&gt;<br />                            &lt;bean<br />                                    class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/&gt;<br />                        &lt;/property&gt;<br />                        &lt;property name="cacheName" value="userCache"/&gt;<br />                    &lt;/bean&gt;<br />                &lt;/property&gt;<br />            &lt;/bean&gt;<br />        &lt;/property&gt;<br />        &lt;property name="passwordEncoder" ref="passwordEncoder"/&gt;<br />    &lt;/bean&gt;</p>
		<p>    &lt;bean id="passwordEncoder"</p>
		<p>          class="org.acegisecurity.providers.encoding.Md5PasswordEncoder"/&gt;</p>
		<p>    &lt;!-- UserDetailsService is the most commonly frequently Acegi Security interface implemented by end users --&gt;<br />    &lt;!--&lt;bean id="c"--&gt;<br />    &lt;!--class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl"&gt;--&gt;<br />    &lt;!--&lt;property name="userProperties"&gt;--&gt;<br />    &lt;!--&lt;bean--&gt;<br />    &lt;!--class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt;--&gt;<br />    &lt;!--&lt;property name="location"--&gt;<br />    &lt;!--value="/WEB-INF/users.properties" /&gt;--&gt;<br />    &lt;!--&lt;/bean&gt;--&gt;<br />    &lt;!--&lt;/property&gt;--&gt;<br />    &lt;!--&lt;/bean&gt;--&gt;<br />    &lt;bean id="userDetailsService" class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl"&gt;<br />        &lt;property name="dataSource"&gt;<br />            &lt;ref bean="dataSource"/&gt;<br />        &lt;/property&gt;<br />        &lt;property name="authoritiesByUsernameQuery"&gt;<br />            &lt;value&gt;<br />                SELECT account,'ROLE_ADMIN' as authority FROM TB_STAFF WHERE account = ?<br />            &lt;/value&gt;<br />        &lt;/property&gt;<br />        &lt;property name="usersByUsernameQuery"&gt;<br />            &lt;value&gt;<br />                SELECT account,password, 1 as enabled FROM TB_STAFF WHERE account = ?</p>
		<p>            &lt;/value&gt;<br />        &lt;/property&gt;<br />    &lt;/bean&gt;</p>
		<p>    &lt;!-- This bean is optional; it isn't used by any other bean as it only listens and logs --&gt;<br />    &lt;bean id="loggerListener"<br />          class="org.acegisecurity.event.authentication.LoggerListener"/&gt;</p>
		<p>&lt;/beans&gt;<br /><font style="BACKGROUND-COLOR: #ff1493">---------------------------------------------------------------------------------------------------------------</font><br /></p>
<img src ="http://www.blogjava.net/RR00/aggbug/75582.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/RR00/" target="_blank">R.Zeus</a> 2006-10-17 13:07 <a href="http://www.blogjava.net/RR00/articles/75582.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>