Class TokenEnhancerUtility
java.lang.Object
com.broadleafcommerce.auth.user.session.token.enhancer.TokenEnhancerUtility
Utility to consolidate common operations performed in
JwtAccessTokenEnhancer.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetSessionToken(org.springframework.security.core.Authentication userPrincipal) Get thesession tokenfrom theauthentication token.booleanCheck whether the current authentication is a CSR impersonation of an anonymous user.booleanisClientOnly(JwtTokenEnhancerContext context) Determine if the givenJwtTokenEnhancerContextrepresents a "client-only" authorization.booleanisCsrImpersonatingSelf(org.springframework.security.core.Authentication userAuthentication) In some flows, CSR will need access to log into the storefront without impersonating a specific customer or be anonymous.booleanisImpersonationSession(org.springframework.security.core.Authentication userPrincipal) Checks the session to see if the user is a CSR in an impersonation flow.
-
Constructor Details
-
TokenEnhancerUtility
public TokenEnhancerUtility()
-
-
Method Details
-
isClientOnly
Determine if the givenJwtTokenEnhancerContextrepresents a "client-only" authorization. A client-only authorization does not have a User. For example, the Client Credentials grant type would be client-only.- Parameters:
context- TheJwtTokenEnhancerContextto evaluate.- Returns:
- True if the given
JwtTokenEnhancerContextis a client-only authorization, false otherwise.
-
isAnonymousCsrImpersonation
Check whether the current authentication is a CSR impersonation of an anonymous user.- Parameters:
context- TheJwtTokenEnhancerContextobject passed toJwtAccessTokenEnhancer.enhance(JwtTokenEnhancerContext).- Returns:
- True if the current authentication is a CSR impersonation of an anonymous user.
-
getSessionToken
public Optional<OAuth2SessionToken> getSessionToken(org.springframework.security.core.Authentication userPrincipal) Get thesession tokenfrom theauthentication token.- Parameters:
userPrincipal- TheOAuth2SessionAuthenticationTokenof the User.- Returns:
- An Optional with the
OAuth2SessionTokenif available, or empty.
-
isCsrImpersonatingSelf
public boolean isCsrImpersonatingSelf(org.springframework.security.core.Authentication userAuthentication) In some flows, CSR will need access to log into the storefront without impersonating a specific customer or be anonymous. Instead, they need to be able to act as themselves, a service rep, to manage some data like Quotes. This method is used to detect these cases.- Returns:
- Whether the currently authenticated user is a CSR acting on their own behalf.
-
isImpersonationSession
public boolean isImpersonationSession(org.springframework.security.core.Authentication userPrincipal) Checks the session to see if the user is a CSR in an impersonation flow.- Parameters:
userPrincipal- The Authentication representing the User.- Returns:
- Whether the current session is marked as for impersonation.
-