Class JWTPreviewTokenEncoder
java.lang.Object
com.broadleafcommerce.sandbox.service.JWTPreviewTokenEncoder
- All Implemented Interfaces:
PreviewTokenEncoder
A default implementation of the
PreviewTokenEncoder that encodes the PreviewToken
into a JWT token string.- Author:
- Nick Crum (ncrum)
-
Constructor Summary
ConstructorsConstructorDescriptionOptional constructor if looking to manually configure the encoder using the setters.Primary constructor for initializing the encoder -
Method Summary
Modifier and TypeMethodDescriptioncom.broadleafcommerce.data.tracking.core.preview.PreviewTokenencode(com.broadleafcommerce.data.tracking.core.preview.PreviewToken previewToken) Encodes a token from thePreviewTokenand should return the same object with `token` property containing the encoded token string.protected com.nimbusds.jwt.JWTClaimsSetgetClaims(com.broadleafcommerce.data.tracking.core.preview.PreviewToken previewToken) protected Dateprotected JWTPreviewTokenEncoderPropertiesprotected com.nimbusds.jose.JWSSignervoidsetEncodedPrivateKey(String encodedPrivateKey) Sets the value ofJWTPreviewTokenEncoderProperties.getEncodedPrivateKey(), and initializes thesignerused to sign JWT tokens.voidsetExpirationTimeout(Duration expirationTimeout) Setter for overwriting the current expiration time forJWTPreviewTokenEncoderProperties.voidSetter for overwriting the current issuer forJWTPreviewTokenEncoderProperties.
-
Constructor Details
-
JWTPreviewTokenEncoder
Primary constructor for initializing the encoder- Parameters:
properties- the property configuration for the encoder
-
JWTPreviewTokenEncoder
public JWTPreviewTokenEncoder()Optional constructor if looking to manually configure the encoder using the setters.
-
-
Method Details
-
setEncodedPrivateKey
Sets the value ofJWTPreviewTokenEncoderProperties.getEncodedPrivateKey(), and initializes thesignerused to sign JWT tokens.- Parameters:
encodedPrivateKey- the encoded private key
-
setIssuer
Setter for overwriting the current issuer forJWTPreviewTokenEncoderProperties.- Parameters:
issuer- the issuer
-
setExpirationTimeout
Setter for overwriting the current expiration time forJWTPreviewTokenEncoderProperties.- Parameters:
expirationTimeout- the expiration timeout duration
-
encode
public com.broadleafcommerce.data.tracking.core.preview.PreviewToken encode(com.broadleafcommerce.data.tracking.core.preview.PreviewToken previewToken) throws PreviewTokenEncoderException Description copied from interface:PreviewTokenEncoderEncodes a token from thePreviewTokenand should return the same object with `token` property containing the encoded token string.- Specified by:
encodein interfacePreviewTokenEncoder- Parameters:
previewToken- the preview token without an encoded preview token string- Returns:
- the preview token with an encoded preview token string
- Throws:
PreviewTokenEncoderException- when it fails to encode the preview token
-
getClaims
protected com.nimbusds.jwt.JWTClaimsSet getClaims(com.broadleafcommerce.data.tracking.core.preview.PreviewToken previewToken) -
getExpirationTime
-
getProperties
-
getSigner
protected com.nimbusds.jose.JWSSigner getSigner()
-