Spring Social

org.springframework.social.connect.web
Class ConnectSupport

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

public class ConnectSupport
extends java.lang.Object

Provides common connect support and utilities for Java web/servlet environments. Used by ConnectController and ProviderSignInController.

Author:
Keith Donald

Constructor Summary
ConnectSupport()
           
 
Method Summary
 java.lang.String buildOAuthUrl(ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request)
          Builds the provider URL to redirect the user to for connection authorization.
 java.lang.String buildOAuthUrl(ConnectionFactory<?> connectionFactory, org.springframework.web.context.request.NativeWebRequest request, org.springframework.util.MultiValueMap<java.lang.String,java.lang.String> additionalParameters)
          Builds the provider URL to redirect the user to for connection authorization.
 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.
 void setApplicationUrl(java.lang.String applicationUrl)
          Configures the base secure URL for the application this controller is being used in e.g.
 void setUseAuthenticateUrl(boolean useAuthenticateUrl)
          Flag indicating if this instance will support OAuth-based authentication instead of the traditional user authorization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectSupport

public ConnectSupport()
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 has oauthUrl return 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(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 HttpServletRequests. 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

buildOAuthUrl

public java.lang.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. FacebookConnectionFactory
request - the current web request
Returns:
the URL to redirect the user to for authorization
Throws:
java.lang.IllegalArgumentException - if the connection factory is not OAuth1 based.

buildOAuthUrl

public java.lang.String buildOAuthUrl(ConnectionFactory<?> connectionFactory,
                                      org.springframework.web.context.request.NativeWebRequest request,
                                      org.springframework.util.MultiValueMap<java.lang.String,java.lang.String> additionalParameters)
Builds the provider URL to redirect the user to for connection authorization.

Parameters:
connectionFactory - the service provider's connection factory e.g. FacebookConnectionFactory
request - the current web request
additionalParameters - parameters to add to the authorization URL.
Returns:
the URL to redirect the user to for authorization
Throws:
java.lang.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. FacebookConnectionFactory
request - 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. FacebookConnectionFactory
request - the current web request
Returns:
a new connection to the service provider

Spring Social