org.springframework.social.connect.web
Class ConnectController

java.lang.Object
  extended by org.springframework.social.connect.web.ConnectController

@Controller
@RequestMapping(value="/connect")
public class ConnectController
extends java.lang.Object

Generic UI controller for managing the account-to-service-provider connection flow.


Constructor Summary
ConnectController(java.lang.String applicationUrl, ConnectionFactoryLocator connectionFactoryLocator, javax.inject.Provider<ConnectionRepository> connectionRepositoryProvider)
          Constructs a ConnectController.
 
Method Summary
 void addInterceptor(ConnectInterceptor<?> interceptor)
          Adds a ConnectInterceptor to receive callbacks during the connection process.
 java.lang.String connect(java.lang.String providerId, Model model)
          Render the connect form for the service provider identified by {name} to the member as HTML in their web browser.
 java.lang.String connect(java.lang.String providerId, WebRequest request)
          Process a connect form submission by commencing the process of establishing a connection to the provider on behalf of the member.
protected  java.lang.String handleConnectToCustomConnectionFactory(ConnectionFactory<?> connectionFactory, WebRequest request)
          Hook method subclasses may override to create connections to providers of custom types other than OAuth1 or OAuth2.
 java.lang.String oauth1Callback(java.lang.String providerId, java.lang.String token, java.lang.String verifier, WebRequest request)
          Process the authorization callback from an OAuth 1 service provider.
 java.lang.String oauth2Callback(java.lang.String providerId, java.lang.String code, WebRequest request)
          Process the authorization callback from an OAuth 2 service provider.
 java.lang.String removeConnections(java.lang.String providerId)
          Remove all provider connections for a user account.
 java.lang.String removeConnections(java.lang.String providerId, java.lang.String providerUserId)
          Remove a single provider connection associated with a user account.
 void setInterceptors(java.util.List<ConnectInterceptor<?>> interceptors)
          Configure the list of interceptors that should receive callbacks during the connection process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectController

@Inject
public ConnectController(java.lang.String applicationUrl,
                                ConnectionFactoryLocator connectionFactoryLocator,
                                javax.inject.Provider<ConnectionRepository> connectionRepositoryProvider)
Constructs a ConnectController.

Parameters:
applicationUrl - the base secure URL for this application, used to construct the callback URL passed to the service providers at the beginning of the connection process.
connectionFactoryLocator - the locator for ConnectionFactory instances needed to establish connections
connectionRepositoryProvider - the provider of the current user's ConnectionRepository needed to persist connections
Method Detail

setInterceptors

public void setInterceptors(java.util.List<ConnectInterceptor<?>> interceptors)
Configure the list of interceptors that should receive callbacks during the connection process. Convenient when an instance of this class is configured using a tool that supports JavaBeans-based configuration.


addInterceptor

public void addInterceptor(ConnectInterceptor<?> interceptor)
Adds a ConnectInterceptor to receive callbacks during the connection process. Useful for programmatic configuration.


connect

@RequestMapping(value="/{providerId}",
                method=GET)
public java.lang.String connect(@PathVariable
                                                             java.lang.String providerId,
                                                             Model model)
Render the connect form for the service provider identified by {name} to the member as HTML in their web browser.


connect

@RequestMapping(value="/{providerId}",
                method=POST)
public java.lang.String connect(@PathVariable
                                                              java.lang.String providerId,
                                                              WebRequest request)
Process a connect form submission by commencing the process of establishing a connection to the provider on behalf of the member. For OAuth1, fetches a new request token from the provider, temporarily stores it in the session, then redirects the member to the provider's site for authorization. For OAuth2, redirects the user to the provider's site for authorization.


oauth1Callback

@RequestMapping(value="/{providerId}",
                method=GET,
                params="oauth_token")
public java.lang.String oauth1Callback(@PathVariable
                                                                          java.lang.String providerId,
                                                                          @RequestParam(value="oauth_token")
                                                                          java.lang.String token,
                                                                          @RequestParam(value="oauth_verifier",required=false)
                                                                          java.lang.String verifier,
                                                                          WebRequest request)
Process the authorization callback from an OAuth 1 service provider. Called after the user authorizes the connection, generally done by having he or she click "Allow" in their web browser at the provider's site. On authorization verification, connects the user's local account to the account they hold at the service provider Removes the request token from the session since it is no longer valid after the connection is established.


oauth2Callback

@RequestMapping(value="/{providerId}",
                method=GET,
                params="code")
public java.lang.String oauth2Callback(@PathVariable
                                                                          java.lang.String providerId,
                                                                          @RequestParam(value="code")
                                                                          java.lang.String code,
                                                                          WebRequest request)
Process the authorization callback from an OAuth 2 service provider. Called after the user authorizes the connection, generally done by having he or she click "Allow" in their web browser at the provider's site. On authorization verification, connects the user's local account to the account they hold at the service provider.


removeConnections

@RequestMapping(value="/{providerId}",
                method=DELETE)
public java.lang.String removeConnections(@PathVariable
                                                                          java.lang.String providerId)
Remove all provider connections for a user account. The user has decided they no longer wish to use the service provider from this application.


removeConnections

@RequestMapping(value="/{providerId}/{providerUserId}",
                method=DELETE)
public java.lang.String removeConnections(@PathVariable
                                                                          java.lang.String providerId,
                                                                          @PathVariable
                                                                          java.lang.String providerUserId)
Remove a single provider connection associated with a user account. The user has decided they no longer wish to use the service provider account from this application.


handleConnectToCustomConnectionFactory

protected java.lang.String handleConnectToCustomConnectionFactory(ConnectionFactory<?> connectionFactory,
                                                                  WebRequest request)
Hook method subclasses may override to create connections to providers of custom types other than OAuth1 or OAuth2. Default implementation throws an IllegalStateException indicating the custom ConnectionFactory is not supported.