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
ConstructorsConstructorDescriptionJWTPreviewTokenDecoder(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 PreviewTokenconvertToPreviewToken(com.nimbusds.jwt.JWTClaimsSet claims) Decoded an encoded preview token string into aPreviewToken.protected com.fasterxml.jackson.databind.ObjectMapperprotected JWTPreviewTokenDecoderPropertiesprotected com.broadleafcommerce.common.extension.TypeFactoryprotected com.nimbusds.jose.JWSVerifiervoidsetEncodedPublicKey(String encodedPublicKey) Sets the value ofJWTPreviewTokenDecoderProperties.getEncodedPublicKey(), and initializes theverifierused to verify JWT tokens.voidSetter for overwriting the current issuer onJWTPreviewTokenDecoderProperties.protected voidvalidateJWT(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 theverifierused 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:PreviewTokenDecoderDecoded an encoded preview token string into aPreviewToken.- Specified by:
decodein 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()
-