Class DefaultPreviewTokenWebRequestResolver

java.lang.Object
com.broadleafcommerce.data.tracking.core.preview.context.DefaultPreviewTokenWebRequestResolver
All Implemented Interfaces:
PreviewTokenWebRequestResolver

public class DefaultPreviewTokenWebRequestResolver extends Object implements PreviewTokenWebRequestResolver
The default implementation of PreviewTokenWebRequestResolver that makes use of the PreviewTokenDecoder to decode a PreviewToken from the provided NativeWebRequest.

This resolver will look for a header named getHeaderName() or a request parameter named getParameterName() to detect a preview token String. If a token is found, the resolver will use the decoder to convert it into a PreviewToken. If successfully decoded, the resolver will validate the token is a match for the provided ContextRequest and OperationType.

If this resolver either fails to detect a token, or fails to decode a found token, then it will return null.

Author:
Nick Crum (ncrum)
  • Field Details

  • Constructor Details

    • DefaultPreviewTokenWebRequestResolver

      public DefaultPreviewTokenWebRequestResolver(PreviewTokenDecoder decoder)
  • Method Details

    • resolve

      public PreviewToken resolve(org.springframework.web.context.request.NativeWebRequest webRequest)
      Description copied from interface: PreviewTokenWebRequestResolver
      Attempts to resolve a PreviewToken for the provided request, operation type, and context. If no preview token is found, or if it is found to be invalid, this method is expected to return null.
      Specified by:
      resolve in interface PreviewTokenWebRequestResolver
      Parameters:
      webRequest - the current web request
      Returns:
      a PreviewToken or null
    • decodeTokenString

      protected PreviewToken decodeTokenString(String tokenString)
    • parseRequestHeader

      protected String parseRequestHeader(org.springframework.web.context.request.NativeWebRequest webRequest)
    • parseRequestParameter

      protected String parseRequestParameter(org.springframework.web.context.request.NativeWebRequest webRequest)
    • getDecoder

      protected PreviewTokenDecoder getDecoder()
    • getHeaderName

      protected String getHeaderName()
    • setHeaderName

      public void setHeaderName(String headerName)
    • getParameterName

      protected String getParameterName()
    • setParameterName

      public void setParameterName(String parameterName)