Class JWTPreviewTokenDecoder
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.preview.JWTPreviewTokenDecoder
-
- All Implemented Interfaces:
PreviewTokenDecoder
public class JWTPreviewTokenDecoder extends Object implements PreviewTokenDecoder
A default implementation of thePreviewTokenDecoderthat decoded thePreviewTokenfrom a JWT token string.- Author:
- Nick Crum (ncrum)
-
-
Constructor Summary
Constructors Constructor Description 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.JWTPreviewTokenDecoder(JWTPreviewTokenDecoderProperties properties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper mapper)Primary constructor for initializing the decoder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PreviewTokenconvertToPreviewToken(com.nimbusds.jwt.JWTClaimsSet claims)PreviewTokendecode(String encodedTokenString)Decoded an encoded preview token string into aPreviewToken.protected com.fasterxml.jackson.databind.ObjectMappergetMapper()protected JWTPreviewTokenDecoderPropertiesgetProperties()protected com.broadleafcommerce.common.extension.TypeFactorygetTypeFactory()protected com.nimbusds.jose.JWSVerifiergetVerifier()voidsetEncodedPublicKey(String encodedPublicKey)Sets the value ofJWTPreviewTokenDecoderProperties.getEncodedPublicKey(), and initializes theverifierused to verify JWT tokens.voidsetIssuer(String issuer)Setter for overwriting the current issuer onJWTPreviewTokenDecoderProperties.protected voidvalidateJWT(com.nimbusds.jwt.SignedJWT signedJWT)
-
-
-
Constructor Detail
-
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 Detail
-
setEncodedPublicKey
public void setEncodedPublicKey(String encodedPublicKey)
Sets the value ofJWTPreviewTokenDecoderProperties.getEncodedPublicKey(), and initializes theverifierused to verify JWT tokens.- Parameters:
encodedPublicKey- the encoded public key
-
setIssuer
public void setIssuer(String issuer)
Setter for overwriting the current issuer onJWTPreviewTokenDecoderProperties.- Parameters:
issuer- the issuer
-
decode
public PreviewToken decode(String encodedTokenString) throws PreviewTokenParseException
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
protected JWTPreviewTokenDecoderProperties getProperties()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
getMapper
protected com.fasterxml.jackson.databind.ObjectMapper getMapper()
-
getVerifier
protected com.nimbusds.jose.JWSVerifier getVerifier()
-
-