Java Code Examples for org.springframework.social.oauth2.OAuth2ServiceProvider

The following examples show how to use org.springframework.social.oauth2.OAuth2ServiceProvider. 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
Source Project: syndesis   Source File: OAuth2CredentialProviderFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CredentialProvider create(final SocialProperties properties) {
    if (properties instanceof UnconfiguredProperties) {
        return new OAuth2CredentialProvider<>(OAUTH_2);
    }

    if (!(properties instanceof OAuth2ConnectorProperties)) {
        throw new IllegalArgumentException(String.format("Unsupported social properties instance - " +
                "expected properties of type %s, but found %s", OAuth2ConnectorProperties.class, properties.getClass()));
    }

    final OAuth2ConnectorProperties oauth2Properties = (OAuth2ConnectorProperties) properties;

    final String appId = oauth2Properties.getAppId();
    final String appSecret = oauth2Properties.getAppSecret();
    final String authorizationUrl = oauth2Properties.getAuthorizationUrl();
    final String authenticationUrl = oauth2Properties.getAuthenticationUrl();
    final String accessTokenUrl = oauth2Properties.getAccessTokenUrl();
    final boolean useParametersForClientCredentials = oauth2Properties.isUseParametersForClientCredentials();
    final TokenStrategy tokenStrategy = oauth2Properties.getTokenStrategy();
    final String scope = oauth2Properties.getScope();

    final OAuth2ServiceProvider<RestOperations> serviceProvider = new GenericOAuth2ServiceProvider(appId, appSecret, authorizationUrl,
        authenticationUrl, accessTokenUrl, useParametersForClientCredentials, tokenStrategy);

    final OAuth2ConnectionFactory<RestOperations> connectionFactory = new OAuth2ConnectionFactory<>(OAUTH_2, serviceProvider, null);
    connectionFactory.setScope(scope);

    final OAuth2Applicator applicator = new OAuth2Applicator(properties);
    applicator.setAccessTokenProperty("accessToken");
    applicator.setAccessTokenExpiresAtProperty("accessTokenExpiresAt");

    applicator.setRefreshTokenProperty("refreshToken");
    applicator.setClientIdProperty("clientId");
    applicator.setClientSecretProperty("clientSecret");

    return new OAuth2CredentialProvider<>(OAUTH_2, connectionFactory, applicator, oauth2Properties.getAdditionalQueryParameters());
}
 
Example 2
Source Project: cola   Source File: WechatConnectionFactory.java    License: MIT License 4 votes vote down vote up
private OAuth2ServiceProvider<Wechat> getOAuth2ServiceProvider() {
    return (OAuth2ServiceProvider<Wechat>) getServiceProvider();
}
 
Example 3
Source Project: cola   Source File: WechatMpConnectionFactory.java    License: MIT License 4 votes vote down vote up
private OAuth2ServiceProvider<WechatMp> getOAuth2ServiceProvider() {
    return (OAuth2ServiceProvider<WechatMp>) getServiceProvider();
}
 
Example 4
Source Project: pre   Source File: WeixinConnectionFactory.java    License: GNU General Public License v3.0 4 votes vote down vote up
private OAuth2ServiceProvider<Weixin> getOAuth2ServiceProvider() {
    return (OAuth2ServiceProvider<Weixin>) getServiceProvider();
}
 
Example 5
Source Project: paascloud-master   Source File: WeixinConnectionFactory.java    License: Apache License 2.0 4 votes vote down vote up
private OAuth2ServiceProvider<Weixin> getOAuth2ServiceProvider() {
	return (OAuth2ServiceProvider<Weixin>) getServiceProvider();
}
 
Example 6
Source Project: FEBS-Security   Source File: WeiXinConnectionFactory.java    License: Apache License 2.0 4 votes vote down vote up
private OAuth2ServiceProvider<WeiXin> getOAuth2ServiceProvider() {
    return (OAuth2ServiceProvider<WeiXin>) getServiceProvider();
}
 
Example 7
private OAuth2ServiceProvider<Yahoo2> getOAuth2ServiceProviderWithGuid(AccessGrant accessGrant) {
	YahooOAuth2ServiceProvider yahooSP = (YahooOAuth2ServiceProvider) getServiceProvider();
	yahooSP.setGuid(((YahooAccessGrant) accessGrant).getXoauthYahooGuid());
	return yahooSP;
}