public abstract class AbstractUserTokenEnhancer extends Object implements org.springframework.security.oauth2.provider.token.TokenEnhancer
TokenEnhancer
that has a request scoped UserContext that contains the
current user to avoid repeated database reads. TokenEnhancer implementations that require access
to the User
should extend this class and retrieve the user via the
getUser(OAuth2Authentication)
method.Constructor and Description |
---|
AbstractUserTokenEnhancer() |
Modifier and Type | Method and Description |
---|---|
User |
getUser(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
Retrieve the current authenticated
User . |
protected UserService<User> |
getUserService() |
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.
|
void |
setUserContext(UserContext userContext) |
void |
setUserService(UserService<User> userService) |
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.
|
public User getUser(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
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.
authentication
- The OAuth2Authentication
object passed to
TokenEnhancer.enhance(OAuth2AccessToken, OAuth2Authentication)
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if
User
is not found.TokenEnhancerUtil.readUserId(OAuth2Authentication)
protected boolean isAnonymousCsrImpersonation(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
authentication
- The OAuth2Authentication
object passed to
TokenEnhancer.enhance(OAuth2AccessToken, OAuth2Authentication)
protected boolean shouldEnhance(org.springframework.security.oauth2.common.OAuth2AccessToken accessToken, org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
accessToken
- the current access token with its expiration and refresh tokenauthentication
- The OAuth2Authentication
object passed to
TokenEnhancer.enhance(OAuth2AccessToken, OAuth2Authentication)
@Autowired public void setUserService(@NonNull UserService<User> userService)
@Autowired public void setUserContext(UserContext userContext)
protected UserService<User> getUserService()
Copyright © 2021. All rights reserved.