Class ConnectSupport
- java.lang.Object
-
- org.springframework.social.connect.web.ConnectSupport
-
public class ConnectSupport extends Object
Provides common connect support and utilities for Java web/servlet environments. Used byConnectControllerandProviderSignInController.- Author:
- Keith Donald
-
-
Constructor Summary
Constructors Constructor Description ConnectSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringbuildOAuthUrl(ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request)Builds the provider URL to redirect the user to for connection authorization.StringbuildOAuthUrl(ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request, org.springframework.util.MultiValueMap<String,String> additionalParameters)Builds the provider URL to redirect the user to for connection authorization.protected StringcallbackUrl(org.springframework.web.context.request.NativeWebRequest request)Connection<?>completeConnection(OAuth1ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request)Complete the connection to the OAuth1 provider.Connection<?>completeConnection(OAuth2ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request)Complete the connection to the OAuth2 provider.voidsetApplicationUrl(String applicationUrl)Configures the base secure URL for the application this controller is being used in e.g.voidsetCallbackUrl(String callbackUrl)Configures a specific callback URL that is to be used instead of calculating one based on the application URL or current request URL.voidsetUseAuthenticateUrl(boolean useAuthenticateUrl)Flag indicating if this instance will support OAuth-based authentication instead of the traditional user authorization.
-
-
-
Method Detail
-
setUseAuthenticateUrl
public void setUseAuthenticateUrl(boolean useAuthenticateUrl)
Flag indicating if this instance will support OAuth-based authentication instead of the traditional user authorization. Some providers expose a special "authenticateUrl" the user should be redirected to as part of an OAuth-based authentication attempt. Setting this flag to true hasoauthUrlreturn this authenticate URL.- Parameters:
useAuthenticateUrl- whether to use the authenticat url or not- See Also:
OAuth1Operations.buildAuthenticateUrl(String, OAuth1Parameters),OAuth2Operations.buildAuthenticateUrl(GrantType, OAuth2Parameters)
-
setApplicationUrl
public void setApplicationUrl(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 fromHttpServletRequests. You may wish to set this property if requests into your application flow through a proxy to your application server. In this case, the HttpServletRequest 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
-
setCallbackUrl
public void setCallbackUrl(String callbackUrl)
Configures a specific callback URL that is to be used instead of calculating one based on the application URL or current request URL. When set this URL will override the default behavior where the callback URL is derived from the current request and/or a specified application URL. When set along with applicationUrl, the applicationUrl will be ignored.- Parameters:
callbackUrl- the callback URL to send to providers during authorization. Default is null.
-
buildOAuthUrl
public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request)
Builds the provider URL to redirect the user to for connection authorization.- Parameters:
connectionFactory- the service provider's connection factory e.g. FacebookConnectionFactoryrequest- the current web request- Returns:
- the URL to redirect the user to for authorization
- Throws:
IllegalArgumentException- if the connection factory is not OAuth1 based.
-
buildOAuthUrl
public String buildOAuthUrl(ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request, org.springframework.util.MultiValueMap<String,String> additionalParameters)
Builds the provider URL to redirect the user to for connection authorization.- Parameters:
connectionFactory- the service provider's connection factory e.g. FacebookConnectionFactoryrequest- the current web requestadditionalParameters- parameters to add to the authorization URL.- Returns:
- the URL to redirect the user to for authorization
- Throws:
IllegalArgumentException- if the connection factory is not OAuth1 based.
-
completeConnection
public Connection<?> completeConnection(OAuth1ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request)
Complete the connection to the OAuth1 provider.- Parameters:
connectionFactory- the service provider's connection factory e.g. FacebookConnectionFactoryrequest- the current web request- Returns:
- a new connection to the service provider
-
completeConnection
public Connection<?> completeConnection(OAuth2ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request)
Complete the connection to the OAuth2 provider.- Parameters:
connectionFactory- the service provider's connection factory e.g. FacebookConnectionFactoryrequest- the current web request- Returns:
- a new connection to the service provider
-
callbackUrl
protected String callbackUrl(org.springframework.web.context.request.NativeWebRequest request)
-
-