java - Spring social - Implicit sign up is not working -
i spring social along spring mvc connect twitter
. want achieve implicit sign up, if user new following spring social docs. getting following error, when application deployed
error: org.springframework.web.context.contextloader - context initialization failed org.springframework.beans.factory.beancreationexception: error creating bean name 'springsecurityfilterchain' defined in class org.springframework.security.config.annotation.web.configuration.websecurityconfiguration: instantiation of bean failed; nested exception org.springframework.beans.factory.beandefinitionstoreexception: factory method [public javax.servlet.filter org.springframework.security.config.annotation.web.configuration.websecurityconfiguration.springsecurityfilterchain() throws java.lang.exception] threw exception; nested exception java.lang.illegalstateexception: springsocialconfigurer depends on org.springframework.social.security.socialauthenticationservicelocator. no single bean of type found in application context. @ org.springframework.beans.factory.support.constructorresolver.instantiateusingfactorymethod(constructorresolver.java:597) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.instantiateusingfactorymethod(abstractautowirecapablebeanfactory.java:1094) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbeaninstance(abstractautowirecapablebeanfactory.java:989) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:504) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:475) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:304) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:228) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:300) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:195) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:703) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:760) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:482) @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:403) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4937) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5434) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1559) @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1549) @ java.util.concurrent.futuretask.run(futuretask.java:262) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:744) caused by: org.springframework.beans.factory.beandefinitionstoreexception: factory method [public javax.servlet.filter org.springframework.security.config.annotation.web.configuration.websecurityconfiguration.springsecurityfilterchain() throws java.lang.exception] threw exception; nested exception java.lang.illegalstateexception: springsocialconfigurer depends on org.springframework.social.security.socialauthenticationservicelocator. no single bean of type found in application context. @ org.springframework.beans.factory.support.simpleinstantiationstrategy.instantiate(simpleinstantiationstrategy.java:188) @ org.springframework.beans.factory.support.constructorresolver.instantiateusingfactorymethod(constructorresolver.java:586) ... 23 more
this how socialconfig.java
package org.springframework.social.showcase.config; import javax.inject.inject; import javax.sql.datasource; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration; import org.springframework.context.annotation.scope; import org.springframework.context.annotation.scopedproxymode; import org.springframework.core.env.environment; import org.springframework.security.core.authentication; import org.springframework.security.core.context.securitycontextholder; import org.springframework.security.crypto.encrypt.encryptors; import org.springframework.social.useridsource; import org.springframework.social.config.annotation.connectionfactoryconfigurer; import org.springframework.social.config.annotation.enablesocial; import org.springframework.social.config.annotation.socialconfigureradapter; import org.springframework.social.connect.connection; import org.springframework.social.connect.connectionfactorylocator; import org.springframework.social.connect.connectionrepository; import org.springframework.social.connect.connectionsignup; import org.springframework.social.connect.usersconnectionrepository; import org.springframework.social.connect.jdbc.jdbcusersconnectionrepository; import org.springframework.social.connect.support.connectionfactoryregistry; import org.springframework.social.connect.web.connectcontroller; import org.springframework.social.connect.web.providersignincontroller; import org.springframework.social.connect.web.reconnectfilter; import org.springframework.social.facebook.api.facebook; import org.springframework.social.facebook.connect.facebookconnectionfactory; import org.springframework.social.facebook.web.disconnectcontroller; import org.springframework.social.linkedin.api.linkedin; import org.springframework.social.linkedin.connect.linkedinconnectionfactory; import org.springframework.social.showcase.account.accountconnectionsignup; import org.springframework.social.showcase.account.accountrepository; import org.springframework.social.showcase.facebook.posttowallafterconnectinterceptor; import org.springframework.social.showcase.signin.simplesigninadapter; import org.springframework.social.showcase.twitter.tweetafterconnectinterceptor; import org.springframework.social.twitter.api.twitter; import org.springframework.social.twitter.connect.twitterconnectionfactory; @configuration @enablesocial public class socialconfig extends socialconfigureradapter { @inject private datasource datasource; @inject private environment environment; @override public void addconnectionfactories(connectionfactoryconfigurer cfconfig, environment env) { cfconfig.addconnectionfactory(new twitterconnectionfactory(env.getproperty("twitter.appkey"), env.getproperty("twitter.appsecret"))); cfconfig.addconnectionfactory(new facebookconnectionfactory(env.getproperty("facebook.appkey"), env.getproperty("facebook.appsecret"))); cfconfig.addconnectionfactory(new linkedinconnectionfactory(env.getproperty("linkedin.appkey"), env.getproperty("linkedin.appsecret"))); } @override public useridsource getuseridsource() { return new useridsource() { @override public string getuserid() { authentication authentication = securitycontextholder.getcontext().getauthentication(); if (authentication == null) { throw new illegalstateexception("unable connectionrepository: no user signed in"); } return authentication.getname(); } }; } @override public usersconnectionrepository getusersconnectionrepository(connectionfactorylocator connectionfactorylocator) { return new jdbcusersconnectionrepository(datasource, connectionfactorylocator, encryptors.nooptext()); } @bean public connectcontroller connectcontroller(connectionfactorylocator connectionfactorylocator, connectionrepository connectionrepository) { connectcontroller connectcontroller = new connectcontroller(connectionfactorylocator, connectionrepository); connectcontroller.addinterceptor(new posttowallafterconnectinterceptor()); connectcontroller.addinterceptor(new tweetafterconnectinterceptor()); return connectcontroller; } @bean public disconnectcontroller disconnectcontroller(usersconnectionrepository usersconnectionrepository, environment environment) { return new disconnectcontroller(usersconnectionrepository, environment.getproperty("facebook.appsecret")); } @bean public reconnectfilter apiexceptionhandler(usersconnectionrepository usersconnectionrepository, useridsource useridsource) { return new reconnectfilter(usersconnectionrepository, useridsource); } @bean @scope(value="request", proxymode=scopedproxymode.interfaces) public facebook facebook(connectionrepository repository) { connection<facebook> connection = repository.findprimaryconnection(facebook.class); return connection != null ? connection.getapi() : null; } @bean @scope(value="request", proxymode=scopedproxymode.interfaces) public twitter twitter(connectionrepository repository) { connection<twitter> connection = repository.findprimaryconnection(twitter.class); return connection != null ? connection.getapi() : null; } @bean @scope(value="request", proxymode=scopedproxymode.interfaces) public linkedin linkedin(connectionrepository repository) { connection<linkedin> connection = repository.findprimaryconnection(linkedin.class); return connection != null ? connection.getapi() : null; } // @bean // public providersignincontroller providersignincontroller() { // return new providersignincontroller(connectionfactorylocator(), // usersconnectionrepository(accountrepository), new simplesigninadapter()); // } // @bean // @scope(value="singleton", proxymode=scopedproxymode.interfaces) // public connectionfactorylocator connectionfactorylocator() { // connectionfactoryregistry registry = new connectionfactoryregistry(); // // // // registry.addconnectionfactory(new twitterconnectionfactory( // environment.getproperty("twitter.consumerkey"), // environment.getproperty("twitter.consumersecret"))); // // return registry; // } @bean @scope(value="singleton", proxymode=scopedproxymode.interfaces) public connectionfactorylocator connectionfactorylocator() { connectionfactoryregistry registry = new connectionfactoryregistry(); registry.addconnectionfactory(new facebookconnectionfactory( environment.getproperty("facebook.clientid"), environment.getproperty("facebook.clientsecret"))); registry.addconnectionfactory(new twitterconnectionfactory( environment.getproperty("twitter.consumerkey"), environment.getproperty("twitter.consumersecret"))); return registry; } @bean @scope(value="singleton", proxymode=scopedproxymode.interfaces) public usersconnectionrepository usersconnectionrepository(accountrepository accountrepository) { jdbcusersconnectionrepository repository = new jdbcusersconnectionrepository( datasource, connectionfactorylocator(), encryptors.nooptext()); repository.setconnectionsignup((connectionsignup) new accountconnectionsignup(accountrepository)); return repository; } }
Comments
Post a Comment