Class DefaultCartCookieIssuer
java.lang.Object
com.broadleafcommerce.cartoperation.web.service.DefaultCartCookieIssuer
- All Implemented Interfaces:
CartCookieIssuer
- Author:
- Chris Kittrell (ckittrell)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addCartCookieClaims
(com.nimbusds.jwt.JWTClaimsSet.Builder jwtBuilder, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) jakarta.servlet.http.Cookie
buildCartCookie
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Build a cookie to hold a reference to a cart.jakarta.servlet.http.Cookie
buildCartExpirationCookie
(String applicationId) Build a cookie meant to remove the cart cookie for the provided application.org.springframework.http.ResponseCookie
buildCartResponseCookie
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Build a cookie to hold a reference to a cart.boolean
checkContextMatches
(Map<String, Object> cartCookieClaims, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Check if the provided cookie claims match the context.protected String
getApplicationId
(com.broadleafcommerce.cart.client.domain.Cart cart) getCartCookieName
(String applicationId) Name of the cart cookie.protected Duration
protected boolean
resolveCartId
(Map<String, Object> cartCookieClaims) Resolve the cart id from the provided cookie claims.protected <T> Optional<T>
protected Optional<com.nimbusds.jwt.SignedJWT>
verify
(jakarta.servlet.http.Cookie cartCookie) verifyAndGetClaims
(@NonNull jakarta.servlet.http.Cookie cartCookie) Verify the provided cart cookie and get its claims.
-
Constructor Details
-
DefaultCartCookieIssuer
-
-
Method Details
-
buildCartCookie
public jakarta.servlet.http.Cookie buildCartCookie(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartCookieIssuer
Build a cookie to hold a reference to a cart. If the cart is for a logged in user, no cart ID claim will be part of the cookie.- Specified by:
buildCartCookie
in interfaceCartCookieIssuer
- Parameters:
cart
- The cart for which to build a cookie.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart cookie to be added to the response.
-
buildCartResponseCookie
public org.springframework.http.ResponseCookie buildCartResponseCookie(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartCookieIssuer
Build a cookie to hold a reference to a cart. If the cart is for a logged in user, no cart ID claim will be part of the cookie.- Specified by:
buildCartResponseCookie
in interfaceCartCookieIssuer
- Parameters:
cart
- The cart for which to build a cookie.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart cookie to be added to the response.
-
addCartCookieClaims
protected void addCartCookieClaims(com.nimbusds.jwt.JWTClaimsSet.Builder jwtBuilder, com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getApplicationId
-
buildCartExpirationCookie
Description copied from interface:CartCookieIssuer
Build a cookie meant to remove the cart cookie for the provided application.- Specified by:
buildCartExpirationCookie
in interfaceCartCookieIssuer
- Parameters:
applicationId
- Application id used to identify which cart cookie to remove.- Returns:
- An immediately expiring cookie to be added to the response.
-
verifyAndGetClaims
public Map<String,Object> verifyAndGetClaims(@NonNull @NonNull jakarta.servlet.http.Cookie cartCookie) Description copied from interface:CartCookieIssuer
Verify the provided cart cookie and get its claims.- Specified by:
verifyAndGetClaims
in interfaceCartCookieIssuer
- Parameters:
cartCookie
- The cookie to use for retrieving the claims- Returns:
- The claims on the cart cookie
-
resolveCartId
Description copied from interface:CartCookieIssuer
Resolve the cart id from the provided cookie claims. Expect an empty response for registered user cart cookies.- Specified by:
resolveCartId
in interfaceCartCookieIssuer
- Parameters:
cartCookieClaims
- The cookie claims to use for retrieving the cart id.- Returns:
- Optional cart id for the provided cookie claims.
-
resolveClaim
-
verify
protected Optional<com.nimbusds.jwt.SignedJWT> verify(jakarta.servlet.http.Cookie cartCookie) throws ParseException, com.nimbusds.jose.JOSEException - Throws:
ParseException
com.nimbusds.jose.JOSEException
-
getCartCookieName
Description copied from interface:CartCookieIssuer
Name of the cart cookie.- Specified by:
getCartCookieName
in interfaceCartCookieIssuer
- Parameters:
applicationId
- Application id that may be appended to the cookie name.- Returns:
- The name of the cart cookie.
-
checkContextMatches
public boolean checkContextMatches(Map<String, Object> cartCookieClaims, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartCookieIssuer
Check if the provided cookie claims match the context.- Specified by:
checkContextMatches
in interfaceCartCookieIssuer
- Parameters:
cartCookieClaims
- The cookie claims to use for retrieving the cart id.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- Whether the provided cookie claims matches the context
-
isApplicationIdIncludedInCookieName
protected boolean isApplicationIdIncludedInCookieName() -
getCartTtl
-