@Order(value=0) public abstract class AbstractAuthenticationStrategyDelegate<T extends org.springframework.security.core.Authentication> extends Object implements AuthenticationStrategyDelegate
AuthenticationStrategyDelegate for converting Authentication to
OAuth2UserDetails. This class handles registering new users if necessary. Child classes
should implement the abstract methods to map required fields from their specific Authentication
token.| Constructor and Description |
|---|
AbstractAuthenticationStrategyDelegate(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 abstract String |
buildUsername(T authentication)
Build a username from the authentication token.
|
protected UserRegistration |
buildUserRegistration(T authentication,
String clientId,
String username)
Build a
UserRegistration from the authentication token. |
protected String |
generateRandomPassword()
Create a random password for the User.
|
protected AuthorizedClient |
getAuthorizedClient(String clientId)
Fetches an
AuthorizedClient for the given clientId. |
protected abstract String |
getClientId(T authentication)
Get the Broadleaf Client Id from the authentication token
|
protected ClientIdentityProviderProperties |
getClientProperties() |
protected AuthorizedClientService<AuthorizedClient> |
getClientService() |
protected abstract String |
getEmail(T authentication)
Get the user's email address from the authentication token.
|
protected abstract String |
getName(T authentication)
Get the user's name from the authentication token
|
OAuth2UserDetails |
getOAuth2UserDetails(@NonNull org.springframework.security.core.Authentication authentication)
Get the clientId and username from the token to load from the database.
|
protected OAuth2UserDetailsService |
getOAuth2UserDetailsService() |
protected PasscodeService<PasswordToken,User> |
getPasscodeService() |
protected AuthRegistrationProperties |
getRegistrationProperties() |
protected UserRegistrationService<User> |
getRegistrationService() |
protected com.broadleafcommerce.common.extension.TypeFactory |
getTypeFactory() |
protected String |
getUsername(T authentication,
boolean emailAsUsername)
Get the username from the authentication token.
|
protected String |
getUserType(String clientId)
Determines the appropriate type of user for the
AuthorizedClient matching the given
clientId. |
protected boolean |
isAutoRegister(String clientId)
Check the client service and properties to determine if auto registration for new users is
enabled
|
protected void |
registerNewUser(T authentication,
String clientId,
String username)
Register a new user if allowed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanHandlepublic AbstractAuthenticationStrategyDelegate(OAuth2UserDetailsService oAuth2UserDetailsService, UserRegistrationService<User> registrationService, AuthRegistrationProperties registrationProperties, AuthorizedClientService<AuthorizedClient> clientService, ClientIdentityProviderProperties clientProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PasscodeService<PasswordToken,User> passcodeService)
protected abstract String getClientId(T authentication)
authentication - protected abstract String getEmail(T authentication)
authentication - protected abstract String getName(T authentication)
authentication - protected abstract String buildUsername(T authentication)
authentication - public OAuth2UserDetails getOAuth2UserDetails(@NonNull @NonNull org.springframework.security.core.Authentication authentication)
getOAuth2UserDetails in interface AuthenticationStrategyDelegateauthentication - The authentication tokenOAuth2UserDetails for the given authentication tokenprotected void registerNewUser(@NonNull
T authentication,
String clientId,
String username)
authentication - The authentication token for the userclientId - The ID of the client to authenticate withusername - The username of the userprotected boolean isAutoRegister(String clientId)
clientId - ID of the AuthorizedClient a user is trying to authenticate withprotected AuthorizedClient getAuthorizedClient(String clientId)
AuthorizedClient for the given clientId.clientId - The ID of the client to fetchclientIdcom.broadleafcommerce.data.tracking.core.exception.EntityMissingException - if no client is foundprotected String getUsername(@NonNull T authentication, boolean emailAsUsername)
authentication - The user's Authentication.emailAsUsername - Whether the user's email is also the usernameprotected UserRegistration buildUserRegistration(@NonNull T authentication, String clientId, String username)
UserRegistration from the authentication token.authentication - The user's Authentication.clientId - The ID of the client authenticated withusername - The username of the userUserRegistration for the user.protected String generateRandomPassword()
protected String getUserType(String clientId)
AuthorizedClient matching the given
clientId.clientId - The ID of the client to check the user's type againstAuthorizedClient matching
clientId.protected OAuth2UserDetailsService getOAuth2UserDetailsService()
protected UserRegistrationService<User> getRegistrationService()
protected AuthRegistrationProperties getRegistrationProperties()
protected AuthorizedClientService<AuthorizedClient> getClientService()
protected ClientIdentityProviderProperties getClientProperties()
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
protected PasscodeService<PasswordToken,User> getPasscodeService()
Copyright © 2021. All rights reserved.