我使用spring社交项目开发了带有oauth身份验证的spring应用程序。我目前能够使用facebook,twitter和linkedin进行身份验证。我还想使用spring-social-google添加google身份验证。我真的很困惑,在现有的春季社交配置中添加谷歌的连接工厂。
我目前的春季社交应用背景是
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:facebook="http://www.springframework.org/schema/social/facebook"
xmlns:twitter="http://www.springframework.org/schema/social/twitter"
xmlns:social="http://www.springframework.org/schema/social"
xmlns:linkedin="http://www.springframework.org/schema/social/linkedin"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/social/facebook http://www.springframework.org/schema/social/spring-social-facebook.xsd
http://www.springframework.org/schema/social/linkedin http://www.springframework.org/schema/social/spring-social-linkedin.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/social/twitter http://www.springframework.org/schema/social/spring-social-twitter.xsd
http://www.springframework.org/schema/social http://www.springframework.org/schema/social/spring-social.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder location="/WEB-INF/properties/application.properties" />
<facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}" app-namespace="my-app" />
<twitter:config app-id="${twitter.consumerKey}" app-secret="${twitter.consumerSecret}"/>
<linkedin:config app-id="${linkedin.consumerKey}" app-secret="${linkedin.consumerSecret}"/>
<social:jdbc-connection-repository/>
<bean id="userIdSource" class="org.springframework.social.security.AuthenticationNameUserIdSource" />
<bean id="connectController" class="org.springframework.social.connect.web.ConnectController" autowire="constructor">
<property name="connectInterceptors">
<list>
<bean class="com.prs.ony.controller.facebook.PostToWallAfterConnectInterceptor" />
<bean class="com.prs.ony.controller.twitter.TweetAfterConnectInterceptor" />
</list>
</property>
</bean>
<bean id="psc" class="org.springframework.social.connect.web.ProviderSignInController" autowire="constructor" />
<bean id="signInAdapter" class="com.prs.ony.controller.signin.SimpleSignInAdapter" autowire="constructor" />
<!-- <bean id="disconnectController" class="org.springframework.social.facebook.web.DisconnectController"
c:_0-ref="usersConnectionRepository" c:_1="${facebook.clientSecret}" /> -->
</beans>
现在我很困惑在哪里添加googles连接工厂。它必须与现有的oauth提供商一起工作。
<bean id="connectionFactoryLocator" class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
<property name="connectionFactories">
<list>
<bean class="org.springframework.social.google.connect.GoogleConnectionFactory">
<constructor-arg value="${google.consumerKey}" />
<constructor-arg value="${google.consumerSecret}" />
</bean>
</list>
</property>
</bean>
任何帮助都将受到高度赞赏。
答案 0 :(得分:0)
可以省略具体社交配置命名空间的使用并一起注册连接工厂:
<bean id="connectionFactoryLocator" class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
<property name="connectionFactories">
<list>
<bean class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
<constructor-arg name="appId" value="${facebook.clientId}" />
<constructor-arg name="appSecret" value="${facebook.clientSecret}" />
</bean>
<bean class="org.springframework.social.twitter.connect.TwitterConnectionFactory">
<constructor-arg name="consumerKey" value="${twitter.consumerKey}" />
<constructor-arg name="consumerSecret" value="${twitter.consumerSecret}" />
</bean>
<bean class="org.springframework.social.linkedin.connect.LinkedInConnectionFactory">
<constructor-arg name="consumerKey" value="${linkedin.consumerKey}" />
<constructor-arg name="consumerSecret" value="${linkedin.consumerSecret}" />
</bean>
<bean class="org.springframework.social.google.connect.GoogleConnectionFactory">
<constructor-arg name="clientId" value="${google.consumerKey}" />
<constructor-arg name="clientSecret" value="${google.consumerSecret}" />
</bean>
</list>
</property>
</bean>