use of org.springframework.social.connect.support.OAuth2ConnectionFactory in project profile by craftercms.
the class ProviderLoginSupportImpl method completeConnection.
protected Connection<?> completeConnection(ConnectSupport connectSupport, String providerId, HttpServletRequest request) throws OAuth2Exception {
if (StringUtils.isNotEmpty(request.getParameter(PARAM_OAUTH_TOKEN))) {
OAuth1ConnectionFactory<?> connectionFactory = (OAuth1ConnectionFactory<?>) getConnectionFactory(providerId);
ServletWebRequest webRequest = new ServletWebRequest(request);
return connectSupport.completeConnection(connectionFactory, webRequest);
} else if (StringUtils.isNotEmpty(request.getParameter(PARAM_CODE))) {
OAuth2ConnectionFactory<?> connectionFactory = (OAuth2ConnectionFactory<?>) getConnectionFactory(providerId);
ServletWebRequest webRequest = new ServletWebRequest(request);
return connectSupport.completeConnection(connectionFactory, webRequest);
} else if (StringUtils.isNotEmpty(request.getParameter(PARAM_ERROR))) {
String error = request.getParameter(PARAM_ERROR);
String errorDescription = request.getParameter(PARAM_ERROR_DESCRIPTION);
String errorUri = request.getParameter(PARAM_ERROR_URI);
throw new OAuth2Exception(error, errorDescription, errorUri);
} else {
return null;
}
}
use of org.springframework.social.connect.support.OAuth2ConnectionFactory in project syndesis by syndesisio.
the class OAuth2CredentialProviderFactory method create.
@Override
public CredentialProvider create(final SocialProperties properties) {
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<>("oauth2", serviceProvider, null);
connectionFactory.setScope(scope);
final OAuth2Applicator applicator = new OAuth2Applicator(properties);
applicator.setAccessTokenProperty("accessToken");
return new OAuth2CredentialProvider<>("oauth2", connectionFactory, applicator);
}
Aggregations