spring security 配置

  1. <?xml version= "1.0"  encoding= "UTF-8" ?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"   
  3.     xmlns:aop="http://www.springframework.org/schema/aop"  xmlns:context= "http://www.springframework.org/schema/context"   
  4.     xmlns:jee="http://www.springframework.org/schema/jee"  xmlns:jms= "http://www.springframework.org/schema/jms"   
  5.     xmlns:p="http://www.springframework.org/schema/p"  xmlns:tx= "http://www.springframework.org/schema/tx"   
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   
  7.         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd   
  8.         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd   
  9.         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd   
  10.         http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd   
  11.         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">   
  12.       
  13.       
  14.     <!-- login start -->  
  15.     <bean id="filterChainProxy"   class = "org.springframework.security.util.FilterChainProxy" >  
  16.         <property name="filterInvocationDefinitionSource" >  
  17.             <value><![CDATA[  
  18.                 CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON  
  19.                 PATTERN_TYPE_APACHE_ANT  
  20.                 /**=channelProcessingFilter,httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,concurrentSessionFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterSecurityInterceptor  
  21.             ]]></value>  
  22.                 <!-- securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter, -->  
  23.         </property>  
  24.     </bean>  
  25.       
  26.     <bean id="httpSessionContextIntegrationFilter"   class = "org.springframework.security.context.HttpSessionContextIntegrationFilter" />  
  27.       
  28.     <!-- login out -->  
  29.     <bean id="logoutFilter"   class = "org.springframework.security.ui.logout.LogoutFilter" >  
  30.         <constructor-arg>  
  31.             <list>  
  32.                 <bean class = "org.springframework.security.ui.logout.SecurityContextLogoutHandler" />  
  33.             </list>  
  34.         </constructor-arg>  
  35.         <constructor-arg value="/web/page/login/login_out_success.jsp" />  
  36.         <property name="filterProcessesUrl"  value= "/loginout.do" />  
  37.     </bean>  
  38.       
  39.     <!-- login -->  
  40.     <bean id="authenticationProcessingFilter"   class = "org.springframework.security.ui.webapp.AuthenticationProcessingFilter" >  
  41.         <property name="filterProcessesUrl"  value= "/login.do" />  
  42.         <property name="defaultTargetUrl"  value= "/web/page/login/login_name.jsp" />  
  43.         <property name="authenticationFailureUrl"  value= "http://www.baidu.com" />  
  44.         <property name="authenticationManager"  ref= "authenticationManager" />  
  45.         <property name="rememberMeServices"  ref= "rememberMeServices" />  
  46.     </bean>  
  47.     <bean id="authenticationManager"   class = "org.springframework.security.providers.ProviderManager" >  
  48.         <property name="providers" >  
  49.             <list>  
  50.                 <ref bean="daoAuthenticationProvider" />  
  51.                 <bean class = "org.springframework.security.providers.rememberme.RememberMeAuthenticationProvider" >  
  52.                     <property name="key"  value= "hereonline" />  
  53.                 </bean>  
  54.                 <ref local="anonymousAuthenticationProvider" />  
  55.             </list>  
  56.         </property>  
  57.         <property name="sessionController"  ref= "concurrentSessionController" />  
  58.     </bean>  
  59.       
  60.     <bean id="daoAuthenticationProvider"   class = "org.springframework.security.providers.dao.DaoAuthenticationProvider" >  
  61.         <property name="userDetailsService"  ref= "hoUserDAO" ></property>  
  62.     </bean>  
  63.       
  64.     <!-- login start end-->  
  65.       
  66.       
  67.     <!-- url -->  
  68.     <bean id="filterSecurityInterceptor"   class = "org.springframework.security.intercept.web.FilterSecurityInterceptor" >  
  69.         <property name="authenticationManager"  ref= "authenticationManager" />  
  70.         <property name="accessDecisionManager"  ref= "accessDecisionManager" />  
  71.         <property name="objectDefinitionSource" >  
  72.             <value>  
  73.                 CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON  
  74.                 PATTERN_TYPE_APACHE_ANT  
  75.                 /web/page/login/login_id.jsp = PRI_1,PRI_ADMIN  
  76.             </value>  
  77.         </property>         
  78.     </bean>  
  79.       
  80.     <bean id="accessDecisionManager"   class = "org.springframework.security.vote.AffirmativeBased" >  
  81.         <property name="allowIfAllAbstainDecisions"  value= "true" />  
  82.         <property name="decisionVoters" >  
  83.             <list>  
  84.                 <ref bean="roleVoter" />  
  85.             </list>  
  86.         </property>  
  87.     </bean>  
  88.       
  89.     <bean id="roleVoter"   class = "org.springframework.security.vote.RoleVoter" >  
  90.         <property name="rolePrefix"  value= "PRI_" ></property>  
  91.     </bean>  
  92.       
  93.     <!-- exception convert -->  
  94.     <bean id="exceptionTranslationFilter"   class = "org.springframework.security.ui.ExceptionTranslationFilter" >  
  95.         <property name="authenticationEntryPoint" >  
  96.             <ref local="authenticationProcessingFilterEntryPoint" />  
  97.         </property>  
  98.         <property name="accessDeniedHandler" >  
  99.             <bean class = "org.springframework.security.ui.AccessDeniedHandlerImpl" >  
  100.                 <property name="errorPage"  value= "/web/page/login/login_foward_login.jsp" />  
  101.             </bean>  
  102.         </property>  
  103.     </bean>  
  104.       
  105.     <bean id="authenticationProcessingFilterEntryPoint"   class = "org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint" >  
  106.         <property name="loginFormUrl"  value= "/web/page/login/login_err.jsp" />  
  107.     </bean>  
  108.       
  109.     <!-- 設置cookie 屬性-->  
  110.     <bean id="rememberMeServices"   class = "org.springframework.security.ui.rememberme.TokenBasedRememberMeServices" >  
  111.         <property name="tokenValiditySeconds"  value= "5" />  
  112.         <property name="key"  value= "hereonline" />  
  113.         <property name="userDetailsService"  ref= "hoUserDAO" />  
  114.     </bean>     
  115.       
  116.     <!-- cookie 自動登錄 -->  
  117.     <bean id="rememberMeProcessingFilter"   class = "org.springframework.security.ui.rememberme.RememberMeProcessingFilter" >  
  118.         <property name="rememberMeServices"  ref= "rememberMeServices" />  
  119.         <property name="authenticationManager"  ref= "authenticationManager" />  
  120.     </bean>  
  121.       
  122.     <!-- 阻止用戶在成功登錄之後再進行一次成功登錄  -->  
  123.     <bean id="concurrentSessionController"   class = "org.springframework.security.concurrent.ConcurrentSessionControllerImpl" >  
  124.         <property name="maximumSessions"  value= "1" />  
  125.         <property name="exceptionIfMaximumExceeded"  value= "true" />  
  126.         <property name="sessionRegistry"  ref= "sessionRegistry" />  
  127.     </bean>  
  128.     <!-- 通過監聽HttpSessionEventPublisher 發的不的時間記錄用戶Session 併發數 -->  
  129.     <bean id="sessionRegistry"   class = "org.springframework.security.concurrent.SessionRegistryImpl" />  
  130.       
  131.     <bean id="concurrentSessionFilter"   class = "org.springframework.security.concurrent.ConcurrentSessionFilter" >  
  132.         <property name="sessionRegistry"  ref= "sessionRegistry" />  
  133.         <property name="expiredUrl"  value= "/web/page/login/session_err.jsp" />  
  134.     </bean>  
  135.            
  136.           
  137.     <!-- 匿名用戶處理過濾器 -->  
  138.     <bean id="anonymousProcessingFilter"   class = "org.springframework.security.providers.anonymous.AnonymousProcessingFilter" >  
  139.         <property name="key"  value= "hereonline" />  
  140.         <property name="userAttribute"  value= "ANONYMOUSUSER,PRI_ANONYMOUSUSER" />  
  141.     </bean>  
  142.     <!-- 匿名用戶認證提供 -->  
  143.     <bean id="anonymousAuthenticationProvider"   class = "org.springframework.security.providers.anonymous.AnonymousAuthenticationProvider" >  
  144.         <property name="key"  value= "hereonline" />  
  145.     </bean>  
  146.       
  147.     <!-- acegi的通道過濾器 -->  
  148.     <bean id="channelProcessingFilter"   class = "org.springframework.security.securechannel.ChannelProcessingFilter" >  
  149.         <property name="channelDecisionManager"  ref= "channelDecisionManager" />  
  150.         <property name="filterInvocationDefinitionSource" >  
  151.             <value>  
  152.                 CONVERT_URL_TO_UPPERCASE_BEFORE_COMPARISON  
  153.                 /A/web/page/login/login_name.jsp/Z=REQUIRES_SECURE_CHANNEL  
  154.                 /A/j_acegi_security_check.*/Z=REQUIRES_SECURE_CHANNEL  
  155.                 /A.*/Z=REQUIRES_INSECURE_CHANNEL  
  156.             </value>  
  157.         </property>  
  158.     </bean>  
  159.       
  160.     <bean id="channelDecisionManager"   class = "org.springframework.security.securechannel.ChannelDecisionManagerImpl" >  
  161.         <property name="channelProcessors" >  
  162.             <list>  
  163.                 <ref local="secureChannelProcessor" />  
  164.                 <bean class = "org.springframework.security.securechannel.InsecureChannelProcessor" />  
  165.             </list>  
  166.         </property>  
  167.     </bean>  
  168.       
  169.     <bean id="secureChannelProcessor"   class = "org.springframework.security.securechannel.SecureChannelProcessor" >  
  170.         <property name="entryPoint"  ref= "retryWithHttpsEntryPoint" />  
  171.     </bean>  
  172.       
  173.     <bean id="retryWithHttpsEntryPoint"   class = "org.springframework.security.securechannel.RetryWithHttpsEntryPoint" >  
  174.         <property name="portMapper"  ref= "portMapper" />  
  175.     </bean>  
  176.       
  177.     <bean id="portMapper"   class = "org.springframework.security.util.PortMapperImpl" >  
  178.         <property name="portMappings" >  
  179.             <map>  
  180.                 <entry key="8888"  value= "8443" ></entry>  
  181.             </map>  
  182.         </property>  
  183.     </bean>  
  184.       
  185.       
  186.       
  187.     <bean id="loggerListener"   class = "org.springframework.security.event.authentication.LoggerListener" />  
  188.   
  189.     <bean class = "cn.com.hereonline.sso.listener.LoginSuccessListener" />  
  190.       
  191. </beans> 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章