2016-03-07 38 views
0

我想用XML配置與春季安全4.0.3添加彈簧社會的Facebook(社交春天1.1.4春Facebook的社會1.1.1)創建SocialAuthenticationFilter,春天社會:無法使用XML配置

我米無法添加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) 

回答

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>