public abstract class AbstractOAuthClientAuthenticationStrategyDelegate extends AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
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.Constructor and Description |
---|
AbstractOAuthClientAuthenticationStrategyDelegate(OAuth2UserDetailsService oAuth2UserDetailsService,
UserRegistrationService<User> registrationService,
AuthRegistrationProperties registrationProperties,
AuthorizedClientService<AuthorizedClient> clientService,
ClientIdentityProviderProperties clientProperties,
com.broadleafcommerce.common.extension.TypeFactory typeFactory,
PasscodeService<PasswordToken,User> passcodeService) |
Modifier and Type | Method and 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 an
OAuth2AuthenticationToken and the
registration id matches getOAuthRegistrationType() |
protected String |
getClientId(@NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
Get the Broadleaf Client Id from the authentication token
|
protected 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 token
|
protected abstract String |
getOAuthRegistrationType()
Gets the registration type / client registration id that this delegate handles
|
buildUserRegistration, generateRandomPassword, getAuthorizedClient, getClientProperties, getClientService, getOAuth2UserDetails, getOAuth2UserDetailsService, getPasscodeService, getRegistrationProperties, getRegistrationService, getTypeFactory, getUsername, getUserType, isAutoRegister, registerNewUser
public AbstractOAuthClientAuthenticationStrategyDelegate(OAuth2UserDetailsService oAuth2UserDetailsService, UserRegistrationService<User> registrationService, AuthRegistrationProperties registrationProperties, AuthorizedClientService<AuthorizedClient> clientService, ClientIdentityProviderProperties clientProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PasscodeService<PasswordToken,User> passcodeService)
@Nullable protected abstract String getOAuthRegistrationType()
public boolean canHandle(@NonNull @NonNull org.springframework.security.core.Authentication authentication)
OAuth2AuthenticationToken
and the
registration id matches getOAuthRegistrationType()
authentication
- The authentication tokenprotected String getClientId(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
AbstractAuthenticationStrategyDelegate
getClientId
in class AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
protected String getEmail(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
AbstractAuthenticationStrategyDelegate
getEmail
in class AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
protected String getName(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
AbstractAuthenticationStrategyDelegate
getName
in class AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
protected String buildUsername(@NonNull @NonNull org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
AbstractAuthenticationStrategyDelegate
buildUsername
in class AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
Copyright © 2021. All rights reserved.