org.springframework.social.connect.signin.web
Class ProviderSignInController

java.lang.Object
  extended by org.springframework.social.connect.signin.web.ProviderSignInController

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

Spring MVC Controller for handling the provider user sign-in flow.


Constructor Summary
ProviderSignInController(java.lang.String applicationUrl, javax.inject.Provider<ConnectionFactoryLocator> connectionFactoryLocatorProvider, UsersConnectionRepository usersConnectionRepository, javax.inject.Provider<ConnectionRepository> connectionRepositoryProvider, SignInService signInService)
          Creates a new provider sign-in controller.
 
Method Summary
 java.lang.String oauth1Callback(java.lang.String providerId, java.lang.String token, java.lang.String verifier, WebRequest request)
          Process the authentication callback from an OAuth 1 service provider.
 java.lang.String oauth2Callback(java.lang.String providerId, java.lang.String code, WebRequest request)
          Process the authentication callback from an OAuth 2 service provider.
 void setSignupUrl(java.lang.String signupUrl)
          Overrides the default URL of the application's signup page ("/signup").
 java.lang.String signin(java.lang.String providerId, WebRequest request)
          Process a sign-in form submission by commencing the process of establishing a connection to the provider on behalf of the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProviderSignInController

@Inject
public ProviderSignInController(java.lang.String applicationUrl,
                                       javax.inject.Provider<ConnectionFactoryLocator> connectionFactoryLocatorProvider,
                                       UsersConnectionRepository usersConnectionRepository,
                                       javax.inject.Provider<ConnectionRepository> connectionRepositoryProvider,
                                       SignInService signInService)
Creates a new provider sign-in controller.

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 sign-in process.
connectionFactoryLocatorProvider - the provider of the locator of connection factories that can be used for sign-in; A JSR330 Provider is injected here instead of the actual locator object to support the fact ProviderSignInAttempt objects are session-scoped and thus require a Serializable reference to a ConnectionFactoryLocator. The injected Provider should be Serializable, otherwise NotSerializableException instances could occur during the provider sign-in flow.
usersConnectionRepository - the global store for service provider connections across all local user accounts
connectionRepositoryProvider - the provider of the current user's ConnectionRepository instance; A JSR 330 Provider is injected here instead of the actual repository object because repository instances are request-scoped and resolved based on the currently authenticated user.
signInService - an adapter between this controller and the local application's user sign-in system.
Method Detail

signin

@RequestMapping(value="/{providerId}",
                method=POST)
public java.lang.String signin(@PathVariable
                                                             java.lang.String providerId,
                                                             WebRequest request)
Process a sign-in form submission by commencing the process of establishing a connection to the provider on behalf of the user. For OAuth1, fetches a new request token from the provider, temporarily stores it in the session, then redirects the user to the provider's site for authentication authorization. For OAuth2, redirects the user to the provider's site for authentication 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 authentication callback from an OAuth 1 service provider. Called after the member authorizes the authentication, generally done once by having he or she click "Allow" in their web browser at the provider's site. Handles the provider sign-in callback by first determining if a local user account is associated with the connected provider account. If so, signs the local user in by delegating to SignInService.signIn(String). If not, redirects the user to a signup page to create a new account with ProviderSignInAttempt context exposed in the HttpSession.

See Also:
ProviderSignInAttempt, ProviderSignInUtils

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 authentication callback from an OAuth 2 service provider. Called after the user authorizes the authentication, generally done once by having he or she click "Allow" in their web browser at the provider's site. Handles the provider sign-in callback by first determining if a local user account is associated with the connected provider account. If so, signs the local user in by delegating to SignInService.signIn(String). If not, redirects the user to a signup page to create a new account with ProviderSignInAttempt context exposed in the HttpSession.

See Also:
ProviderSignInAttempt, ProviderSignInUtils

setSignupUrl

public void setSignupUrl(java.lang.String signupUrl)
Overrides the default URL of the application's signup page ("/signup"). ProviderSignInController will redirect to this URL if no matching connection can be found after signing into the provider.

Parameters:
signupUrl - the URL of the signup page.