Interface CartCookieIssuer

  • All Known Implementing Classes:
    DefaultCartCookieIssuer

    public interface CartCookieIssuer
    Responsible for issuing and resolving cart cookies. Note that cart cookies for registered users don't contain the cart ID. Instead, they act as a container for the cart version to be able to enforce optimistic locking.
    • Method Detail

      • buildCartCookie

        @Deprecated
        javax.servlet.http.Cookie buildCartCookie​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                                  @Nullable
                                                  com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Deprecated.
        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.
        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

        org.springframework.http.ResponseCookie buildCartResponseCookie​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                        @Nullable
                                                                        com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        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.
        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.
      • buildCartExpirationCookie

        javax.servlet.http.Cookie buildCartExpirationCookie​(@Nullable
                                                            String applicationId)
        Build a cookie meant to remove the cart cookie for the provided application.
        Parameters:
        applicationId - Application id used to identify which cart cookie to remove.
        Returns:
        An immediately expiring cookie to be added to the response.
      • verifyAndGetClaims

        Map<String,​Object> verifyAndGetClaims​(@NonNull
                                                    @NonNull javax.servlet.http.Cookie cartCookie)
        Verify the provided cart cookie and get its claims.
        Parameters:
        cartCookie - The cookie to use for retrieving the claims
        Returns:
        The claims on the cart cookie
      • resolveCartId

        Optional<String> resolveCartId​(Map<String,​Object> cartCookieClaims)
        Resolve the cart id from the provided cookie claims. Expect an empty response for registered user cart cookies.
        Parameters:
        cartCookieClaims - The cookie claims to use for retrieving the cart id.
        Returns:
        Optional cart id for the provided cookie claims.
      • getCartCookieName

        String getCartCookieName​(@Nullable
                                 String applicationId)
        Name of the cart cookie.
        Parameters:
        applicationId - Application id that may be appended to the cookie name.
        Returns:
        The name of the cart cookie.
      • checkContextMatches

        boolean checkContextMatches​(Map<String,​Object> cartCookieClaims,
                                    @Nullable
                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Check if the provided cookie claims match the context.
        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