I want to integrate Spring social facebook into my application using Spring Security (I use xml configurations). All I need to do is just connect my facebook account with my application account. In a 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 understand it, 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 returns " userId " from #{request.userPrincipal.name} . So my question is: how can I pass " userId " to this method if I want to get this " userId " using SecurityContextHolder.getContext().getAuthentication().getPrincipal() .
The only way I can see is to create my implementation of the JdbcUsersConnectionRepository method and override createConnectionRepository(String userId) . But perhaps there is a more elegant solution.
source share