Java Code Examples for org.springframework.social.connect.ConnectionFactory

The following examples show how to use org.springframework.social.connect.ConnectionFactory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@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));
}
 
Example 2
Source Project: cola   Source File: WechatMpConnectionConfiguration.java    License: MIT License 5 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	WechatMpConnectionFactory factory = new WechatMpConnectionFactory(wechatMpProperties.getProviderId(), wechatMpProperties.getAppId(),
			wechatMpProperties.getAppSecret());
	factory.setScope(wechatMpProperties.getScope());
	return factory;
}
 
Example 3
Source Project: pre   Source File: QQAutoConfig.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
    QQProperties qqProperties = preSecurityProperties.getSocial().getQq();
    String providerId = qqProperties.getProviderId();
    String appId = qqProperties.getAppId();
    String appSecret = qqProperties.getAppSecret();
    return new QQConnectionFactory(providerId, appId, appSecret);
}
 
Example 4
Source Project: pre   Source File: WeixinAuthConfig.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
    WeiXinProperties weiXin = preSecurityProperties.getSocial().getWeiXin();
    String providerId = weiXin.getProviderId();
    String appId = weiXin.getAppId();
    String appSecret = weiXin.getAppSecret();
    return new WeixinConnectionFactory(providerId, appId, appSecret);
}
 
Example 5
@Override
protected ConnectionFactory<WechatMp> createConnectionFactory() {
	final WechatMpConnectionFactory factory = new WechatMpConnectionFactory(properties.getAppId(),
			properties.getAppSecret());
	factory.setScope(properties.getScope());
	return factory;
}
 
Example 6
@Override
protected ConnectionFactory<Wechat> createConnectionFactory() {
	final WechatConnectionFactory factory = new WechatConnectionFactory(properties.getAppId(),
			properties.getAppSecret());
	factory.setScope(properties.getScope());
	return factory;
}
 
Example 7
Source Project: paascloud-master   Source File: WeixinAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create connection factory connection factory.
 *
 * @return the connection factory
 */
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	WeixinProperties weixinConfig = securityProperties.getSocial().getWeixin();
	return new WeixinConnectionFactory(weixinConfig.getProviderId(), weixinConfig.getAppId(),
			weixinConfig.getAppSecret());
}
 
Example 8
private Connection<?> authToConnection(SocialAuthentication auth) {
    ConnectionFactory<?> connectionFactory = locator.getConnectionFactory(auth.getProviderId());
    ConnectionData data = new ConnectionData(auth.getProviderId(), auth.getProviderUserId(), null, null,
            auth.getImageUrl(), auth.getToken(), auth.getSecret(), auth.getRefreshToken(),
            auth.getExpirationTime());
    return connectionFactory.createConnection(data);
}
 
Example 9
@Override
public ConnectionFactory<Facebook> parse(HierarchicalConfiguration config) throws ConfigurationException {
    String appId = config.getString(FACEBOOK_CONNECTION_FACTORY_APP_ID_KEY);
    String appSecret = config.getString(FACEBOOK_CONNECTION_FACTORY_APP_SECRET_KEY);

    if (StringUtils.isNotEmpty(appId) && StringUtils.isNotEmpty(appSecret)) {
        return createFacebookConnectionFactory(appId, appSecret);
    } else {
        return null;
    }
}
 
Example 10
private Connection<?> buildConnection(UserSocialConnection userSocialConnection) {
    ConnectionData connectionData = new ConnectionData(userSocialConnection.getProviderId(),
            userSocialConnection.getProviderUserId(), userSocialConnection.getDisplayName(),
            userSocialConnection.getProfileUrl(), userSocialConnection.getImageUrl(),
            decrypt(userSocialConnection.getAccessToken()), decrypt(userSocialConnection.getSecret()),
            decrypt(userSocialConnection.getRefreshToken()), userSocialConnection.getExpireTime());
    ConnectionFactory<?> connectionFactory = this.socialAuthenticationServiceLocator.getConnectionFactory(connectionData
            .getProviderId());
    return connectionFactory.createConnection(connectionData);
}
 
Example 11
public ConnectionFactory<?> createConnectionFactory() {
	return new GitHubConnectionFactory(
			properties.getAppId(),
			properties.getAppSecret());
}
 
Example 12
Source Project: cola   Source File: WechatConnectionConfiguration.java    License: MIT License 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	WechatConnectionFactory connectionFactory = new WechatConnectionFactory(wechatProperties.getProviderId(), wechatProperties.getAppId(), wechatProperties.getAppSecret());
	connectionFactory.setScope(wechatProperties.getScope());
	return connectionFactory;
}
 
Example 13
Source Project: cola   Source File: QQConnectConfiguration.java    License: MIT License 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	return new QQConnectionFactory(qqProperties.getProviderId(), qqProperties.getAppId(), qqProperties.getAppSecret());
}
 
Example 14
Source Project: cola   Source File: AlipayConnectConfiguration.java    License: MIT License 4 votes vote down vote up
protected ConnectionFactory<?> createConnectionFactory() {
	ConnectionFactory<?> factory = new AlipayConnectionFactory(properties);
	((AlipayConnectionFactory) factory).setScope(properties.getScope());
	return factory;
}
 
Example 15
Source Project: pre   Source File: GithubAutoAuthConfig.java    License: GNU General Public License v3.0 4 votes vote down vote up
public ConnectionFactory<?> createConnectionFactory() {
    GithubProperties github = preSecurityProperties.getSocial().getGithub();
    return new GitHubConnectionFactory(github.getProviderId(), github.getAppId(), github.getAppSecret());
}
 
Example 16
Source Project: pre   Source File: GiteeAutoAuthConfig.java    License: GNU General Public License v3.0 4 votes vote down vote up
public ConnectionFactory<?> createConnectionFactory() {
    GiteeProperties gitee = preSecurityProperties.getSocial().getGitee();
    return new GiteeConnectionFactory(gitee.getProviderId(), gitee.getAppId(), gitee.getAppSecret());
}
 
Example 17
public ConnectionFactory<?> createConnectionFactory() {
	return new GitHubConnectionFactory(
			properties.getAppId(),
			properties.getAppSecret());
}
 
Example 18
Source Project: oauth2lab   Source File: GitHubConfiguration.java    License: MIT License 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	return new GitHubConnectionFactory(properties.getAppId(),
			properties.getAppSecret());
}
 
Example 19
Source Project: paascloud-master   Source File: QQAutoConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create connection factory connection factory.
 *
 * @return the connection factory
 */
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	QQProperties qqConfig = securityProperties.getSocial().getQq();
	return new QQConnectionFactory(qqConfig.getProviderId(), qqConfig.getAppId(), qqConfig.getAppSecret());
}
 
Example 20
Source Project: FEBS-Security   Source File: QQAutoConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
    QQProperties properties = securityProperties.getSocial().getQQ();
    return new QQConnectionFactory(properties.getProviderId(), properties.getAppId(), properties.getAppSecret());
}
 
Example 21
Source Project: FEBS-Security   Source File: WeixinAutoConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
    WeiXinProperties weixinConfig = securityProperties.getSocial().getWeixin();
    return new WeiXinConnectionFactory(weixinConfig.getProviderId(), weixinConfig.getAppId(), weixinConfig.getAppSecret());
}
 
Example 22
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	return new FacebookConnectionFactory(this.properties.getAppId(), this.properties.getAppSecret());
}
 
Example 23
Source Project: OAuth-2.0-Cookbook   Source File: GitHubConfiguration.java    License: MIT License 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	return new GitHubConnectionFactory(properties.getAppId(),
			properties.getAppSecret());
}
 
Example 24
Source Project: OAuth-2.0-Cookbook   Source File: FacebookConfiguration.java    License: MIT License 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	return new CustomFacebookConnectionFactory(this.properties.getAppId(),
			this.properties.getAppSecret(), this.properties.getApiVersion());
}
 
Example 25
@Override
public ConnectionFactory<?> getConnectionFactory(final String providerId) {
    return getCurrentConnectionFactoryLocator().getConnectionFactory(providerId);
}
 
Example 26
@Override
public <A> ConnectionFactory<A> getConnectionFactory(final Class<A> apiType) {
    return getCurrentConnectionFactoryLocator().getConnectionFactory(apiType);
}
 
Example 27
protected ConnectionFactory<Facebook> createFacebookConnectionFactory(String appId, String appSecret) {
    return new FacebookConnectionFactory(appId, appSecret);
}
 
Example 28
@Override
protected ConnectionFactory<Facebook> createConnectionFactory() {
	FacebookConnectionFactory facebookConnectionFactory = new FacebookConnectionFactory(facebookConsumerKey, facebookConsumerSecret);
	facebookConnectionFactory.setScope("email");
	return facebookConnectionFactory;
}
 
Example 29
@Override
protected ConnectionFactory<Google> createConnectionFactory() {
	GoogleConnectionFactory googleConnectionFactory = new GoogleConnectionFactory(googleConsumerKey, googleConsumerSecret);
	googleConnectionFactory.setScope("email");
	return googleConnectionFactory;
}
 
Example 30
@Override
protected ConnectionFactory<Twitter> createConnectionFactory() {
	return new TwitterConnectionFactory(
			twitterConsumerKey, twitterConsumerSecret);
}