Class AbstractOAuthClientAuthenticationStrategyDelegate
java.lang.Object
com.broadleafcommerce.auth.user.web.authentication.session.AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
com.broadleafcommerce.auth.client.web.authentication.session.AbstractOAuthClientAuthenticationStrategyDelegate
- All Implemented Interfaces:
AuthenticationStrategyDelegate
- Direct Known Subclasses:
DefaultOIDCAuthenticationStrategyDelegate,GithubOAuthClientAuthenticationStrategyDelegate,GoogleOAuthClientAuthenticationStrategyDelegate
public abstract class AbstractOAuthClientAuthenticationStrategyDelegate
extends AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
Abstract
AuthenticationStrategyDelegate for converting OAuth2AuthenticationToken
to OAuth2UserDetails. This implements the #canHandle method to check that the
ClientRegistration id from the token matches #getOAuthRegistrationType. This implementation
offers reasonable defaults while allowing child classes to modify as needed.
Child classes can simply implement #getOAuthRegistrationType to return the OAuth Client
Registration id. Override methods to introduce specific behavior.- Author:
- Cade Rea (cade-rea)
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractOAuthClientAuthenticationStrategyDelegate(OAuth2UserDetailsService oAuth2UserDetailsService, UserRegistrationService<User> registrationService, AuthRegistrationProperties registrationProperties, AuthorizedClientService<AuthorizedClient> clientService, ClientIdentityProviderProperties clientProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PasswordGenerator passwordGenerator) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildUsername(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Build a username from the authentication token.booleancanHandle(@NonNull org.springframework.security.core.Authentication authentication, AuthorizedClient authorizedClient) Determine if this delegate can map the given Authentication token to an OAuth2UserDetailsprotected StringgetClientId(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Get the Broadleaf Client ID from the authentication token.protected StringgetEmail(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Get the user's email address from the authentication token.protected StringgetName(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Get the user's name from the authentication token.protected abstract StringGets the registration type / client registration id that this delegate handlesMethods inherited from class com.broadleafcommerce.auth.user.web.authentication.session.AbstractAuthenticationStrategyDelegate
buildUserRegistration, createAdminUser, generateRandomPassword, getAuthorizedClient, getClientProperties, getClientService, getExternalAdminUserHandler, getOAuth2UserDetails, getOAuth2UserDetailsService, getPasswordGenerator, getRegistrationProperties, getRegistrationService, getTypeFactory, getUsername, getUserType, handleAdminLogin, isAutoRegister, isAutoRegister, isThirdPartyAuth, registerNewUser, registerNewUser, setExternalAdminUserHandlerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.auth.user.web.authentication.session.AuthenticationStrategyDelegate
canHandle, getOAuth2UserDetails, isAdminClientHandler, isCustomerClientHandler
-
Constructor Details
-
AbstractOAuthClientAuthenticationStrategyDelegate
public AbstractOAuthClientAuthenticationStrategyDelegate(OAuth2UserDetailsService oAuth2UserDetailsService, UserRegistrationService<User> registrationService, AuthRegistrationProperties registrationProperties, AuthorizedClientService<AuthorizedClient> clientService, ClientIdentityProviderProperties clientProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PasswordGenerator passwordGenerator)
-
-
Method Details
-
getOAuthRegistrationType
Gets the registration type / client registration id that this delegate handles- Returns:
- supported registration type
-
canHandle
public boolean canHandle(@NonNull @NonNull org.springframework.security.core.Authentication authentication, @Nullable AuthorizedClient authorizedClient) Description copied from interface:AuthenticationStrategyDelegateDetermine if this delegate can map the given Authentication token to an OAuth2UserDetails- Parameters:
authentication- The authentication tokenauthorizedClient- The authorized client- Returns:
- Whether this delegate can map the token to an OAuth2UserDetails
-
getClientId
protected String getClientId(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Description copied from class:AbstractAuthenticationStrategyDelegateGet the Broadleaf Client ID from the authentication token.- Specified by:
getClientIdin classAbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>- Parameters:
authentication- The User's OAuth token issued by the third-party IDP.- Returns:
- The Broadleaf Client ID from the authentication token.
-
getEmail
protected String getEmail(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Description copied from class:AbstractAuthenticationStrategyDelegateGet the user's email address from the authentication token.- Specified by:
getEmailin classAbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>- Parameters:
authentication- The User's OAuth token issued by the third-party IDP.- Returns:
- The user's email address from the authentication token.
-
getName
protected String getName(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Description copied from class:AbstractAuthenticationStrategyDelegateGet the user's name from the authentication token.- Specified by:
getNamein classAbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>- Parameters:
authentication- The User's OAuth token issued by the third-party IDP.- Returns:
- The user's name from the authentication token.
-
buildUsername
protected String buildUsername(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication) Description copied from class:AbstractAuthenticationStrategyDelegateBuild a username from the authentication token.- Specified by:
buildUsernamein classAbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>- Parameters:
authentication- The User's OAuth token issued by the third-party IDP.- Returns:
- A username derived from the authentication token.
-