Class JWTPreviewTokenDecoder
java.lang.Object
com.broadleafcommerce.data.tracking.core.preview.JWTPreviewTokenDecoder
- All Implemented Interfaces:
PreviewTokenDecoder
A default implementation of the
PreviewTokenDecoder
that decoded the PreviewToken
from a JWT token string.- Author:
- Nick Crum (ncrum)
-
Constructor Summary
ConstructorDescriptionJWTPreviewTokenDecoder
(com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper mapper) Optional constructor if looking to manually configure the decoder using the setters.JWTPreviewTokenDecoder
(JWTPreviewTokenDecoderProperties properties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper mapper) Primary constructor for initializing the decoder -
Method Summary
Modifier and TypeMethodDescriptionprotected PreviewToken
convertToPreviewToken
(com.nimbusds.jwt.JWTClaimsSet claims) Decoded an encoded preview token string into aPreviewToken
.protected com.fasterxml.jackson.databind.ObjectMapper
protected JWTPreviewTokenDecoderProperties
protected com.broadleafcommerce.common.extension.TypeFactory
protected com.nimbusds.jose.JWSVerifier
void
setEncodedPublicKey
(String encodedPublicKey) Sets the value ofJWTPreviewTokenDecoderProperties.getEncodedPublicKey()
, and initializes theverifier
used to verify JWT tokens.void
Setter for overwriting the current issuer onJWTPreviewTokenDecoderProperties
.protected void
validateJWT
(com.nimbusds.jwt.SignedJWT signedJWT)
-
Constructor Details
-
JWTPreviewTokenDecoder
public JWTPreviewTokenDecoder(JWTPreviewTokenDecoderProperties properties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper mapper) Primary constructor for initializing the decoder- Parameters:
properties
- the property configuration for the decoder
-
JWTPreviewTokenDecoder
public JWTPreviewTokenDecoder(com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper mapper) Optional constructor if looking to manually configure the decoder using the setters.
-
-
Method Details
-
setEncodedPublicKey
Sets the value ofJWTPreviewTokenDecoderProperties.getEncodedPublicKey()
, and initializes theverifier
used to verify JWT tokens.- Parameters:
encodedPublicKey
- the encoded public key
-
setIssuer
Setter for overwriting the current issuer onJWTPreviewTokenDecoderProperties
.- Parameters:
issuer
- the issuer
-
decode
Description copied from interface:PreviewTokenDecoder
Decoded an encoded preview token string into aPreviewToken
.- Specified by:
decode
in interfacePreviewTokenDecoder
- Parameters:
encodedTokenString
- the encoded preview token string- Returns:
- the decoded preview token
- Throws:
PreviewTokenParseException
- when there is an issue with the parsing of the encoded token
-
validateJWT
protected void validateJWT(com.nimbusds.jwt.SignedJWT signedJWT) throws ParseException, PreviewTokenParseException -
convertToPreviewToken
protected PreviewToken convertToPreviewToken(com.nimbusds.jwt.JWTClaimsSet claims) throws PreviewTokenParseException - Throws:
PreviewTokenParseException
-
getProperties
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getMapper
protected com.fasterxml.jackson.databind.ObjectMapper getMapper() -
getVerifier
protected com.nimbusds.jose.JWSVerifier getVerifier()
-