Custom AuthenticationProvider in Spring Security

In your application context you need

<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-2.0.xsd
                                   http://www.springframework.org/schema/security
                                   http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> 
   <http>
      [...]
   </http>
   <beans:bean id="myAuthenticationProvider"
                       class="com.example.security.MyAuthenticationProvider">
      <custom-authentication-provider/>
   </beans:bean>

If you are using username and password authentication, your bean can then extend the abstract base class that comes with Spring:

org.springframework.security.providers.dao.AbstractUserDetailsAuthenticationProvider

Leave a Reply

Your email address will not be published. Required fields are marked *