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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected PreviewToken
decodeTokenString
(String tokenString) protected PreviewTokenDecoder
protected String
protected String
protected String
parseRequestHeader
(org.springframework.web.context.request.NativeWebRequest webRequest) protected String
parseRequestParameter
(org.springframework.web.context.request.NativeWebRequest webRequest) resolve
(org.springframework.web.context.request.NativeWebRequest webRequest) Attempts to resolve aPreviewToken
for the provided request, operation type, and context.void
setHeaderName
(String headerName) void
setParameterName
(String parameterName)
-
Field Details
-
DEFAULT_HEADER_NAME
- See Also:
-
DEFAULT_PARAMETER_NAME
- See Also:
-
-
Constructor Details
-
DefaultPreviewTokenWebRequestResolver
-
-
Method Details
-
resolve
Description copied from interface:PreviewTokenWebRequestResolver
Attempts to resolve aPreviewToken
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 returnnull
.- Specified by:
resolve
in interfacePreviewTokenWebRequestResolver
- Parameters:
webRequest
- the current web request- Returns:
- a
PreviewToken
ornull
-
decodeTokenString
-
parseRequestHeader
protected String parseRequestHeader(org.springframework.web.context.request.NativeWebRequest webRequest) -
parseRequestParameter
protected String parseRequestParameter(org.springframework.web.context.request.NativeWebRequest webRequest) -
getDecoder
-
getHeaderName
-
setHeaderName
-
getParameterName
-
setParameterName
-