org.springframework.social.connect.ConnectionFactory Java Examples

The following examples show how to use org.springframework.social.connect.ConnectionFactory. 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
Source File: ConfigAwareConnectionFactoryLocatorTest.java    From engine with GNU General Public License v3.0 6 votes vote down vote up
@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 File: MongoConnectionRepositoryImpl.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
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 #3
Source File: WechatMpConnectionConfiguration.java    From cola with 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 #4
Source File: JpaConnectionRepository.java    From computoser with GNU Affero General Public License v3.0 5 votes vote down vote up
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 #5
Source File: QQAutoConfig.java    From pre with 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 #6
Source File: FacebookConnectionFactoryConfigParser.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@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 #7
Source File: WeixinAuthConfig.java    From pre with 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 #8
Source File: WeixinAutoConfiguration.java    From paascloud-master with 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 #9
Source File: WechatMpAutoConfiguration.java    From spring-social-wechat with Apache License 2.0 5 votes vote down vote up
@Override
protected ConnectionFactory<WechatMp> createConnectionFactory() {
	final WechatMpConnectionFactory factory = new WechatMpConnectionFactory(properties.getAppId(),
			properties.getAppSecret());
	factory.setScope(properties.getScope());
	return factory;
}
 
Example #10
Source File: WechatAutoConfiguration.java    From spring-social-wechat with Apache License 2.0 5 votes vote down vote up
@Override
protected ConnectionFactory<Wechat> createConnectionFactory() {
	final WechatConnectionFactory factory = new WechatConnectionFactory(properties.getAppId(),
			properties.getAppSecret());
	factory.setScope(properties.getScope());
	return factory;
}
 
Example #11
Source File: FacebookConfiguration.java    From OAuth-2.0-Cookbook with 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 #12
Source File: FacebookAutoConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	return new FacebookConnectionFactory(this.properties.getAppId(), this.properties.getAppSecret());
}
 
Example #13
Source File: ConfigAwareConnectionFactoryLocator.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ConnectionFactory<?> getConnectionFactory(final String providerId) {
    return getCurrentConnectionFactoryLocator().getConnectionFactory(providerId);
}
 
Example #14
Source File: ConfigAwareConnectionFactoryLocator.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
@Override
public <A> ConnectionFactory<A> getConnectionFactory(final Class<A> apiType) {
    return getCurrentConnectionFactoryLocator().getConnectionFactory(apiType);
}
 
Example #15
Source File: FacebookConnectionFactoryConfigParser.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
protected ConnectionFactory<Facebook> createFacebookConnectionFactory(String appId, String appSecret) {
    return new FacebookConnectionFactory(appId, appSecret);
}
 
Example #16
Source File: FacebookProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected ConnectionFactory<Facebook> createConnectionFactory() {
	FacebookConnectionFactory facebookConnectionFactory = new FacebookConnectionFactory(facebookConsumerKey, facebookConsumerSecret);
	facebookConnectionFactory.setScope("email");
	return facebookConnectionFactory;
}
 
Example #17
Source File: GoogleProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected ConnectionFactory<Google> createConnectionFactory() {
	GoogleConnectionFactory googleConnectionFactory = new GoogleConnectionFactory(googleConsumerKey, googleConsumerSecret);
	googleConnectionFactory.setScope("email");
	return googleConnectionFactory;
}
 
Example #18
Source File: TwitterProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected ConnectionFactory<Twitter> createConnectionFactory() {
	return new TwitterConnectionFactory(
			twitterConsumerKey, twitterConsumerSecret);
}
 
Example #19
Source File: FacebookProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected ConnectionFactory<Facebook> createConnectionFactory() {
	FacebookConnectionFactory facebookConnectionFactory = new FacebookConnectionFactory(facebookConsumerKey, facebookConsumerSecret);
	facebookConnectionFactory.setScope("email");
	return facebookConnectionFactory;
}
 
Example #20
Source File: GoogleProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected ConnectionFactory<Google> createConnectionFactory() {
	GoogleConnectionFactory googleConnectionFactory = new GoogleConnectionFactory(googleConsumerKey, googleConsumerSecret);
	googleConnectionFactory.setScope("email");
	return googleConnectionFactory;
}
 
Example #21
Source File: TwitterProviderConfig.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected ConnectionFactory<Twitter> createConnectionFactory() {
	return new TwitterConnectionFactory(
			twitterConsumerKey, twitterConsumerSecret);
}
 
Example #22
Source File: GitHubConfiguration.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	return new GitHubConnectionFactory(properties.getAppId(),
			properties.getAppSecret());
}
 
Example #23
Source File: CustomSocialAutoConfigurerAdapter.java    From codeway_service with GNU General Public License v3.0 4 votes vote down vote up
public ConnectionFactory<?> createConnectionFactory() {
	return new GitHubConnectionFactory(
			properties.getAppId(),
			properties.getAppSecret());
}
 
Example #24
Source File: WeixinAutoConfiguration.java    From FEBS-Security with 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 #25
Source File: QQAutoConfig.java    From FEBS-Security with 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 #26
Source File: QQAutoConfig.java    From paascloud-master with 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 #27
Source File: GitHubConfiguration.java    From oauth2lab with MIT License 4 votes vote down vote up
@Override
protected ConnectionFactory<?> createConnectionFactory() {
	return new GitHubConnectionFactory(properties.getAppId(),
			properties.getAppSecret());
}
 
Example #28
Source File: CustomSocialAutoConfigurerAdapter.java    From codeway_service with GNU General Public License v3.0 4 votes vote down vote up
public ConnectionFactory<?> createConnectionFactory() {
	return new GitHubConnectionFactory(
			properties.getAppId(),
			properties.getAppSecret());
}
 
Example #29
Source File: GiteeAutoAuthConfig.java    From pre with 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 #30
Source File: GithubAutoAuthConfig.java    From pre with 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());
}