Spring Social

org.springframework.social.connect.web
Class ProviderSignInController

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

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

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

Author:
Keith Donald

Constructor Summary
ProviderSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter)
          Creates a new provider sign-in controller.
 
Method Summary
 org.springframework.web.servlet.view.RedirectView canceledAuthorizationCallback()
          Process the authentication callback when neither the oauth_token or code parameter is given, likely indicating that the user denied authorization with the provider.
 org.springframework.web.servlet.view.RedirectView oauth1Callback(java.lang.String providerId, org.springframework.web.context.request.NativeWebRequest request)
          Process the authentication callback from an OAuth 1 service provider.
 org.springframework.web.servlet.view.RedirectView oauth2Callback(java.lang.String providerId, java.lang.String code, org.springframework.web.context.request.NativeWebRequest request)
          Process the authentication callback from an OAuth 2 service provider.
 void setApplicationUrl(java.lang.String applicationUrl)
          Configures the base secure URL for the application this controller is being used in e.g.
 void setPostSignInUrl(java.lang.String postSignInUrl)
          Sets the default URL to redirect the user to after signing in using a provider.
 void setSignInUrl(java.lang.String signInUrl)
          Sets the URL of the application's sign in page.
 void setSignUpUrl(java.lang.String signUpUrl)
          Sets the URL to redirect the user to if no local user account can be mapped when signing in using a provider.
 org.springframework.web.servlet.view.RedirectView signIn(java.lang.String providerId, org.springframework.web.context.request.NativeWebRequest 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(ConnectionFactoryLocator connectionFactoryLocator,
                                       UsersConnectionRepository usersConnectionRepository,
                                       SignInAdapter signInAdapter)
Creates a new provider sign-in controller.

Parameters:
connectionFactoryLocator - the locator of connection factories used to support provider sign-in. Note: this reference should be a serializable proxy to a singleton-scoped target instance. This is because ProviderSignInAttempt are session-scoped objects that hold ConnectionFactoryLocator references. If these references cannot be serialized, NotSerializableExceptions can occur at runtime.
usersConnectionRepository - the global store for service provider connections across all users. Note: this reference should be a serializable proxy to a singleton-scoped target instance.
signInAdapter - handles user sign-in
Method Detail

setSignInUrl

public void setSignInUrl(java.lang.String signInUrl)
Sets the URL of the application's sign in page. Defaults to "/signin".

Parameters:
signInUrl - the signIn URL

setSignUpUrl

public void setSignUpUrl(java.lang.String signUpUrl)
Sets the URL to redirect the user to if no local user account can be mapped when signing in using a provider. Defaults to "/signup".

Parameters:
signUpUrl - the signUp URL

setPostSignInUrl

public void setPostSignInUrl(java.lang.String postSignInUrl)
Sets the default URL to redirect the user to after signing in using a provider. Defaults to "/".

Parameters:
postSignInUrl - the postSignIn URL

setApplicationUrl

public void setApplicationUrl(java.lang.String applicationUrl)
Configures the base secure URL for the application this controller is being used in e.g. https://myapp.com. Defaults to null. If specified, will be used to generate OAuth callback URLs. If not specified, OAuth callback URLs are generated from web request info. You may wish to set this property if requests into your application flow through a proxy to your application server. In this case, the request URI may contain a scheme, host, and/or port value that points to an internal server not appropriate for an external callback URL. If you have this problem, you can set this property to the base external URL for your application and it will be used to construct the callback URL instead.

Parameters:
applicationUrl - the application URL value

signIn

@RequestMapping(value="/{providerId}",
                method=POST)
public org.springframework.web.servlet.view.RedirectView signIn(@PathVariable
                                                                               java.lang.String providerId,
                                                                               org.springframework.web.context.request.NativeWebRequest 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 org.springframework.web.servlet.view.RedirectView oauth1Callback(@PathVariable
                                                                                       java.lang.String providerId,
                                                                                       org.springframework.web.context.request.NativeWebRequest 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 SignInAdapter.signIn(String, Connection, NativeWebRequest) 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 org.springframework.web.servlet.view.RedirectView oauth2Callback(@PathVariable
                                                                                       java.lang.String providerId,
                                                                                       @RequestParam(value="code")
                                                                                       java.lang.String code,
                                                                                       org.springframework.web.context.request.NativeWebRequest 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 SignInAdapter.signIn(String, Connection, NativeWebRequest). 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

canceledAuthorizationCallback

@RequestMapping(value="/{providerId}",
                method=GET)
public org.springframework.web.servlet.view.RedirectView canceledAuthorizationCallback()
Process the authentication callback when neither the oauth_token or code parameter is given, likely indicating that the user denied authorization with the provider. Redirects to application's sign in URL, as set in the signInUrl property.


Spring Social