Class NimbusResponseEncoder

All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, UnmodifiableComponent, MessageEncoder, HttpServletResponseMessageEncoder

public class NimbusResponseEncoder extends AbstractHttpServletResponseMessageEncoder
A message encodes that encodes the Nimbus Response in the message context inside the attached HttpServletResponse.
  • Field Details

    • DEFAULT_TEMPLATE_ID

      @Nonnull @NotEmpty public static final String DEFAULT_TEMPLATE_ID
      Default template ID for using FORM POST response mode.
      See Also:
    • velocityEngine

      @Nullable private org.apache.velocity.app.VelocityEngine velocityEngine
      Velocity engine used to evaluate the template when using FORM POST response mode.
    • velocityTemplateId

      @Nonnull @NotEmpty private String velocityTemplateId
      ID of the Velocity template used when using FORM POST response mode.
    • objectMapper

      @NonnullAfterInit private com.fasterxml.jackson.databind.ObjectMapper objectMapper
      Object mapper used for pretty-printing JSON response.
    • cspDigester

      @Nullable private StringDigester cspDigester
      CSP digester for generating CSP hashes.
    • cspNonceGenerator

      @Nullable private IdentifierGenerationStrategy cspNonceGenerator
      CSP nonce generator.
  • Constructor Details

    • NimbusResponseEncoder

      public NimbusResponseEncoder()
      Constructor.
  • Method Details

    • setVelocityTemplateId

      public void setVelocityTemplateId(String newVelocityTemplateId)
      Set the Velocity template id.

      Defaults to DEFAULT_TEMPLATE_ID.

      Parameters:
      newVelocityTemplateId - the new Velocity template id
    • setVelocityEngine

      public void setVelocityEngine(org.apache.velocity.app.VelocityEngine newVelocityEngine)
      Set the VelocityEngine instance.
      Parameters:
      newVelocityEngine - the new VelocityEngine instane
    • setObjectMapper

      public void setObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper mapper)
      Set the object mapper used for pretty-printing JSON in the request.
      Parameters:
      mapper - What to set.
      Since:
      4.1.0
    • setCSPDigester

      public void setCSPDigester(@Nullable StringDigester digester)
      Sets a StringDigester to use in computing CSP digests in views.
      Parameters:
      digester - digester to set
      Since:
      4.1.0
    • setCSPNonceGenerator

      public void setCSPNonceGenerator(@Nullable IdentifierGenerationStrategy strategy)
      Sets an IdentifierGenerationStrategy to use in computing CSP nonces in views.
      Parameters:
      strategy - nonce strategy
      Since:
      4.1.0
    • impliesFormPost

      private boolean impliesFormPost(@Nullable Object response)
      Whether we should use FORM POST response encoding.
      Parameters:
      response - response message.
      Returns:
      true if DORM POST should be used.
    • doPostEncode

      private org.apache.velocity.VelocityContext doPostEncode(@Nonnull com.nimbusds.oauth2.sdk.AuthorizationResponse message)
      Set response message to FORM POST velocity context.
      Parameters:
      message - response message.
      Returns:
      response message as velocity context.
    • doEncode

      protected void doEncode() throws MessageEncodingException
      Specified by:
      doEncode in class AbstractMessageEncoder
      Throws:
      MessageEncodingException
    • serializeMessageForLogging

      @Nullable protected String serializeMessageForLogging(@Nullable Object message)
      Overrides:
      serializeMessageForLogging in class AbstractMessageEncoder