0

我想使用 XML 配置在 spring security 4.0.3 中添加 spring social facebook(spring social 1.1.4 和 spring social facebook 1.1.1),

我无法添加 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>

由于此错误消息,执行失败:

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)
4

1 回答 1

0

您需要socialAuthenticationServiceLocator在您的上下文中正确定义。

<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>
于 2016-03-17T12:00:00.550 回答