secruity

security3.x

xml version="1.0" encoding="UTF-8"?>  
<beans:beans xmlns="http://www.springframework.org/schema/security"  
    xmlns:beans="http://www.springframework.org/schema/beans"   
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xsi:schemaLocation="http://www.springframework.org/schema/beans   
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd    
http://www.springframework.org/schema/security   
http://www.springframework.org/schema/security/spring-security-3.1.xsd">  
    <global-method-security pre-post-annotations="enabled">  
    global-method-security>  
      
    <http pattern="/include/js/**" security="none" />  
    <http pattern="/include/css/**" security="none" />  
    <http pattern="/include/scripts/**" security="none" />  
    <http pattern="/include/jsp/**" security="none" />  
    <http pattern="/images/**" security="none" />  
    <http pattern="/login.jsp" security="none" />  
      
      
          
      
      
      
    <http use-expressions="true" auto-config="true"  
        access-denied-page="/include/jsp/timeout.jsp">  
  
  
          
          
  
          
<form-login login-page="/login.jsp" default-target-url='/system/default.jsp'  
        always-use-default-target="true" authentication-failure-url="/login.jsp?login_error=1" />  
  
          
          
        <logout invalidate-session="true" logout-success-url="/login.jsp"  
            logout-url="/j_spring_security_logout" />  
          
        <remember-me />  
  
          
  
   
  
  
        <session-management invalid-session-url="/login.jsp"  
            session-fixation-protection="none">  
            <concurrency-control max-sessions="1"  
                error-if-maximum-exceeded="false" />  
        session-management>  
        <custom-filter ref="myFilter" before="FILTER_SECURITY_INTERCEPTOR" />  
        <session-management  
            session-authentication-strategy-ref="sas" />  
  
    http>  
<beans:bean id="sas"  
class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">  
        <beans:constructor-arg name="sessionRegistry"  
            ref="sessionRegistry" />  
        <beans:property name="maximumSessions" value="1" />  
          
        <beans:property name="alwaysCreateSession" value="true" />  
        <beans:property name="migrateSessionAttributes" value="false" />  
          
        <beans:property name="exceptionIfMaximumExceeded"  
            value="false" />  
    beans:bean>  
    <beans:bean id="sessionRegistry"  
        class="org.springframework.security.core.session.SessionRegistryImpl" />  
      
      
    <beans:bean  
        class="org.springframework.security.authentication.event.LoggerListener" />  
      
    <beans:bean id="messageSource"  
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">  
        <beans:property name="basenames" value="classpath:message_zh_CN">  
beans:property>  
    beans:bean>  
      
    <beans:bean id="myFilter"  
        class="com.taskmanager.web.security.MySecurityFilter">  
      
    <beans:property name="authenticationManager" ref="myAuthenticationManager" />  
      
    <beans:property name="accessDecisionManager" ref="myAccessDecisionManager" />  
      
    <beans:property name="securityMetadataSource" ref="mySecurityMetadataSource" />  
    beans:bean>  
      
    <authentication-manager alias="myAuthenticationManager">  
        <authentication-provider user-service-ref="myUserDetailServiceImpl">  
              
            <password-encoder hash="md5" ref="passwordEncoder">  
            password-encoder>  
        authentication-provider>  
    authentication-manager>  
      
    <beans:bean id="myAccessDecisionManager"  
        class="com.taskmanager.web.security.MyAccessDecisionManager">  
    beans:bean>  
      
    <beans:bean id="mySecurityMetadataSource"  
        class="com.taskmanager.web.security.MySecurityMetadataSource">  
        <beans:constructor-arg name="powerService" ref="powerService">  
beans:constructor-arg>  
    beans:bean>  
      
    <beans:bean id="myUserDetailServiceImpl"  
        class="com.taskmanager.web.security.MyUserDetailServiceImpl">  
        <beans:property name="userService" ref="userService">beans:property>  
    beans:bean>  
  
      
    <beans:bean id="passwordEncoder"  
class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" />  
beans:beans>

 

security4.x

<beans:beans  
        xmlns="http://www.springframework.org/schema/security"  
        xmlns:beans="http://www.springframework.org/schema/beans"  
        xmlns:p="http://www.springframework.org/schema/p"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xmlns:context="http://www.springframework.org/schema/context"  
        xsi:schemaLocation="http://www.springframework.org/schema/beans  
          http://www.springframework.org/schema/beans/spring-beans.xsd  
          http://www.springframework.org/schema/context  
          http://www.springframework.org/schema/context/spring-context.xsd  
          http://www.springframework.org/schema/security  
              http://www.springframework.org/schema/security/spring-security.xsd">  
  
  
    <context:component-scan base-package="com.framework.security"/>  
  
  
      
    <http pattern="/login.jsp" security="none" />  
    <http pattern="/common/**" security="none" />  
    <http pattern="/*.ico" security="none" />  
  
  
    <http  use-expressions="false" >  
          
        <intercept-url pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" />  
        <intercept-url pattern="/pm/**/*.jsp" access="ROLE_STATIC" />  
        <form-login login-page="/login"    authentication-failure-url="/login?error=1" authentication-success-forward-url="/main.to" />  
        <logout invalidate-session="true" logout-url="/logout"  logout-success-url="/"  />  
        <http-basic/>  
        <headers >  
            <frame-options disabled="true">frame-options>  
        headers>  
  
  
        <csrf token-repository-ref="csrfTokenRepository" />  
  
  
        <session-management session-authentication-error-url="/frame.expired" >  
              
            <concurrency-control max-sessions="1" error-if-maximum-exceeded="false" expired-url="/frame.expired" session-registry-ref="sessionRegistry" />  
        session-management>  
  
  
        <expression-handler ref="webexpressionHandler" >expression-handler>  
    http>  
  
  
    <beans:bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" />  
  
  
    <beans:bean id="userDetailsService" class="com.framework.security.UserDetailsServiceImpl" />  
  
  
      
    <beans:bean id="webexpressionHandler" class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler" />  
  
  
    <authentication-manager >  
        <authentication-provider ref="authenticationProvider" />  
    authentication-manager>  
  
  
      
    <beans:bean id="authenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">  
        <beans:property name="hideUserNotFoundExceptions" value="true" />  
        <beans:property name="userDetailsService" ref="userDetailsService" />  
        <beans:property name="passwordEncoder" ref="passwordEncoder" />  
        <beans:property name="saltSource" ref="saltSource" />  
    beans:bean>  
  
  
      
    <beans:bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" />  
  
  
      
    <beans:bean id="saltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource">  
        <beans:property name="userPropertyToUse" value="salt"/>  
    beans:bean>  
  
  
    <beans:bean id="csrfTokenRepository" class="org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository" />  
beans:beans>

 

 
    xmlns:beans="http://www.springframework.org/schema/beans"   
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xsi:schemaLocation="http://www.springframework.org/schema/beans   
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd    
http://www.springframework.org/schema/security   
http://www.springframework.org/schema/security/spring-security-3.1.xsd">  
     
   
 
     
     
     
     
     
     
     
     
     
         
     
     
      
            access-denied-page="/include/jsp/timeout.jsp">  
 
 
         
         
 
          
        always-use-default-target="true" authentication-failure-url="/login.jsp?login_error=1" />  
 
         
         
                    logout-url="/j_spring_security_logout" />  
         
         
 
         
 
   
 
 
                    session-fixation-protection="none">  
                            error-if-maximum-exceeded="false" />  
       
 
         
                    session-authentication-strategy-ref="sas" />  
 
   
 
class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">  
                    ref="sessionRegistry" />  
         
         
         
         
         
                    value="false" />  
   
 
            class="org.springframework.security.core.session.SessionRegistryImpl" />  
     
     
            class="org.springframework.security.authentication.event.LoggerListener" />  
     
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">  
         
 
   
 
     
            class="com.taskmanager.web.security.MySecurityFilter">  
     
     
     
     
     
     
   
 
     
     
         
             
             
           
 
       
 
   
 
     
            class="com.taskmanager.web.security.MyAccessDecisionManager">  
   
 
     
            class="com.taskmanager.web.security.MySecurityMetadataSource">  
         
 
   
 
     
            class="com.taskmanager.web.security.MyUserDetailServiceImpl">  
         
   
 
 
     
    class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" />  

你可能感兴趣的:(secruity)