锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 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. 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. 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+.
the "FilterInvocationDefinitionSourceEditor" = "filterInvocationDefinitionSource" plus "editor" ignore the case.
That is exactly what Spring do.
in acegi , "filterInvocationDefinitionSource"聽 use to store urls for filering,so when u understand the its struture ,u can
get the url for database,not explicitly.
for the key word " CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON",it means u must
set the聽properties name lower case,otherwise will be error.
and "聽 PATTERN_TYPE_APACHE_ANT" means use class PathBasedFilterInvocationDefinitionMap,default use
class RegExpBasedFilterInvocationDefinitionMap.
]]>
聽聽聽聽聽聽聽聽聽 class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
聽聽聽聽聽聽聽 <property name="basename">
聽聽聽聽聽聽聽聽聽聽聽 <value>com/suzsoft/jportal/usermanagement/acegi/ApplicationMessages_zh_CN</value>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽 <property name="alwaysUseMessageFormat" value="true"/>
聽聽聽 </bean>
this from the reference,but the ReloadableResourceBundleMessageSource seems never init and i don't konw how to make it work.
at the last ,I use
聽 <bean id="messageSource"
聽聽聽聽聽聽聽聽聽 class="org.springframework.context.support.ResourceBundleMessageSource">
聽聽聽聽聽聽聽 <property name="basename">
聽聽聽聽聽聽聽聽聽聽聽 <value>com.suzsoft.jportal.usermanagement.acegi.ApplicationMessages</value>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽 <property name="alwaysUseMessageFormat" value="true"/>
聽</bean>
ResourceBundleMessageSource:setBasename
public void setBasename(String聽basename)
ReloadableResourceBundleMessageSource:setBasename
public void setBasename(String聽basename)
]]>
The below feature聽 make聽much effect in my project:
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.
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)
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
security level!
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?
after set property "sessionController",below is the variety:
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.
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
url will redirect to the loginfromurl.before this url will continuate with last authed user.
3.session will not auto expire after long time idlesse.
<!--
聽- A simple "base bones" Acegi Security configuration.
聽-
聽- The sample includes the "popular" features that people tend to use.
聽- Specifically, form authentication, remember-me, and anonymous processing.
聽- Other features aren't setup, as these can be added later by inserting
聽- the relevant XML fragments as specified in the Reference Guide.
聽-
聽- To assist new users, the filters specified in the FilterChainProxy are
聽- declared in the application context in the same order. Collaborators
聽- required by those filters are placed at the end of the file.
聽-
聽- $Id: applicationContext-acegi-security.xml,v 1.1 2006/10/17 02:58:44 ronald.feng Exp $
-->
<beans>
聽聽聽 <bean id="filterChainProxy"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.util.FilterChainProxy">
聽聽聽聽聽聽聽 <property name="filterInvocationDefinitionSource">
聽聽聽聽聽聽聽聽聽聽聽 <value>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 PATTERN_TYPE_APACHE_ANT
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 /**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
聽聽聽聽聽聽聽聽聽聽聽 </value>
聽聽聽聽聽聽聽 </property>
聽聽聽 </bean>
聽聽聽 <bean id="httpSessionContextIntegrationFilter"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.context.HttpSessionContextIntegrationFilter"/>
聽聽聽 <bean id="logoutFilter"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.ui.logout.LogoutFilter">
聽聽聽聽聽聽聽 <constructor-arg value="/login.jsp"/>
聽聽聽聽聽聽聽 <!-- URL redirected to after logout -->
聽聽聽聽聽聽聽 <constructor-arg>
聽聽聽聽聽聽聽聽聽聽聽 <list>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <ref bean="rememberMeServices"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler"/>
聽聽聽聽聽聽聽聽聽聽聽 </list>
聽聽聽聽聽聽聽 </constructor-arg>
聽聽聽 </bean>
聽聽聽 <bean id="authenticationProcessingFilter"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
聽聽聽聽聽聽聽 <property name="authenticationManager"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ref="authenticationManager"/>
聽聽聽聽聽聽聽 <property name="authenticationFailureUrl"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 value="/login.jsp?login_error=1"/>
聽聽聽聽聽聽聽 <property name="defaultTargetUrl" value="/"/>
聽聽聽聽聽聽聽 <property name="filterProcessesUrl"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 value="/j_acegi_security_check"/>
聽聽聽聽聽聽聽 <property name="rememberMeServices" ref="rememberMeServices"/>
聽聽聽 </bean>
聽聽聽 <bean id="securityContextHolderAwareRequestFilter"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter"/>
聽聽聽 <bean id="rememberMeProcessingFilter"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter">
聽聽聽聽聽聽聽 <property name="authenticationManager"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ref="authenticationManager"/>
聽聽聽聽聽聽聽 <property name="rememberMeServices" ref="rememberMeServices"/>
聽聽聽 </bean>
聽聽聽 <bean id="anonymousProcessingFilter"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter">
聽聽聽聽聽聽聽 <property name="key" value="changeThis"/>
聽聽聽聽聽聽聽 <property name="userAttribute"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 value="anonymousUser,ROLE_ANONYMOUS"/>
聽聽聽 </bean>
聽聽聽 <bean id="exceptionTranslationFilter"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.ui.ExceptionTranslationFilter">
聽聽聽聽聽聽聽 <property name="authenticationEntryPoint">
聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="loginFormUrl" value="/login.jsp"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="forceHttps" value="false"/>
聽聽聽聽聽聽聽聽聽聽聽 </bean>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽 <property name="accessDeniedHandler">
聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.ui.AccessDeniedHandlerImpl">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="errorPage" value="/accessDenied.jsp"/>
聽聽聽聽聽聽聽聽聽聽聽 </bean>
聽聽聽聽聽聽聽 </property>
聽聽聽 </bean>
聽聽聽 <bean id="filterInvocationInterceptor"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
聽聽聽聽聽聽聽 <property name="authenticationManager"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 ref="authenticationManager"/>
聽聽聽聽聽聽聽 <property name="accessDecisionManager">
聽聽聽聽聽聽聽聽聽聽聽 <bean class="org.acegisecurity.vote.AffirmativeBased">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="allowIfAllAbstainDecisions"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 value="false"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="decisionVoters">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <list>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <bean class="org.acegisecurity.vote.RoleVoter"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.vote.AuthenticatedVoter"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </list>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽聽聽聽聽 </bean>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽 <property name="objectDefinitionSource">
聽聽聽聽聽聽聽聽聽聽聽 <value>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 PATTERN_TYPE_APACHE_ANT
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 /images/**=IS_AUTHENTICATED_ANONYMOUSLY
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 /css/**=IS_AUTHENTICATED_ANONYMOUSLY
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 /scripts/**=IS_AUTHENTICATED_ANONYMOUSLY
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 /login.jsp=IS_AUTHENTICATED_ANONYMOUSLY
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 /error.jsp=IS_AUTHENTICATED_ANONYMOUSLY
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <!-- this for .do url!remember acegi is only for url and can filter for any url! -->
聽<!--聽or聽 staff/searchstaff.do=ROLE_ADMIN_TEST -->
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 /staff/**=ROLE_ADMIN_TEST
聽聽聽聽聽聽聽聽聽聽聽 </value>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽
聽聽聽 </bean>
聽聽聽 <bean id="rememberMeServices"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices">
聽聽聽聽聽聽聽 <property name="userDetailsService" ref="userDetailsService"/>
聽聽聽聽聽聽聽 <property name="key" value="changeThis"/>
聽聽聽 </bean>
聽聽聽 <bean id="authenticationManager"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.providers.ProviderManager">
聽聽聽聽聽聽聽 <property name="providers">
聽聽聽聽聽聽聽聽聽聽聽 <list>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <ref local="daoAuthenticationProvider"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="key" value="changeThis"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </bean>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.providers.rememberme.RememberMeAuthenticationProvider">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="key" value="changeThis"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </bean>
聽聽聽聽聽聽聽聽聽聽聽 </list>
聽聽聽聽聽聽聽 </property>
聽聽聽 </bean>
聽聽聽 <bean id="daoAuthenticationProvider"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
聽聽聽聽聽聽聽 <property name="userDetailsService" ref="userDetailsService"/>
聽聽聽聽聽聽聽 <property name="userCache">
聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="cache">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.springframework.cache.ehcache.EhCacheFactoryBean">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="cacheManager">
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <bean
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 <property name="cacheName" value="userCache"/>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </bean>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽聽聽聽聽 </bean>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽 <property name="passwordEncoder" ref="passwordEncoder"/>
聽聽聽 </bean>
聽聽聽 <bean id="passwordEncoder"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.providers.encoding.Md5PasswordEncoder"/>
聽聽聽 <!-- UserDetailsService is the most commonly frequently Acegi Security interface implemented by end users -->
聽聽聽 <!--<bean id="c"-->
聽聽聽 <!--class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl">-->
聽聽聽 <!--<property name="userProperties">-->
聽聽聽 <!--<bean-->
聽聽聽 <!--class="org.springframework.beans.factory.config.PropertiesFactoryBean">-->
聽聽聽 <!--<property name="location"-->
聽聽聽 <!--value="/WEB-INF/users.properties" />-->
聽聽聽 <!--</bean>-->
聽聽聽 <!--</property>-->
聽聽聽 <!--</bean>-->
聽聽聽 <bean id="userDetailsService" class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
聽聽聽聽聽聽聽 <property name="dataSource">
聽聽聽聽聽聽聽聽聽聽聽 <ref bean="dataSource"/>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽 <property name="authoritiesByUsernameQuery">
聽聽聽聽聽聽聽聽聽聽聽 <value>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 SELECT account,'ROLE_ADMIN' as authority FROM TB_STAFF WHERE account = ?
聽聽聽聽聽聽聽聽聽聽聽 </value>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽 <property name="usersByUsernameQuery">
聽聽聽聽聽聽聽聽聽聽聽 <value>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 SELECT account,password, 1 as enabled FROM TB_STAFF WHERE account = ?
聽聽聽聽聽聽聽聽聽聽聽 </value>
聽聽聽聽聽聽聽 </property>
聽聽聽 </bean>
聽聽聽 <!-- This bean is optional; it isn't used by any other bean as it only listens and logs -->
聽聽聽 <bean id="loggerListener"
聽聽聽聽聽聽聽聽聽 class="org.acegisecurity.event.authentication.LoggerListener"/>
</beans>
---------------------------------------------------------------------------------------------------------------