Class DefaultBroadleafClientRegistrationRepository
- java.lang.Object
-
- com.broadleafcommerce.auth.client.registration.DefaultBroadleafClientRegistrationRepository
-
- All Implemented Interfaces:
BroadleafClientRegistrationRepository
,org.springframework.security.oauth2.client.registration.ClientRegistrationRepository
public class DefaultBroadleafClientRegistrationRepository extends Object implements BroadleafClientRegistrationRepository
ProvidesClientRegistration
objects to the OAuth2 Client beans. This class relies on theContextHelperService
to get the current tenant id from request attributes. This enables us to allow tenant tracking while preserving theClientRegistrationRepository
interface from the OAuth2 Client library. This class has the ability to incorporateOAuthClientRegistrationWrapper
data built from application properties. TheOAuthClientRegistrationPersistenceService
will always be checked first. If a registration is not found there then this will check theClientRegistrationPropertiesService
. If a registration is found with theClientRegistrationPropertiesService
, it will be saved withOAuthClientRegistrationPersistenceService
. Despite the name, this is not a repository in the usual sense. Its name is based on the Spring interfaceClientRegistrationRepository
that this class implements. Actual persistence operations are handled byOAuthClientRegistrationPersistenceService
.- Author:
- Cade Rea (cade-rea)
-
-
Constructor Summary
Constructors Constructor Description DefaultBroadleafClientRegistrationRepository(OAuthClientRegistrationPersistenceService<OAuthClientRegistrationWrapper> clientRegistrationService, ContextHelperService contextHelperService, ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper> clientRegistrationPropertiesService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.springframework.security.oauth2.client.registration.ClientRegistration
buildClientRegistration(OAuthClientRegistrationWrapper wrapper)
Converts anOAuthClientRegistrationWrapper
to aClientRegistration
.Map<String,OAuthClientRegistrationWrapper>
findAllClientRegistrations()
Return a Map of all available 3rd party OAuth providers.org.springframework.security.oauth2.client.registration.ClientRegistration
findByRegistrationId(String registrationId)
Looks up aClientRegistration
by its registration id.protected ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper>
getClientRegistrationPropertiesService()
protected OAuthClientRegistrationPersistenceService<OAuthClientRegistrationWrapper>
getClientRegistrationService()
protected ContextHelperService
getContextHelperService()
protected OAuthClientRegistrationWrapper
loadFromProperties(String registrationId, String tenantId)
-
-
-
Constructor Detail
-
DefaultBroadleafClientRegistrationRepository
public DefaultBroadleafClientRegistrationRepository(OAuthClientRegistrationPersistenceService<OAuthClientRegistrationWrapper> clientRegistrationService, ContextHelperService contextHelperService, ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper> clientRegistrationPropertiesService)
-
-
Method Detail
-
findByRegistrationId
@Nullable public org.springframework.security.oauth2.client.registration.ClientRegistration findByRegistrationId(String registrationId)
Looks up aClientRegistration
by its registration id. This will first check theOAuthClientRegistrationPersistenceService
. If not found there, this will checkClientRegistrationPropertiesService
.- Specified by:
findByRegistrationId
in interfaceorg.springframework.security.oauth2.client.registration.ClientRegistrationRepository
- Parameters:
registrationId
- The registration id, e.g. "google" or "facebook".- Returns:
- The
ClientRegistration
that corresponds to the given registration id.
-
findAllClientRegistrations
public Map<String,OAuthClientRegistrationWrapper> findAllClientRegistrations()
Return a Map of all available 3rd party OAuth providers. The map key is the registration id from theOAuthClientRegistrationWrapper
.- Specified by:
findAllClientRegistrations
in interfaceBroadleafClientRegistrationRepository
- Returns:
- A tenant-discriminated Map of
OAuthClientRegistrationWrapper
-
loadFromProperties
protected OAuthClientRegistrationWrapper loadFromProperties(String registrationId, String tenantId)
-
buildClientRegistration
@Nullable protected org.springframework.security.oauth2.client.registration.ClientRegistration buildClientRegistration(OAuthClientRegistrationWrapper wrapper)
Converts anOAuthClientRegistrationWrapper
to aClientRegistration
. Returns null if there are any exceptions in the conversion process.- Parameters:
wrapper
-- Returns:
-
getClientRegistrationService
protected OAuthClientRegistrationPersistenceService<OAuthClientRegistrationWrapper> getClientRegistrationService()
-
getContextHelperService
protected ContextHelperService getContextHelperService()
-
getClientRegistrationPropertiesService
protected ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper> getClientRegistrationPropertiesService()
-
-