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>
AbstractAuthenticationStrategyDelegate
for convertingOAuth2AuthenticationToken
toOAuth2UserDetails
. 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
Constructors Constructor Description AbstractOAuthClientAuthenticationStrategyDelegate(OAuth2UserDetailsService oAuth2UserDetailsService, UserRegistrationService<User> registrationService, AuthRegistrationProperties registrationProperties, AuthorizedClientService<AuthorizedClient> clientService, ClientIdentityProviderProperties clientProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PasscodeService<PasswordToken,User> passcodeService)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
buildUsername(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Build a username from the authentication token.boolean
canHandle(@NonNull org.springframework.security.core.Authentication authentication)
Check if the given Authentication is anOAuth2AuthenticationToken
and the registration id matchesgetOAuthRegistrationType()
protected String
getClientId(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Get the Broadleaf Client Id from the authentication tokenprotected String
getEmail(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Get the user's email address from the authentication token.protected String
getName(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Get the user's name from the authentication tokenprotected abstract String
getOAuthRegistrationType()
Gets the registration type / client registration id that this delegate handles-
Methods inherited from class com.broadleafcommerce.auth.user.web.authentication.session.AbstractAuthenticationStrategyDelegate
buildUserRegistration, generateRandomPassword, getAuthorizedClient, getClientProperties, getClientService, getOAuth2UserDetails, getOAuth2UserDetailsService, getPasscodeService, getRegistrationProperties, getRegistrationService, getTypeFactory, getUsername, getUserType, isAutoRegister, registerNewUser
-
-
-
-
Constructor Detail
-
AbstractOAuthClientAuthenticationStrategyDelegate
public AbstractOAuthClientAuthenticationStrategyDelegate(OAuth2UserDetailsService oAuth2UserDetailsService, UserRegistrationService<User> registrationService, AuthRegistrationProperties registrationProperties, AuthorizedClientService<AuthorizedClient> clientService, ClientIdentityProviderProperties clientProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PasscodeService<PasswordToken,User> passcodeService)
-
-
Method Detail
-
getOAuthRegistrationType
@Nullable protected abstract String 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)
Check if the given Authentication is anOAuth2AuthenticationToken
and the registration id matchesgetOAuthRegistrationType()
- Parameters:
authentication
- The authentication token- Returns:
-
getClientId
protected String getClientId(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Description copied from class:AbstractAuthenticationStrategyDelegate
Get the Broadleaf Client Id from the authentication token- Specified by:
getClientId
in classAbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
- Returns:
-
getEmail
protected String getEmail(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Description copied from class:AbstractAuthenticationStrategyDelegate
Get the user's email address from the authentication token.- Specified by:
getEmail
in classAbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
- Returns:
-
getName
protected String getName(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Description copied from class:AbstractAuthenticationStrategyDelegate
Get the user's name from the authentication token- Specified by:
getName
in classAbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
- Returns:
-
buildUsername
protected String buildUsername(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Description copied from class:AbstractAuthenticationStrategyDelegate
Build a username from the authentication token.- Specified by:
buildUsername
in classAbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
- Returns:
-
-