0

I want to add spring social facebook (spring social 1.1.4 and spring social facebook 1.1.1) with spring security 4.0.3 using XML configuration,

I'm unable to add SocialAuthenticationFilter :

    <b:bean id="socialAuthenticationFilter"  class="org.springframework.social.security.SocialAuthenticationFilter">
    <b:constructor-arg index="0" ref="authenticationManager" />
    <b:constructor-arg index="1" ref="userIdSource" />
    <b:constructor-arg index="2" ref="usersConnectionRepository" />
    <b:constructor-arg index="3" ref="socialAuthenticationServiceLocator" />
</b:bean>

the execution fails due to this error message :

GRAVE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#1' while setting bean property 'sourceList' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#1': Cannot resolve reference to bean 'socialAuthenticationFilter' while setting constructor argument with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'socialAuthenticationFilter' defined in ServletContext resource [/WEB-INF/spring/security-context.xml]: Cannot resolve reference to bean 'socialAuthenticationServiceLocator' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'socialAuthenticationServiceLocator' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:382)
Khalil_B
  • 59
  • 7

1 Answers1

0

You need a proper socialAuthenticationServiceLocator defined in your context.

<bean id="socialAuthenticationServiceLocator" class="org.springframework.social.security.SocialAuthenticationServiceRegistry">
    <property name="authenticationServices">
        <list>
            <bean class="org.springframework.social.twitter.security.TwitterAuthenticationService">
                <constructor-arg value="${twitter.apiKey}" />
                <constructor-arg value="${twitter.appSecret}" />            
            </bean>
        </list>
    </property>
</bean>
isah
  • 5,221
  • 3
  • 26
  • 36