Guest User

Untitled

a guest
Sep 6th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. Spring security using JPA. How to configure applicationContext-security.XML file?(using DaoAuthenticationProvider)
  2. <authentication-provider>
  3. <jdbc-user-service id="userDetailsService" data-source-ref="dataSource" />
  4. </authentication-provider>
  5.  
  6. <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
  7. <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  8. <property name="url" value="jdbc:mysql://localhost:3306/demodata" />
  9. <property name="username" value="root"/>
  10. <property name="password" value="root"/>
  11. </bean>
  12.  
  13. <beans:bean id="daoAuthenticationProvider" class="org.springframework.security.providers.dao.DaoAuthenticationProvider">
  14. <property name="userDetailsService" ref="userDetailsService"/>
  15. <property name="saltSource" ref bean="saltSource"/>
  16. <property name="passwordEncoder" ref="passwordEncoder"/>
  17. </beans:bean>
  18.  
  19. <authentication-provider user-service-ref="CustomUserDetailsService">
  20. </authentication-provider>
  21. <beans:bean id="CustomUserDetailsService" class="com.service.CustomUserDetailsService" />
  22.  
  23. <beans:bean id="authenticationManager"
  24. class="org.springframework.security.providers.ProviderManager">
  25. <beans:property name="providers"><beans:list>
  26. <beans:ref local="daoAuthenticationProvider" />
  27. </beans:list> </beans:property>
  28. <beans:property name="sessionController"
  29. ref="defaultConcurrentSessionController" />
  30. </beans:bean>
  31.  
  32. <beans:bean id="daoAuthenticationProvider"
  33. class="org.springframework.security.providers.dao.DaoAuthenticationProvider">
  34. <property name="userDetailsService" ref="CustomUserDetailsService"/>
  35. <property name="saltSource" ref bean="saltSource"/>
  36. <property name="passwordEncoder" ref="passwordEncoder"/>
  37. </beans:bean>
  38.  
  39. <authentication-provider user-service-ref="CustomUserDetailsService">
  40. </authentication-provider>
  41. <beans:bean id="CustomUserDetailsService"
  42. class="com.service.CustomUserDetailsService" />
  43.  
  44. <beans:bean id="CustomUserDetailsService" class="com.service.CustomUserDetailsService">
  45. <custom-authentication-provider/>
  46. </beans>
Add Comment
Please, Sign In to add comment