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;
}
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");
}
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));
}
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;
}
}
Aggregations