Spring Social

org.springframework.social.connect.support
Class OAuth2ConnectionFactory<S>

java.lang.Object
  extended by org.springframework.social.connect.ConnectionFactory<S>
      extended by org.springframework.social.connect.support.OAuth2ConnectionFactory<S>
Type Parameters:
S - the service API type.

public class OAuth2ConnectionFactory<S>
extends ConnectionFactory<S>

Factory for creating OAuth2-based Connections. May be subclassed to further simplify construction e.g. FacebookConnectionFactory.

Author:
Keith Donald

Constructor Summary
OAuth2ConnectionFactory(java.lang.String providerId, OAuth2ServiceProvider<S> serviceProvider, ApiAdapter<S> apiAdapter)
          Create a OAuth2ConnectionFactory.
 
Method Summary
 Connection<S> createConnection(AccessGrant accessGrant)
          Create a OAuth2-based Connection from the AccessGrant returned after completing the OAuth2 flow.
 Connection<S> createConnection(ConnectionData data)
          Create a OAuth2-based Connection from the connection data.
protected  java.lang.String extractProviderUserId(AccessGrant accessGrant)
          Hook for extracting the providerUserId from the returned AccessGrant, if it is available.
 OAuth2Operations getOAuthOperations()
          Get the ServiceProvider's OAuth2Operations that allows the client application to conduct the OAuth2 flow with the provider.
 
Methods inherited from class org.springframework.social.connect.ConnectionFactory
getApiAdapter, getProviderId, getServiceProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAuth2ConnectionFactory

public OAuth2ConnectionFactory(java.lang.String providerId,
                               OAuth2ServiceProvider<S> serviceProvider,
                               ApiAdapter<S> apiAdapter)
Create a OAuth2ConnectionFactory.

Parameters:
providerId - the provider id e.g. "facebook"
serviceProvider - the ServiceProvider model for conducting the authorization flow and obtaining a native service API instance.
apiAdapter - the ApiAdapter for mapping the provider-specific service API model to the uniform Connection interface.
Method Detail

getOAuthOperations

public OAuth2Operations getOAuthOperations()
Get the ServiceProvider's OAuth2Operations that allows the client application to conduct the OAuth2 flow with the provider.


createConnection

public Connection<S> createConnection(AccessGrant accessGrant)
Create a OAuth2-based Connection from the AccessGrant returned after completing the OAuth2 flow.

Parameters:
accessGrant - the access grant
Returns:
the new service provider connection
See Also:
OAuth2Operations.exchangeForAccess(String, String, org.springframework.util.MultiValueMap)

createConnection

public Connection<S> createConnection(ConnectionData data)
Create a OAuth2-based Connection from the connection data.

Specified by:
createConnection in class ConnectionFactory<S>

extractProviderUserId

protected java.lang.String extractProviderUserId(AccessGrant accessGrant)
Hook for extracting the providerUserId from the returned AccessGrant, if it is available. Default implementation returns null, indicating it is not exposed and another remote API call will be required to obtain it. Subclasses may override.


Spring Social