I want to integrate Spring Social facebook into my application with Spring Security (I use xml configurations). All I need is just connect facebook account with my app's account. In simple example I found this:
<bean id="connectionRepository" factory-method="createConnectionRepository"
factory-bean="usersConnectionRepository" scope="request">
<constructor-arg value="#{request.userPrincipal.name}" />
<aop:scoped-proxy proxy-target-class="false" />
</bean>
So, as I understood, this method comes into play:
public ConnectionRepository createConnectionRepository(String userId) {
if (userId == null) {
throw new IllegalArgumentException("userId cannot be null");
}
return new JdbcConnectionRepository(userId, jdbcTemplate, connectionFactoryLocator, textEncryptor, tablePrefix);
}
It resives "userId
" from #{request.userPrincipal.name}
. So, my question: How can I pass "userId
"
to this method if I want to obtain this "userId
" using SecurityContextHolder.getContext().getAuthentication().getPrincipal()
.
The only way I see is to create my implementation of JdbcUsersConnectionRepository
and redefine createConnectionRepository(String userId)
method. But maybe there is more elegant solution.