@Controller @RequestMapping(value="/signin") public class ProviderSignInController extends Object implements InitializingBean
Constructor and Description |
---|
ProviderSignInController(ConnectionFactoryLocator connectionFactoryLocator,
UsersConnectionRepository usersConnectionRepository,
SignInAdapter signInAdapter)
Creates a new provider sign-in controller.
|
Modifier and Type | Method and Description |
---|---|
void |
addSignInInterceptor(ProviderSignInInterceptor<?> interceptor)
Adds a ConnectInterceptor to receive callbacks during the connection process.
|
void |
afterPropertiesSet() |
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.
|
RedirectView |
oauth1Callback(String providerId,
NativeWebRequest request)
Process the authentication callback from an OAuth 1 service provider.
|
RedirectView |
oauth2Callback(String providerId,
String code,
NativeWebRequest request)
Process the authentication callback from an OAuth 2 service provider.
|
RedirectView |
oauth2ErrorCallback(String providerId,
String error,
String errorDescription,
String errorUri,
NativeWebRequest request)
Process an error callback from an OAuth 2 authorization as described at http://tools.ietf.org/html/rfc6749#section-4.1.2.1.
|
void |
setApplicationUrl(String applicationUrl)
Configures the base secure URL for the application this controller is being used in e.g.
|
void |
setPostSignInUrl(String postSignInUrl)
Sets the default URL to redirect the user to after signing in using a provider.
|
void |
setSessionStrategy(SessionStrategy sessionStrategy)
Sets a strategy to use when persisting information that is to survive past the boundaries of a request.
|
void |
setSignInInterceptors(List<ProviderSignInInterceptor<?>> interceptors)
Configure the list of sign in interceptors that should receive callbacks during the sign in process.
|
void |
setSignInUrl(String signInUrl)
Sets the URL of the application's sign in page.
|
void |
setSignUpUrl(String signUpUrl)
Sets the URL to redirect the user to if no local user account can be mapped when signing in using a provider.
|
RedirectView |
signIn(String providerId,
NativeWebRequest request)
Process a sign-in form submission by commencing the process of establishing a connection to the provider on behalf of the user.
|
@Inject public ProviderSignInController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter)
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-inpublic void setSignInInterceptors(List<ProviderSignInInterceptor<?>> interceptors)
interceptors
- the sign in interceptors to addpublic void setSignInUrl(String signInUrl)
signInUrl
- the signIn URLpublic void setSignUpUrl(String signUpUrl)
signUpUrl
- the signUp URLpublic void setPostSignInUrl(String postSignInUrl)
postSignInUrl
- the postSignIn URLpublic void setApplicationUrl(String applicationUrl)
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.applicationUrl
- the application URL valuepublic void setSessionStrategy(SessionStrategy sessionStrategy)
sessionStrategy
- the session strategy.public void addSignInInterceptor(ProviderSignInInterceptor<?> interceptor)
interceptor
- the connect interceptor to add@RequestMapping(value="/{providerId}", method=POST) public RedirectView signIn(@PathVariable String providerId, NativeWebRequest request)
providerId
- the provider ID to authorize againstrequest
- the request@RequestMapping(value="/{providerId}", method=GET, params="oauth_token") public RedirectView oauth1Callback(@PathVariable String providerId, NativeWebRequest request)
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.providerId
- the provider ID to authorize againstrequest
- the requestProviderSignInAttempt
,
ProviderSignInUtils
@RequestMapping(value="/{providerId}", method=GET, params="code") public RedirectView oauth2Callback(@PathVariable String providerId, @RequestParam(value="code") String code, NativeWebRequest request)
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.providerId
- the provider ID to authorize againstcode
- the OAuth 2 authorization coderequest
- the web requestProviderSignInAttempt
,
ProviderSignInUtils
@RequestMapping(value="/{providerId}", method=GET, params="error") public RedirectView oauth2ErrorCallback(@PathVariable String providerId, @RequestParam(value="error") String error, @RequestParam(value="error_description",required=false) String errorDescription, @RequestParam(value="error_uri",required=false) String errorUri, NativeWebRequest request)
providerId
- The Provider IDerror
- An error parameter sent on the redirect from the providererrorDescription
- An optional error description sent from the providererrorUri
- An optional error URI sent from the providerrequest
- The web request@RequestMapping(value="/{providerId}", method=GET) public RedirectView canceledAuthorizationCallback()
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception