Class JWTPreviewTokenEncoder

java.lang.Object
com.broadleafcommerce.sandbox.service.JWTPreviewTokenEncoder
All Implemented Interfaces:
PreviewTokenEncoder

public class JWTPreviewTokenEncoder extends Object implements PreviewTokenEncoder
A default implementation of the PreviewTokenEncoder that encodes the PreviewToken into a JWT token string.
Author:
Nick Crum (ncrum)
  • Constructor Details

    • JWTPreviewTokenEncoder

      public JWTPreviewTokenEncoder(@NonNull JWTPreviewTokenEncoderProperties properties)
      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

      public void setEncodedPrivateKey(String encodedPrivateKey)
      Sets the value of JWTPreviewTokenEncoderProperties.getEncodedPrivateKey(), and initializes the signer used to sign JWT tokens.
      Parameters:
      encodedPrivateKey - the encoded private key
    • setIssuer

      public void setIssuer(String issuer)
      Setter for overwriting the current issuer for JWTPreviewTokenEncoderProperties.
      Parameters:
      issuer - the issuer
    • setExpirationTimeout

      public void setExpirationTimeout(Duration expirationTimeout)
      Setter for overwriting the current expiration time for JWTPreviewTokenEncoderProperties.
      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 the PreviewToken and should return the same object with `token` property containing the encoded token string.
      Specified by:
      encode in interface PreviewTokenEncoder
      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

      protected Date getExpirationTime()
    • getProperties

      protected JWTPreviewTokenEncoderProperties getProperties()
    • getSigner

      protected com.nimbusds.jose.JWSSigner getSigner()