Failed properties: Property 'authenticationServices' threw exception; nested exception is java.lang.IllegalArgumentException: A ConnectionFactory for provider 'twitter' has already been registered
Not sure why i am getting this. Twitter and Facebook are configured via annotations. This whole configuration is loaded via the ContextLoaderListener, just like the samples project.
But for some reason it looks like the App context loaded by the DispatcherServlet might be trying to make them too.
Here is my Java Config class
Here is what I have in the applicationContext.xmlCode:@Configuration @EnableJdbcConnectionRepository @EnableTwitter(appId="${twitter.consumerKey}", appSecret = "${twitter.consumerSecret}") @EnableFacebook(appId = "${facebook.clientId}", appSecret = "${facebook.clientSecret}") public class SocialWebConfig { @Autowired ConnectionFactoryLocator connectionFactoryLocator; @Autowired ConnectionRepository connectionRepository; @Autowired UsersConnectionRepository usersConnectionRepository; @Autowired private UserIdSource userIdSource; @Bean public ConnectController connectController() { ConnectController connectController = new ConnectController(connectionFactoryLocator, connectionRepository); return connectController; } @Bean public ProviderSignInController providerSignInController(RequestCache requestCache) { ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SpringSecuritySignInAdapter(requestCache)); controller.setSignUpUrl("/account/signup"); return controller; } @Bean public SocialAuthenticationFilter socialAuthenticationFilter(AuthenticationManager authenticationManager, RememberMeServices rememberMeServices, SocialAuthenticationServiceLocator authenticationServiceLocator) { SocialAuthenticationFilter socialAuthenticationFilter = new SocialAuthenticationFilter(authenticationManager, userIdSource, usersConnectionRepository, authenticationServiceLocator); socialAuthenticationFilter.setFilterProcessesUrl("/auth"); socialAuthenticationFilter.setSignupUrl("/account/signup"); // TODO: Fix filter to handle in-app paths socialAuthenticationFilter.setRememberMeServices(rememberMeServices); return socialAuthenticationFilter; } @Bean public AuthenticationProvider socialAuthenticationProvider(UserDetailsService userDetailsService, UsersConnectionRepository usersConnectionRepository) { return new SocialAuthenticationProvider(usersConnectionRepository, socialUsersDetailsService(userDetailsService)); } @Bean public SocialUserDetailsService socialUsersDetailsService(UserDetailsService userDetailsService) { return new SimpleSocialUserDetailsService(userDetailsService); } @Bean public PasswordEncoder passwordEncoder() { return NoOpPasswordEncoder.getInstance(); } @Bean public TextEncryptor textEncryptor() { return Encryptors.noOpText(); } @Bean public UserIdSource userIdSource() { return new AuthenticationNameUserIdSource(); } }
Here is my spring-security xml file configCode:<context:property-placeholder location="classpath:META-INF/spring/social.properties"/> <context:component-scan base-package="com.hdpoker.social.config"/> <import resource="classpath*:META-INF/spring/applicationContext*.xml"/> <import resource="applicationContext-security-account.xml"/>
Any ideas what I am doing wrong.Code:<security:global-method-security secured-annotations="enabled"/> <!-- HTTP security configurations --> <security:http auto-config="true" use-expressions="true"> <security:form-login login-page="/" authentication-failure-url="/?login_error=1" default-target-url="/index"/> <security:intercept-url pattern="/index/**" access="hasRole('Player')"/> <security:intercept-url pattern="/account/**" method="POST" access="permitAll"/> <!-- Configure these elements to secure URIs in your application --> <security:intercept-url pattern="/resources/**" access="permitAll"/> <security:intercept-url pattern="/auth/**" access="permitAll" /> <security:intercept-url pattern="/signin/**" access="permitAll" /> <security:intercept-url pattern="/signup/**" access="permitAll" /> <security:intercept-url pattern="/" access="permitAll" /> <!-- Spring Social Security authentication filter --> <security:custom-filter ref="socialAuthenticationFilter" before="PRE_AUTH_FILTER" /> </security:http> <!--Make sure somewhere there is a component-scan to bring in the accountUserDetailsService--> <security:authentication-manager alias="authenticationManager"> <security:authentication-provider user-service-ref="accountUserDetailsService"> <!--security:password-encoder hash="md5"> <security:salt-source system-wide="wysiwyg"/> </security:password-encoder--> </security:authentication-provider> <security:authentication-provider ref="socialAuthenticationProvider"/> </security:authentication-manager>
Thanks
Mark


Reply With Quote
