Class GoogleOAuthClientAuthenticationStrategyDelegate

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
com.broadleafcommerce.auth.client.web.authentication.session.GoogleOAuthClientAuthenticationStrategyDelegate
All Implemented Interfaces:
AuthenticationStrategyDelegate

public class GoogleOAuthClientAuthenticationStrategyDelegate extends AbstractOAuthClientAuthenticationStrategyDelegate
Maps OAuth2AuthenticationToken from Google to OAuth2UserDetails. This implementation overrides the default behavior of #buildUserRegistration to check that email addresses have been verified before using them for registration.
Author:
Cade Rea (cade-rea)
  • Field Details

    • EMAIL_ATTR_KEY

      public static final String EMAIL_ATTR_KEY
      Attributes key to retrieve user's email address.
      See Also:
    • FULL_NAME_ATTR_KEY

      public static final String FULL_NAME_ATTR_KEY
      Attributes key to retrieve user's full name as a single string
      See Also:
    • EMAIL_VERIFIED_ATTR_KEY

      public static final String EMAIL_VERIFIED_ATTR_KEY
      Attribute key to retrieve the email verified claim. This is a boolean
      See Also:
    • FIRST_NAME_ATTR_KEY

      public static final String FIRST_NAME_ATTR_KEY
      Attribute key to retrieve the user's first name
      See Also:
    • LAST_NAME_ATTR_KEY

      public static final String LAST_NAME_ATTR_KEY
      Attribute to retrieve the user's surname
      See Also:
    • REQUIRED_SCOPES

      public static final String REQUIRED_SCOPES
      For debugging purposes. The scopes required to be able to retrieve the user's email address and name.
      See Also:
  • Constructor Details

  • Method Details

    • buildUserRegistration

      public UserRegistration buildUserRegistration(org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication, String clientId, String username)
      Description copied from class: AbstractAuthenticationStrategyDelegate
      Build a UserRegistration from the authentication token.
      Overrides:
      buildUserRegistration in class AbstractAuthenticationStrategyDelegate<org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken>
      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.
    • 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.
      Overrides:
      buildUsername in class AbstractOAuthClientAuthenticationStrategyDelegate
      Parameters:
      authentication - The User's OAuth token issued by the third-party IDP.
      Returns:
      A username derived from the authentication token.
    • getName

      @Nullable 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.
      Overrides:
      getName in class AbstractOAuthClientAuthenticationStrategyDelegate
      Parameters:
      authentication - The User's OAuth token issued by the third-party IDP.
      Returns:
      The user's name from the authentication token.
    • 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.
      Overrides:
      getEmail in class AbstractOAuthClientAuthenticationStrategyDelegate
      Parameters:
      authentication - The User's OAuth token issued by the third-party IDP.
      Returns:
      The user's email address from the authentication token.
    • isEmailVerified

      protected boolean isEmailVerified(org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken authentication)
    • getOAuthRegistrationType

      protected String getOAuthRegistrationType()
      Gets the registration type / client registration id that this delegate handles
      Specified by:
      getOAuthRegistrationType in class AbstractOAuthClientAuthenticationStrategyDelegate
      Returns:
      supported registration type
    • getRequiredScopes

      protected String getRequiredScopes()
    • isAdminClientHandler

      public boolean isAdminClientHandler()
      Returns:
      Does this authentication strategy delegate handle admin users? Default implementation returns true.
    • isCustomerClientHandler

      public boolean isCustomerClientHandler()
      Returns:
      Does this authentication strategy handle customer users? Default implementation returns true