Announcement Announcement Module
Collapse
No announcement yet.
using my own FORM_LOGIN_FILTER Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • using my own FORM_LOGIN_FILTER

    The following MyAuthenticationFilter class is my own Filter:

    Code:
    public class MyAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
    ...
    }
    In my application context file, I try to use my own filter to replace the default one:
    Code:
    <http auto-config="false">
    		
        <custom-filter position="FORM_LOGIN_FILTER" ref="myAuthenticationFilter" />
    
        <form-login login-page="/login.spring" authentication-failure-url="/login.spring?login_error=1"/>
    
    </http>
    
    <beans:bean id="myAuthenticationFilter" class="MyAuthenticationFilter"/>
    
    <authentication-manager>
        <authentication-provider user-service-ref='userDetailsService'/>
    </authentication-manager>
    When I restart tomcat, I got the following error message:
    Code:
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Filter beans '<myAuthenticationFilter>' and 'Root bean: class [org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null' have the same 'order' value. When using custom filters, please make sure the positions do not conflict with default filters. Alternatively you can disable the default filters by removing the corresponding child elements from <http> and avoiding the use of <http auto-config='true'>.
    Offending resource: ServletContext resource [/WEB-INF/applicationContext-security.xml]
    Can you help me?
    Thanks a lot.

  • #2
    Finally, the following code works fine.

    Code:
    <http auto-config="false" entry-point-ref="loginUrlAuthenticationEntryPoint">
    		<custom-filter position="FORM_LOGIN_FILTER" ref="myAuthenticationFilter" />
    
    </http>
    
    	<beans:bean id="myAuthenticationFilter" class="MyAuthenticationFilter">
    		<beans:property name="authenticationManager" ref="authenticationManager"/>
    		<beans:property name="authenticationFailureHandler" ref="failureHandler"/>
     		<beans:property name="authenticationSuccessHandler" ref="successHandler"/>
    	</beans:bean>
    
    	<beans:bean id="successHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
     		<beans:property name="defaultTargetUrl" value="/login.spring"/>
    	</beans:bean>
    
    	<beans:bean id="failureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
     		<beans:property name="defaultFailureUrl" value="/login.spring?login_error=1"/>
    	</beans:bean>
    
    	<beans:bean id="loginUrlAuthenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
     		<beans:property name="loginFormUrl" value="/login.spring"/>
    	</beans:bean>

    Comment


    • #3
      Good!
      What's your filter implementation?

      Comment

      Working...
      X