Class DefaultCartCookieIssuer

    • Constructor Detail

    • Method Detail

      • buildCartCookie

        public javax.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 interface CartCookieIssuer
        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 interface CartCookieIssuer
        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

        protected String getApplicationId​(com.broadleafcommerce.cart.client.domain.Cart cart)
      • buildCartExpirationCookie

        public javax.servlet.http.Cookie buildCartExpirationCookie​(String applicationId)
        Description copied from interface: CartCookieIssuer
        Build a cookie meant to remove the cart cookie for the provided application.
        Specified by:
        buildCartExpirationCookie in interface CartCookieIssuer
        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 javax.servlet.http.Cookie cartCookie)
        Description copied from interface: CartCookieIssuer
        Verify the provided cart cookie and get its claims.
        Specified by:
        verifyAndGetClaims in interface CartCookieIssuer
        Parameters:
        cartCookie - The cookie to use for retrieving the claims
        Returns:
        The claims on the cart cookie
      • resolveCartId

        public Optional<String> resolveCartId​(Map<String,​Object> cartCookieClaims)
        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 interface CartCookieIssuer
        Parameters:
        cartCookieClaims - The cookie claims to use for retrieving the cart id.
        Returns:
        Optional cart id for the provided cookie claims.
      • verify

        protected Optional<com.nimbusds.jwt.SignedJWT> verify​(javax.servlet.http.Cookie cartCookie)
                                                       throws ParseException,
                                                              com.nimbusds.jose.JOSEException
        Throws:
        ParseException
        com.nimbusds.jose.JOSEException
      • getCartCookieName

        public String getCartCookieName​(@Nullable
                                        String applicationId)
        Description copied from interface: CartCookieIssuer
        Name of the cart cookie.
        Specified by:
        getCartCookieName in interface CartCookieIssuer
        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 interface CartCookieIssuer
        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

        protected Duration getCartTtl()