Class OAuth2SessionAuthenticationProvider

java.lang.Object
com.broadleafcommerce.auth.user.session.OAuth2SessionAuthenticationProvider
All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider

public class OAuth2SessionAuthenticationProvider extends Object implements org.springframework.security.authentication.AuthenticationProvider
An AuthenticationProvider that authenticates a user using a OAuth2SessionAuthenticationToken.
Author:
Nick Crum (ncrum)
See Also:
  • Constructor Details

  • Method Details

    • supports

      public boolean supports(Class<?> authentication)
      Specified by:
      supports in interface org.springframework.security.authentication.AuthenticationProvider
    • authenticate

      public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication)
      Specified by:
      authenticate in interface org.springframework.security.authentication.AuthenticationProvider
    • checkTokenBlacklistIfApplicable

      protected void checkTokenBlacklistIfApplicable(String rawSessionTokenValue, com.nimbusds.jwt.SignedJWT validatedSessionJwt)
      Validate whether the provided session token value is blacklisted, if token blacklisting is enabled.
      Parameters:
      rawSessionTokenValue - the raw session token value
      validatedSessionJwt - the parsed, pre-validated SignedJWT representation of the token
      Throws:
      org.springframework.security.authentication.BadCredentialsException - if the provided session token value is blacklisted
      Since:
      AuthenticationServices 3.0.0, Release Train 3.0.0
    • buildTokenBlacklistDetectionRequest

      protected TokenBlacklistDetectionRequest buildTokenBlacklistDetectionRequest(String tokenId, com.nimbusds.jwt.SignedJWT validatedSessionJwt)
      Parameters:
      tokenId - the token ID
      validatedSessionJwt - the parsed, pre-validated SignedJWT representation of the token
      Returns:
      a valid TokenBlacklistDetectionRequest
    • handleUnexpectedTokenBlacklistOperationError

      protected void handleUnexpectedTokenBlacklistOperationError(TokenBlacklistDetectionRequest request, TokenBlacklistOperationException e)
    • loadUser

      protected OAuth2UserDetails loadUser(com.nimbusds.jwt.SignedJWT jwt, OAuth2SessionToken sessionToken, String clientId) throws ParseException
      Loads the appropriate user for the request. Generally, this will rely on the "sub" claim in the JWT, but if the session is impersonated or anonymous CSR, those users will be loaded instead.
      Parameters:
      jwt - the verified JWT
      sessionToken - the session token
      clientId - the current client ID
      Returns:
      the user details
      Throws:
      ParseException - if there is an issue extracting claims from the JWT
      Since:
      Authentication Service 2.3.0, Release Train 2.3.0
    • createSuccessAuthentication

      protected org.springframework.security.core.Authentication createSuccessAuthentication(OAuth2UserDetails user, OAuth2SessionToken sessionToken)
    • getAuthorities

      protected Collection<org.springframework.security.core.GrantedAuthority> getAuthorities(OAuth2UserDetails user, OAuth2SessionToken sessionToken)
    • validateJWT

      protected void validateJWT(com.nimbusds.jwt.SignedJWT jwt) throws ParseException
      Throws:
      ParseException
    • validateUserDetails

      protected void validateUserDetails(OAuth2UserDetails userDetails, String clientId, OAuth2SessionToken sessionToken)
    • validateCredentialsNonExpired

      protected void validateCredentialsNonExpired(OAuth2UserDetails userDetails, String clientId, OAuth2SessionToken sessionToken)
      Validate that for the provided session token, the associated user's credentials are not considered expired.
      Parameters:
      userDetails - the user details to validate
      clientId - the client ID this session authentication is happening for
      sessionToken - the session token received in the request
    • isSessionTokenFromThirdPartyLogin

      protected boolean isSessionTokenFromThirdPartyLogin(OAuth2SessionToken sessionToken)
    • getUserDetailsService

      protected OAuth2UserDetailsService getUserDetailsService()
    • getUtil

      protected StatelessUtil getUtil()
    • getUserDetailsValidationProperties

      protected UserDetailsValidationProperties getUserDetailsValidationProperties()
    • setUserDetailsValidationProperties

      @Autowired public void setUserDetailsValidationProperties(UserDetailsValidationProperties userDetailsValidationProperties)
    • setTokenBlacklistManager

      @Autowired(required=false) public void setTokenBlacklistManager(TokenBlacklistManager tokenBlacklistManager)
    • getTokenBlacklistManager

      @Nullable protected TokenBlacklistManager getTokenBlacklistManager()
    • setTypeFactory

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • getTypeFactory

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