Class AbstractUserTokenEnhancer

    • Constructor Detail

      • AbstractUserTokenEnhancer

        public AbstractUserTokenEnhancer()
    • Method Detail

      • getUser

        public User getUser​(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
        Retrieve the current authenticated User. This method assumes that the user is logged in and exists. In other words, OAuth2Authentication.isClientOnly() should return false if this method is to be called.

        Note that the user is cached at the request scope. Any calls after the first call to this method during the same request will return the same user, regardless of the argument passed.

        Parameters:
        authentication - The OAuth2Authentication object passed to TokenEnhancer.enhance(OAuth2AccessToken, OAuth2Authentication)
        Returns:
        The currently authenticated user.
        Throws:
        com.broadleafcommerce.data.tracking.core.exception.EntityMissingException - if User is not found.
        See Also:
        TokenEnhancerUtil.readUserId(OAuth2Authentication)
      • isAnonymousCsrImpersonation

        protected boolean isAnonymousCsrImpersonation​(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
        Check whether or not the current authentication is a CSR impersonation of an anonymous user.
        Parameters:
        authentication - The OAuth2Authentication object passed to TokenEnhancer.enhance(OAuth2AccessToken, OAuth2Authentication)
        Returns:
        Whether the current authentication is a CSR impersonation of an anonymous user
      • shouldEnhance

        protected boolean shouldEnhance​(org.springframework.security.oauth2.common.OAuth2AccessToken accessToken,
                                        org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
        Whether or not the token should be enhanced.
        Parameters:
        accessToken - the current access token with its expiration and refresh token
        authentication - The OAuth2Authentication object passed to TokenEnhancer.enhance(OAuth2AccessToken, OAuth2Authentication)
        Returns:
        Whether or not the token should be enhanced.
      • setUserService

        @Autowired
        public void setUserService​(@NonNull
                                   UserService<User> userService)
      • setUserContext

        @Autowired
        public void setUserContext​(UserContext userContext)