Search in sources :

Example 1 with ConnectionFactoryRegistry

use of org.springframework.social.connect.support.ConnectionFactoryRegistry in project ORCID-Source by ORCID.

the class SocialConfig method connectionFactoryLocator.

@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
    logger.info("getting connectionFactoryLocator");
    ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
    registry.addConnectionFactory(new FacebookConnectionFactory(fb_key, fb_secret));
    registry.addConnectionFactory(new GoogleConnectionFactory(gg_key, gg_secret));
    return registry;
}
Also used : GoogleConnectionFactory(org.springframework.social.google.connect.GoogleConnectionFactory) FacebookConnectionFactory(org.springframework.social.facebook.connect.FacebookConnectionFactory) ConnectionFactoryRegistry(org.springframework.social.connect.support.ConnectionFactoryRegistry) InitializingBean(org.springframework.beans.factory.InitializingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with ConnectionFactoryRegistry

use of org.springframework.social.connect.support.ConnectionFactoryRegistry in project FuryViewer by TheDoctor-95.

the class CustomSocialUsersConnectionRepositoryIntTest method setUp.

@Before
public void setUp() {
    socialUserConnectionRepository.deleteAll();
    connectionFactoryRegistry = new ConnectionFactoryRegistry();
    connectionFactory = new TestFacebookConnectionFactory();
    connectionFactoryRegistry.addConnectionFactory(connectionFactory);
    usersConnectionRepository = new CustomSocialUsersConnectionRepository(socialUserConnectionRepository, connectionFactoryRegistry);
    connectionRepository = usersConnectionRepository.createConnectionRepository("1");
}
Also used : ConnectionFactoryRegistry(org.springframework.social.connect.support.ConnectionFactoryRegistry) Before(org.junit.Before)

Example 3 with ConnectionFactoryRegistry

use of org.springframework.social.connect.support.ConnectionFactoryRegistry in project engine by craftercms.

the class ConfigAwareConnectionFactoryLocatorTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    CacheTemplateMockUtils.setUpWithNoCaching(cacheTemplate);
    ConfigurationParser<?> configParserStub = new FacebookConnectionFactoryConfigParser() {

        @Override
        protected ConnectionFactory<Facebook> createFacebookConnectionFactory(String appId, String appSecret) {
            return new FacebookConnectionFactoryStub(appId, appSecret);
        }
    };
    locator = new ConfigAwareConnectionFactoryLocator();
    locator.setCacheTemplate(cacheTemplate);
    locator.setDefaultLocator(new ConnectionFactoryRegistry());
    locator.setConfigParsers(Arrays.<ConfigurationParser<?>>asList(configParserStub));
}
Also used : ConfigAwareConnectionFactoryLocator(org.craftercms.engine.util.spring.social.ConfigAwareConnectionFactoryLocator) FacebookConnectionFactoryConfigParser(org.craftercms.engine.util.config.impl.FacebookConnectionFactoryConfigParser) Facebook(org.springframework.social.facebook.api.Facebook) ConnectionFactoryRegistry(org.springframework.social.connect.support.ConnectionFactoryRegistry) Before(org.junit.Before)

Example 4 with ConnectionFactoryRegistry

use of org.springframework.social.connect.support.ConnectionFactoryRegistry in project engine by craftercms.

the class ConfigAwareConnectionFactoryLocator method getCurrentConnectionFactoryLocator.

protected ConnectionFactoryLocator getCurrentConnectionFactoryLocator() {
    Callback<ConnectionFactoryLocator> callback = new Callback<ConnectionFactoryLocator>() {

        @Override
        public ConnectionFactoryLocator execute() {
            HierarchicalConfiguration config = ConfigUtils.getCurrentConfig();
            ConnectionFactoryRegistry registry = null;
            if (config != null) {
                try {
                    HierarchicalConfiguration socialConnectionsConfig = config.configurationAt(SOCIAL_CONNECTIONS_KEY);
                    for (ConfigurationParser<?> parser : configParsers) {
                        ConnectionFactory<?> factory = (ConnectionFactory<?>) parser.parse(socialConnectionsConfig);
                        if (factory != null) {
                            if (registry == null) {
                                registry = new ConnectionFactoryRegistry();
                            }
                            registry.addConnectionFactory(factory);
                        }
                    }
                } catch (IllegalArgumentException e) {
                // Ignore if != 1
                }
            }
            if (registry != null) {
                return registry;
            } else {
                return defaultLocator;
            }
        }
    };
    SiteContext siteContext = SiteContext.getCurrent();
    if (siteContext != null) {
        return cacheTemplate.getObject(siteContext.getContext(), callback, CONNECTION_FACTORY_LOCATOR_CACHE_KEY);
    } else {
        return defaultLocator;
    }
}
Also used : ConnectionFactory(org.springframework.social.connect.ConnectionFactory) Callback(org.craftercms.commons.lang.Callback) SiteContext(org.craftercms.engine.service.context.SiteContext) ConnectionFactoryLocator(org.springframework.social.connect.ConnectionFactoryLocator) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration) ConnectionFactoryRegistry(org.springframework.social.connect.support.ConnectionFactoryRegistry)

Aggregations

ConnectionFactoryRegistry (org.springframework.social.connect.support.ConnectionFactoryRegistry)4 Before (org.junit.Before)2 HierarchicalConfiguration (org.apache.commons.configuration2.HierarchicalConfiguration)1 Callback (org.craftercms.commons.lang.Callback)1 SiteContext (org.craftercms.engine.service.context.SiteContext)1 FacebookConnectionFactoryConfigParser (org.craftercms.engine.util.config.impl.FacebookConnectionFactoryConfigParser)1 ConfigAwareConnectionFactoryLocator (org.craftercms.engine.util.spring.social.ConfigAwareConnectionFactoryLocator)1 InitializingBean (org.springframework.beans.factory.InitializingBean)1 Bean (org.springframework.context.annotation.Bean)1 ConnectionFactory (org.springframework.social.connect.ConnectionFactory)1 ConnectionFactoryLocator (org.springframework.social.connect.ConnectionFactoryLocator)1 Facebook (org.springframework.social.facebook.api.Facebook)1 FacebookConnectionFactory (org.springframework.social.facebook.connect.FacebookConnectionFactory)1 GoogleConnectionFactory (org.springframework.social.google.connect.GoogleConnectionFactory)1