Class AbstractAuthenticationStrategyDelegate<T extends org.springframework.security.core.Authentication>

    • Method Detail

      • getClientId

        protected abstract String getClientId​(T authentication)
        Get the Broadleaf Client Id from the authentication token
        Parameters:
        authentication -
        Returns:
      • getEmail

        protected abstract String getEmail​(T authentication)
        Get the user's email address from the authentication token.
        Parameters:
        authentication -
        Returns:
      • getName

        protected abstract String getName​(T authentication)
        Get the user's name from the authentication token
        Parameters:
        authentication -
        Returns:
      • buildUsername

        protected abstract String buildUsername​(T authentication)
        Build a username from the authentication token.
        Parameters:
        authentication -
        Returns:
      • getOAuth2UserDetails

        public OAuth2UserDetails getOAuth2UserDetails​(@NonNull
                                                      @NonNull org.springframework.security.core.Authentication authentication)
        Get the clientId and username from the token to load from the database. Register new users if necessary and allowed.
        Specified by:
        getOAuth2UserDetails in interface AuthenticationStrategyDelegate
        Parameters:
        authentication - The authentication token
        Returns:
        OAuth2UserDetails for the given authentication token
      • registerNewUser

        protected void registerNewUser​(@NonNull
                                       T authentication,
                                       String clientId,
                                       String username)
        Register a new user if allowed.
        Parameters:
        authentication - The authentication token for the user
        clientId - The ID of the client to authenticate with
        username - The username of the user
      • isAutoRegister

        protected boolean isAutoRegister​(String clientId)
        Check the client service and properties to determine if auto registration for new users is enabled
        Parameters:
        clientId - ID of the AuthorizedClient a user is trying to authenticate with
        Returns:
        Whether the client allows auto-registering new users when they sign in.
      • getAuthorizedClient

        protected AuthorizedClient getAuthorizedClient​(String clientId)
        Fetches an AuthorizedClient for the given clientId.
        Parameters:
        clientId - The ID of the client to fetch
        Returns:
        The client matching clientId
        Throws:
        com.broadleafcommerce.data.tracking.core.exception.EntityMissingException - if no client is found
      • getUsername

        protected String getUsername​(@NonNull
                                     T authentication,
                                     boolean emailAsUsername)
        Get the username from the authentication token. This could be a username or email address, depending on the emailAsUsername parameter
        Parameters:
        authentication - The user's Authentication.
        emailAsUsername - Whether the user's email is also the username
        Returns:
        The user's username
      • buildUserRegistration

        protected UserRegistration buildUserRegistration​(@NonNull
                                                         T authentication,
                                                         String clientId,
                                                         String username)
        Build a UserRegistration from the authentication token.
        Parameters:
        authentication - The user's Authentication.
        clientId - The ID of the client authenticated with
        username - The username of the user
        Returns:
        The UserRegistration for the user.
      • generateRandomPassword

        protected String generateRandomPassword()
        Create a random password for the User.
        Returns:
        a secure, random String
      • getUserType

        protected String getUserType​(String clientId)
        Determines the appropriate type of user for the AuthorizedClient matching the given clientId.
        Parameters:
        clientId - The ID of the client to check the user's type against
        Returns:
        The type of the user given the type of the AuthorizedClient matching clientId.
      • getTypeFactory

        protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()