Class ProviderLoginSupportImpl
- java.lang.Object
-
- org.craftercms.security.social.impl.ProviderLoginSupportImpl
-
- All Implemented Interfaces:
ProviderLoginSupport
public class ProviderLoginSupportImpl extends Object implements ProviderLoginSupport
Default implementation ofProviderLoginSupport
. Oncomplete(String, String, HttpServletRequest)
, if the user data of the provider connection corresponds to an existing Crafter Profile user, the profile connection data will be updated. If a profile doesn't exist, a new one with the connection data will be created. In both cases, the user is automatically authenticated with Crafter Profile.- Author:
- avasquez
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthenticationManager
authenticationManager
protected org.springframework.social.connect.ConnectionFactoryLocator
connectionFactoryLocator
protected org.springframework.social.connect.web.ConnectSupport
connectSupport
static String
PARAM_CODE
static String
PARAM_ERROR
static String
PARAM_ERROR_DESCRIPTION
static String
PARAM_ERROR_URI
static String
PARAM_OAUTH_TOKEN
protected org.craftercms.profile.api.services.ProfileService
profileService
protected org.craftercms.commons.crypto.TextEncryptor
textEncryptor
-
Constructor Summary
Constructors Constructor Description ProviderLoginSupportImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Authentication
complete(String tenant, String providerId, javax.servlet.http.HttpServletRequest request)
Completes the OAuth authentication, returning the resultingAuthentication
object, or null if it couldn't be completed.Authentication
complete(String tenant, String providerId, javax.servlet.http.HttpServletRequest request, Set<String> newUserRoles, Map<String,Object> newUserAttributes)
Completes the OAuth authentication, returning the resultingAuthentication
object, or null if it couldn't be completed.Authentication
complete(String tenant, String providerId, javax.servlet.http.HttpServletRequest request, Set<String> newUserRoles, Map<String,Object> newUserAttributes, org.springframework.social.connect.web.ConnectSupport connectSupport)
Completes the OAuth authentication, returning the resultingAuthentication
object, or null if it couldn't be completed.protected org.springframework.social.connect.Connection<?>
completeConnection(org.springframework.social.connect.web.ConnectSupport connectSupport, String providerId, javax.servlet.http.HttpServletRequest request)
protected org.craftercms.profile.api.Profile
createProfile(String tenant, org.springframework.social.connect.Connection<?> connection, org.craftercms.profile.api.Profile userData)
protected org.springframework.social.connect.ConnectionFactory<?>
getConnectionFactory(String providerId)
protected org.craftercms.profile.api.Profile
getProfile(String tenant, org.craftercms.profile.api.Profile userData)
void
setAuthenticationManager(AuthenticationManager authenticationManager)
void
setConnectionFactoryLocator(org.springframework.social.connect.ConnectionFactoryLocator connectionFactoryLocator)
void
setConnectSupport(org.springframework.social.connect.web.ConnectSupport connectSupport)
void
setProfileService(org.craftercms.profile.api.services.ProfileService profileService)
void
setTextEncryptor(org.craftercms.commons.crypto.TextEncryptor textEncryptor)
String
start(String tenant, String providerId, javax.servlet.http.HttpServletRequest request)
Starts the OAuth login process.String
start(String tenant, String providerId, javax.servlet.http.HttpServletRequest request, org.springframework.util.MultiValueMap<String,String> additionalUrlParams)
Starts the OAuth login process.String
start(String tenant, String providerId, javax.servlet.http.HttpServletRequest request, org.springframework.util.MultiValueMap<String,String> additionalUrlParams, org.springframework.social.connect.web.ConnectSupport connectSupport)
Starts the OAuth login process.protected org.craftercms.profile.api.Profile
updateProfileConnectionData(String tenant, org.springframework.social.connect.Connection<?> connection, org.craftercms.profile.api.Profile profile)
-
-
-
Field Detail
-
PARAM_OAUTH_TOKEN
public static final String PARAM_OAUTH_TOKEN
- See Also:
- Constant Field Values
-
PARAM_CODE
public static final String PARAM_CODE
- See Also:
- Constant Field Values
-
PARAM_ERROR
public static final String PARAM_ERROR
- See Also:
- Constant Field Values
-
PARAM_ERROR_DESCRIPTION
public static final String PARAM_ERROR_DESCRIPTION
- See Also:
- Constant Field Values
-
PARAM_ERROR_URI
public static final String PARAM_ERROR_URI
- See Also:
- Constant Field Values
-
connectSupport
protected org.springframework.social.connect.web.ConnectSupport connectSupport
-
connectionFactoryLocator
protected org.springframework.social.connect.ConnectionFactoryLocator connectionFactoryLocator
-
profileService
protected org.craftercms.profile.api.services.ProfileService profileService
-
authenticationManager
protected AuthenticationManager authenticationManager
-
textEncryptor
protected org.craftercms.commons.crypto.TextEncryptor textEncryptor
-
-
Method Detail
-
setConnectSupport
public void setConnectSupport(org.springframework.social.connect.web.ConnectSupport connectSupport)
-
setConnectionFactoryLocator
public void setConnectionFactoryLocator(org.springframework.social.connect.ConnectionFactoryLocator connectionFactoryLocator)
-
setProfileService
public void setProfileService(org.craftercms.profile.api.services.ProfileService profileService)
-
setAuthenticationManager
public void setAuthenticationManager(AuthenticationManager authenticationManager)
-
setTextEncryptor
public void setTextEncryptor(org.craftercms.commons.crypto.TextEncryptor textEncryptor)
-
start
public String start(String tenant, String providerId, javax.servlet.http.HttpServletRequest request) throws AuthenticationException
Description copied from interface:ProviderLoginSupport
Starts the OAuth login process. Returns a URL that the app should redirect to.- Specified by:
start
in interfaceProviderLoginSupport
- Parameters:
tenant
- the current tenant the authenticated user belongs tooproviderId
- the social service provider ID: facebook, twitter, linkedinrequest
- the current request- Returns:
- the provider specific URL the current app should redirect too.
- Throws:
AuthenticationException
-
start
public String start(String tenant, String providerId, javax.servlet.http.HttpServletRequest request, org.springframework.util.MultiValueMap<String,String> additionalUrlParams) throws AuthenticationException
Description copied from interface:ProviderLoginSupport
Starts the OAuth login process. Returns a URL that the app should redirect to.- Specified by:
start
in interfaceProviderLoginSupport
- Parameters:
tenant
- the current tenant the authenticated user belongs tooproviderId
- the social service provider ID: facebook, twitter, linkedinrequest
- the current requestadditionalUrlParams
- additional parameters that should be added to the redirect URL- Returns:
- the provider specific URL the current app should redirect too.
- Throws:
AuthenticationException
-
start
public String start(String tenant, String providerId, javax.servlet.http.HttpServletRequest request, org.springframework.util.MultiValueMap<String,String> additionalUrlParams, org.springframework.social.connect.web.ConnectSupport connectSupport) throws AuthenticationException
Description copied from interface:ProviderLoginSupport
Starts the OAuth login process. Returns a URL that the app should redirect to.- Specified by:
start
in interfaceProviderLoginSupport
- Parameters:
tenant
- the current tenant the authenticated user belongs tooproviderId
- the social service provider ID: facebook, twitter, linkedinrequest
- the current requestadditionalUrlParams
- additional parameters that should be added to the redirect URLconnectSupport
- helper class instance for establishing the connections with the providers- Returns:
- the provider specific URL the current app should redirect too.
- Throws:
AuthenticationException
-
complete
public Authentication complete(String tenant, String providerId, javax.servlet.http.HttpServletRequest request) throws AuthenticationException
Description copied from interface:ProviderLoginSupport
Completes the OAuth authentication, returning the resultingAuthentication
object, or null if it couldn't be completed.- Specified by:
complete
in interfaceProviderLoginSupport
- Parameters:
tenant
- the current tenant the authenticated user belongs tooproviderId
- the social service provider ID: facebook, twitter, linkedinrequest
- the current request- Returns:
- the authentication
- Throws:
AuthenticationException
-
complete
public Authentication complete(String tenant, String providerId, javax.servlet.http.HttpServletRequest request, Set<String> newUserRoles, Map<String,Object> newUserAttributes) throws AuthenticationException
Description copied from interface:ProviderLoginSupport
Completes the OAuth authentication, returning the resultingAuthentication
object, or null if it couldn't be completed.- Specified by:
complete
in interfaceProviderLoginSupport
- Parameters:
tenant
- the current tenant the authenticated user belongs tooproviderId
- the social service provider ID: facebook, twitter, linkedinrequest
- the current requestnewUserRoles
- roles to add to a new usernewUserAttributes
- attributes to add to a new user- Returns:
- the authentication
- Throws:
AuthenticationException
-
complete
public Authentication complete(String tenant, String providerId, javax.servlet.http.HttpServletRequest request, Set<String> newUserRoles, Map<String,Object> newUserAttributes, org.springframework.social.connect.web.ConnectSupport connectSupport) throws AuthenticationException
Description copied from interface:ProviderLoginSupport
Completes the OAuth authentication, returning the resultingAuthentication
object, or null if it couldn't be completed.- Specified by:
complete
in interfaceProviderLoginSupport
- Parameters:
tenant
- the current tenant the authenticated user belongs tooproviderId
- the social service provider ID: facebook, twitter, linkedinrequest
- the current requestnewUserRoles
- roles to add to a new usernewUserAttributes
- attributes to add to a new userconnectSupport
- helper class instance for establishing the connections with the providers- Returns:
- the authentication
- Throws:
AuthenticationException
-
completeConnection
protected org.springframework.social.connect.Connection<?> completeConnection(org.springframework.social.connect.web.ConnectSupport connectSupport, String providerId, javax.servlet.http.HttpServletRequest request) throws OAuth2Exception
- Throws:
OAuth2Exception
-
getConnectionFactory
protected org.springframework.social.connect.ConnectionFactory<?> getConnectionFactory(String providerId)
-
getProfile
protected org.craftercms.profile.api.Profile getProfile(String tenant, org.craftercms.profile.api.Profile userData)
-
createProfile
protected org.craftercms.profile.api.Profile createProfile(String tenant, org.springframework.social.connect.Connection<?> connection, org.craftercms.profile.api.Profile userData)
-
updateProfileConnectionData
protected org.craftercms.profile.api.Profile updateProfileConnectionData(String tenant, org.springframework.social.connect.Connection<?> connection, org.craftercms.profile.api.Profile profile)
-
-