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
Provides
ClientRegistration
objects to the OAuth2 Client beans.
This class relies on the ContextHelperService
to get the current tenant id from request
attributes. This enables us to allow tenant tracking while preserving the
ClientRegistrationRepository
interface from the OAuth2 Client library.
This class has the ability to incorporate OAuthClientRegistrationWrapper
data built from
application properties. The OAuthClientRegistrationPersistenceService
will always be
checked first. If a registration is not found there then this will check the
ClientRegistrationPropertiesService
. If a registration is found with the
ClientRegistrationPropertiesService
, it will be saved with
OAuthClientRegistrationPersistenceService
.
Despite the name, this is not a repository in the usual sense. Its name is based on the Spring
interface ClientRegistrationRepository
that this class implements. Actual persistence
operations are handled by OAuthClientRegistrationPersistenceService
.- Author:
- Cade Rea (cade-rea)
-
Constructor Summary
ConstructorDescriptionDefaultBroadleafClientRegistrationRepository
(OAuthClientRegistrationPersistenceService<OAuthClientRegistrationWrapper> clientRegistrationService, ContextHelperService contextHelperService, ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper> clientRegistrationPropertiesService) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.security.oauth2.client.registration.ClientRegistration
Converts anOAuthClientRegistrationWrapper
to aClientRegistration
.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 ContextHelperService
protected OAuthClientRegistrationWrapper
loadFromProperties
(String registrationId, String tenantId)
-
Constructor Details
-
DefaultBroadleafClientRegistrationRepository
public DefaultBroadleafClientRegistrationRepository(OAuthClientRegistrationPersistenceService<OAuthClientRegistrationWrapper> clientRegistrationService, ContextHelperService contextHelperService, ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper> clientRegistrationPropertiesService)
-
-
Method Details
-
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
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
-
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
-
getClientRegistrationPropertiesService
protected ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper> getClientRegistrationPropertiesService()
-