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
ProvidesClientRegistrationobjects to the OAuth2 Client beans. This class relies on theContextHelperServiceto get the current tenant id from request attributes. This enables us to allow tenant tracking while preserving theClientRegistrationRepositoryinterface from the OAuth2 Client library. This class has the ability to incorporateOAuthClientRegistrationWrapperdata built from application properties. TheOAuthClientRegistrationPersistenceServicewill 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 interfaceClientRegistrationRepositorythat 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.ClientRegistrationbuildClientRegistration(OAuthClientRegistrationWrapper wrapper)Converts anOAuthClientRegistrationWrapperto aClientRegistration.Map<String,OAuthClientRegistrationWrapper>findAllClientRegistrations()Return a Map of all available 3rd party OAuth providers.org.springframework.security.oauth2.client.registration.ClientRegistrationfindByRegistrationId(String registrationId)Looks up aClientRegistrationby its registration id.protected ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper>getClientRegistrationPropertiesService()protected OAuthClientRegistrationPersistenceService<OAuthClientRegistrationWrapper>getClientRegistrationService()protected ContextHelperServicegetContextHelperService()protected OAuthClientRegistrationWrapperloadFromProperties(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 aClientRegistrationby its registration id. This will first check theOAuthClientRegistrationPersistenceService. If not found there, this will checkClientRegistrationPropertiesService.- Specified by:
findByRegistrationIdin interfaceorg.springframework.security.oauth2.client.registration.ClientRegistrationRepository- Parameters:
registrationId- The registration id, e.g. "google" or "facebook".- Returns:
- The
ClientRegistrationthat 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:
findAllClientRegistrationsin 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 anOAuthClientRegistrationWrapperto 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()
-
-