Class DefaultGuestCartProtectionService
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.DefaultGuestCartProtectionService
-
- All Implemented Interfaces:
GuestCartProtectionService
public class DefaultGuestCartProtectionService extends Object implements GuestCartProtectionService
Default implementation ofGuestCartProtectionServicethat clears typical customer information and utilizesCartProviderfor storing guest tokens.- Author:
- Nick Crum (ncrum)
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringINVALID_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.CartclearCustomerInformation(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Clears customer information from the provided cart.com.broadleafcommerce.cart.client.domain.CartclearCustomerInformation(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)If theCartcontains payment data, then this method should clone the original cart & remove any sensitive customer data.protected voidclearCustomerPayments(String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)com.broadleafcommerce.cart.client.domain.GuestTokencreateGuestToken(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Creates a new guest token for the cart with the provided ID.protected CartProvidergetCartProvider()protected CsrCartOperationServicegetCsrCartOpService()protected PaymentProvider<PaymentSummary>getPaymentProvider()protected GuestTokenGeneratorgetTokenGenerator()protected GuestTokenProvidergetTokenProvider()protected booleanisTokenExpired(com.broadleafcommerce.cart.client.domain.GuestToken retrieved)voidsetCartProvider(CartProvider cartProvider)voidsetCsrCartOpService(CsrCartOperationService csrCartOpService)com.broadleafcommerce.cart.client.domain.GuestTokenvalidateGuestToken(@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:GuestCartProtectionServiceIf theCartcontains 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:
clearCustomerInformationin 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:GuestCartProtectionServiceClears 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:
clearCustomerInformationin 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:GuestCartProtectionServiceCreates 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:
createGuestTokenin 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:GuestCartProtectionServiceValidates 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 aGuestTokenValidationExceptionindicating the token failed to validate.- Specified by:
validateGuestTokenin 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()
-
-