@Controller @RequestMapping(value="/connect") public class ConnectController extends Object implements InitializingBean
Modifier and Type | Field and Description |
---|---|
protected static String |
AUTHORIZATION_ERROR_ATTRIBUTE |
protected static String |
DUPLICATE_CONNECTION_ATTRIBUTE |
protected static String |
PROVIDER_ERROR_ATTRIBUTE |
Constructor and Description |
---|
ConnectController(ConnectionFactoryLocator connectionFactoryLocator,
ConnectionRepository connectionRepository)
Constructs a ConnectController.
|
Modifier and Type | Method and Description |
---|---|
void |
addDisconnectInterceptor(DisconnectInterceptor<?> interceptor)
Adds a DisconnectInterceptor to receive callbacks during the disconnection process.
|
void |
addInterceptor(ConnectInterceptor<?> interceptor)
Adds a ConnectInterceptor to receive callbacks during the connection process.
|
void |
afterPropertiesSet() |
RedirectView |
connect(String providerId,
NativeWebRequest request)
Process a connect form submission by commencing the process of establishing a connection to the provider on behalf of the member.
|
protected String |
connectedView(String providerId)
Returns the view name of a page to display for a provider when the user is connected to the provider.
|
String |
connectionStatus(NativeWebRequest request,
Model model)
Render the status of connections across all providers to the user as HTML in their web browser.
|
String |
connectionStatus(String providerId,
NativeWebRequest request,
Model model)
Render the status of the connections to the service provider to the user as HTML in their web browser.
|
protected RedirectView |
connectionStatusRedirect(String providerId,
NativeWebRequest request)
Returns a RedirectView with the URL to redirect to after a connection is created or deleted.
|
protected String |
connectView()
Returns the view name of a general connection status page, typically displaying the user's connection status for all providers.
|
protected String |
connectView(String providerId)
Returns the view name of a page to display for a provider when the user is not connected to the provider.
|
RedirectView |
oauth1Callback(String providerId,
NativeWebRequest request)
Process the authorization callback from an OAuth 1 service provider.
|
RedirectView |
oauth2Callback(String providerId,
NativeWebRequest request)
Process the authorization 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.
|
RedirectView |
removeConnection(String providerId,
String providerUserId,
NativeWebRequest request)
Remove a single provider connection associated with a user account.
|
RedirectView |
removeConnections(String providerId,
NativeWebRequest request)
Remove all provider connections for a user account.
|
void |
setApplicationUrl(String applicationUrl)
Configures the base secure URL for the application this controller is being used in e.g.
|
void |
setConnectInterceptors(List<ConnectInterceptor<?>> interceptors)
Configure the list of connect interceptors that should receive callbacks during the connection process.
|
void |
setDisconnectInterceptors(List<DisconnectInterceptor<?>> interceptors)
Configure the list of discconnect interceptors that should receive callbacks when connections are removed.
|
void |
setInterceptors(List<ConnectInterceptor<?>> interceptors)
Deprecated.
Use
setConnectInterceptors(List) instead. |
void |
setSessionStrategy(SessionStrategy sessionStrategy)
Sets a strategy to use when persisting information that is to survive past the boundaries of a request.
|
void |
setViewPath(String viewPath)
Sets the path to connection status views.
|
protected static final String DUPLICATE_CONNECTION_ATTRIBUTE
protected static final String PROVIDER_ERROR_ATTRIBUTE
protected static final String AUTHORIZATION_ERROR_ATTRIBUTE
@Inject public ConnectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository)
connectionFactoryLocator
- the locator for ConnectionFactory
instances needed to establish connectionsconnectionRepository
- the current user's ConnectionRepository
needed to persist connections; must be a proxy to a request-scoped bean@Deprecated public void setInterceptors(List<ConnectInterceptor<?>> interceptors)
setConnectInterceptors(List)
instead.interceptors
- the connect interceptors to addpublic void setConnectInterceptors(List<ConnectInterceptor<?>> interceptors)
interceptors
- the connect interceptors to addpublic void setDisconnectInterceptors(List<DisconnectInterceptor<?>> interceptors)
interceptors
- the connect interceptors to addpublic 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 setViewPath(String viewPath)
viewPath
- The path to connection status views.public void setSessionStrategy(SessionStrategy sessionStrategy)
sessionStrategy
- the session strategy.public void addInterceptor(ConnectInterceptor<?> interceptor)
interceptor
- the connect interceptor to addpublic void addDisconnectInterceptor(DisconnectInterceptor<?> interceptor)
interceptor
- the connect interceptor to add@RequestMapping(method=GET) public String connectionStatus(NativeWebRequest request, Model model)
request
- the requestmodel
- the model@RequestMapping(value="/{providerId}", method=GET) public String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model)
providerId
- the ID of the provider to show connection statusrequest
- the requestmodel
- the model@RequestMapping(value="/{providerId}", method=POST) public RedirectView connect(@PathVariable String providerId, NativeWebRequest request)
providerId
- the provider ID to connect torequest
- the request@RequestMapping(value="/{providerId}", method=GET, params="oauth_token") public RedirectView oauth1Callback(@PathVariable String providerId, NativeWebRequest request)
providerId
- the provider ID to connect torequest
- the request@RequestMapping(value="/{providerId}", method=GET, params="code") public RedirectView oauth2Callback(@PathVariable String providerId, NativeWebRequest request)
providerId
- the provider ID to connect torequest
- the request@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 ID that the connection was attempted forerror
- the error parameter sent from the providererrorDescription
- the error_description parameter sent from the providererrorUri
- the error_uri parameter sent from the providerrequest
- the request@RequestMapping(value="/{providerId}", method=DELETE) public RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request)
HiddenHttpMethodFilter
to be registered with the '_method' request parameter set to 'DELETE' to convert web browser POSTs to DELETE requests.providerId
- the provider ID to remove the connections forrequest
- the request@RequestMapping(value="/{providerId}/{providerUserId}", method=DELETE) public RedirectView removeConnection(@PathVariable String providerId, @PathVariable String providerUserId, NativeWebRequest request)
HiddenHttpMethodFilter
to be registered with the '_method' request parameter set to 'DELETE' to convert web browser POSTs to DELETE requests.providerId
- the provider ID to remove connections forproviderUserId
- the user's ID at the providerrequest
- the requestprotected String connectView()
protected String connectView(String providerId)
providerId
- the ID of the provider to display the connection status for.protected String connectedView(String providerId)
providerId
- the ID of the provider to display the connection status for.protected RedirectView connectionStatusRedirect(String providerId, NativeWebRequest request)
providerId
- the ID of the provider for which a connection was created or deleted.request
- the NativeWebRequest used to access the servlet path when constructing the redirect path.public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception