org.springframework.social.oauth2.OAuth2ServiceProvider Java Examples

The following examples show how to use org.springframework.social.oauth2.OAuth2ServiceProvider. 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: OAuth2CredentialProviderFactory.java    From syndesis with 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 File: WechatConnectionFactory.java    From cola with MIT License 4 votes vote down vote up
private OAuth2ServiceProvider<Wechat> getOAuth2ServiceProvider() {
    return (OAuth2ServiceProvider<Wechat>) getServiceProvider();
}
 
Example #3
Source File: WechatMpConnectionFactory.java    From cola with MIT License 4 votes vote down vote up
private OAuth2ServiceProvider<WechatMp> getOAuth2ServiceProvider() {
    return (OAuth2ServiceProvider<WechatMp>) getServiceProvider();
}
 
Example #4
Source File: WeixinConnectionFactory.java    From pre with GNU General Public License v3.0 4 votes vote down vote up
private OAuth2ServiceProvider<Weixin> getOAuth2ServiceProvider() {
    return (OAuth2ServiceProvider<Weixin>) getServiceProvider();
}
 
Example #5
Source File: WeixinConnectionFactory.java    From paascloud-master with Apache License 2.0 4 votes vote down vote up
private OAuth2ServiceProvider<Weixin> getOAuth2ServiceProvider() {
	return (OAuth2ServiceProvider<Weixin>) getServiceProvider();
}
 
Example #6
Source File: WeiXinConnectionFactory.java    From FEBS-Security with Apache License 2.0 4 votes vote down vote up
private OAuth2ServiceProvider<WeiXin> getOAuth2ServiceProvider() {
    return (OAuth2ServiceProvider<WeiXin>) getServiceProvider();
}
 
Example #7
Source File: YahooOAuth2ConnectionFactory.java    From cloudstreetmarket.com with GNU General Public License v3.0 4 votes vote down vote up
private OAuth2ServiceProvider<Yahoo2> getOAuth2ServiceProviderWithGuid(AccessGrant accessGrant) {
	YahooOAuth2ServiceProvider yahooSP = (YahooOAuth2ServiceProvider) getServiceProvider();
	yahooSP.setGuid(((YahooAccessGrant) accessGrant).getXoauthYahooGuid());
	return yahooSP;
}