Class DefaultGuestCartProtectionService
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.DefaultGuestCartProtectionService
-
- All Implemented Interfaces:
GuestCartProtectionService
public class DefaultGuestCartProtectionService extends Object implements GuestCartProtectionService
Default implementation ofGuestCartProtectionService
that clears typical customer information and utilizesCartProvider
for storing guest tokens.- Author:
- Nick Crum (ncrum)
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
INVALID_GUEST_TOKEN_FMT
-
Constructor Summary
Constructors Constructor Description DefaultGuestCartProtectionService(GuestTokenProvider tokenProvider, GuestTokenGenerator tokenGenerator, PaymentProvider<PaymentSummary> paymentProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.broadleafcommerce.cart.client.domain.Cart
clearCustomerInformation(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Clears customer information from the provided cart.com.broadleafcommerce.cart.client.domain.Cart
clearCustomerInformation(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
If theCart
contains payment data, then this method should clone the original cart & remove any sensitive customer data.protected void
clearCustomerPayments(String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
com.broadleafcommerce.cart.client.domain.GuestToken
createGuestToken(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates a new guest token for the cart with the provided ID.protected CartProvider
getCartProvider()
protected CsrCartOperationService
getCsrCartOpService()
protected PaymentProvider<PaymentSummary>
getPaymentProvider()
protected GuestTokenGenerator
getTokenGenerator()
protected GuestTokenProvider
getTokenProvider()
protected boolean
isTokenExpired(com.broadleafcommerce.cart.client.domain.GuestToken retrieved)
void
setCartProvider(CartProvider cartProvider)
void
setCsrCartOpService(CsrCartOperationService csrCartOpService)
com.broadleafcommerce.cart.client.domain.GuestToken
validateGuestToken(@NonNull String cartId, @NonNull String guestToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Validates the provided guest token string for the given cart ID.
-
-
-
Field Detail
-
INVALID_GUEST_TOKEN_FMT
protected static final String INVALID_GUEST_TOKEN_FMT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultGuestCartProtectionService
public DefaultGuestCartProtectionService(GuestTokenProvider tokenProvider, GuestTokenGenerator tokenGenerator, PaymentProvider<PaymentSummary> paymentProvider)
-
-
Method Detail
-
clearCustomerInformation
public com.broadleafcommerce.cart.client.domain.Cart clearCustomerInformation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:GuestCartProtectionService
If theCart
contains payment data, then this method should clone the original cart & remove any sensitive customer data. Otherwise, this method will remove any sensitive customer data and return the existing cart.- Specified by:
clearCustomerInformation
in interfaceGuestCartProtectionService
- Parameters:
cart
- the cart to clearcontextInfo
- the context info- Returns:
- Either the original cart or a cloned cart that has been cleansed of customer data.
-
clearCustomerInformation
public com.broadleafcommerce.cart.client.domain.Cart clearCustomerInformation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Description copied from interface:GuestCartProtectionService
Clears customer information from the provided cart. This is typically used to filter out personal information from a guest cart when a guest token is not present, or when generating a new guest token.Note, this method will not persist any changes to the cart. Instead,
CartOperationService.updateCart(Cart, boolean, boolean, boolean, ContextInfo)
should be used to save the cart if the changes are meant to be permanent.- Specified by:
clearCustomerInformation
in interfaceGuestCartProtectionService
- Parameters:
cart
- the cart to clear
-
createGuestToken
public com.broadleafcommerce.cart.client.domain.GuestToken createGuestToken(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:GuestCartProtectionService
Creates a new guest token for the cart with the provided ID. This typically creates or replaces a token within a token store for the given cart ID, and returns the resulting token details.- Specified by:
createGuestToken
in interfaceGuestCartProtectionService
- Parameters:
cartId
- the cart IDcontextInfo
- the context info- Returns:
- the token details
-
validateGuestToken
public com.broadleafcommerce.cart.client.domain.GuestToken validateGuestToken(@NonNull @NonNull String cartId, @NonNull @NonNull String guestToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:GuestCartProtectionService
Validates the provided guest token string for the given cart ID. This typically retrieves a the token details from a token store using the cart ID, and verifies they match up with the provided token string. If verified, this will return the token details. If not verified, this will throw aGuestTokenValidationException
indicating the token failed to validate.- Specified by:
validateGuestToken
in interfaceGuestCartProtectionService
- Parameters:
cartId
- the cart IDguestToken
- the guest token stringcontextInfo
- the context info- Returns:
- the verified token details
-
clearCustomerPayments
protected void clearCustomerPayments(String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
isTokenExpired
protected boolean isTokenExpired(com.broadleafcommerce.cart.client.domain.GuestToken retrieved)
-
getTokenProvider
protected GuestTokenProvider getTokenProvider()
-
getTokenGenerator
protected GuestTokenGenerator getTokenGenerator()
-
getCsrCartOpService
protected CsrCartOperationService getCsrCartOpService()
-
setCsrCartOpService
@Autowired public void setCsrCartOpService(CsrCartOperationService csrCartOpService)
-
getCartProvider
protected CartProvider getCartProvider()
-
setCartProvider
@Autowired public void setCartProvider(CartProvider cartProvider)
-
getPaymentProvider
protected PaymentProvider<PaymentSummary> getPaymentProvider()
-
-