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.PreviewToken
encode
(com.broadleafcommerce.data.tracking.core.preview.PreviewToken previewToken) Encodes a token from thePreviewToken
and should return the same object with `token` property containing the encoded token string.protected com.nimbusds.jwt.JWTClaimsSet
getClaims
(com.broadleafcommerce.data.tracking.core.preview.PreviewToken previewToken) protected Date
protected JWTPreviewTokenEncoderProperties
protected com.nimbusds.jose.JWSSigner
void
setEncodedPrivateKey
(String encodedPrivateKey) Sets the value ofJWTPreviewTokenEncoderProperties.getEncodedPrivateKey()
, and initializes thesigner
used to sign JWT tokens.void
setExpirationTimeout
(Duration expirationTimeout) Setter for overwriting the current expiration time forJWTPreviewTokenEncoderProperties
.void
Setter 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 thesigner
used 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:PreviewTokenEncoder
Encodes a token from thePreviewToken
and should return the same object with `token` property containing the encoded token string.- Specified by:
encode
in 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()
-