Class HTTPPostEncoder

All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, UnmodifiableComponent, HTMLMessageEncoder, MessageEncoder, HttpServletResponseMessageEncoder, SAMLMessageEncoder
Direct Known Subclasses:
HTTPPostSimpleSignEncoder

public class HTTPPostEncoder extends BaseSAML2MessageEncoder implements HTMLMessageEncoder
SAML 2.0 HTTP Post binding message encoder.
  • Field Details

    • DEFAULT_TEMPLATE_ID

      @Nonnull @NotEmpty public static final String DEFAULT_TEMPLATE_ID
      Default template ID.
      See Also:
    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • velocityEngine

      @NonnullAfterInit private org.apache.velocity.app.VelocityEngine velocityEngine
      Velocity engine used to evaluate the template when performing POST encoding.
    • velocityTemplateId

      @Nonnull private String velocityTemplateId
      ID of the Velocity template used when performing POST encoding.
    • cspDigester

      @Nullable private StringDigester cspDigester
      Digester for CSP hashes.
    • cspNonceGenerator

      @Nullable private IdentifierGenerationStrategy cspNonceGenerator
      Generator for CSP nonces.
  • Constructor Details

    • HTTPPostEncoder

      public HTTPPostEncoder()
      Constructor.
  • Method Details

    • getBindingURI

      @Nonnull @NotEmpty public String getBindingURI()
      Gets the SAML binding URI supported by this encoder.
      Specified by:
      getBindingURI in interface SAMLMessageEncoder
      Returns:
      SAML binding URI supported by this encoder
    • getVelocityEngine

      @NonnullAfterInit public org.apache.velocity.app.VelocityEngine getVelocityEngine()
      Get the VelocityEngine instance.
      Returns:
      return the VelocityEngine instance
    • setVelocityEngine

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

      @Nonnull @NotEmpty public String getVelocityTemplateId()
      Get the Velocity template id.

      Defaults to DEFAULT_TEMPLATE_ID.

      Returns:
      return the Velocity template id
    • setVelocityTemplateId

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

      Defaults to DEFAULT_TEMPLATE_ID.

      Parameters:
      newVelocityTemplateId - the new Velocity template id
    • setCSPDigester

      public void setCSPDigester(@Nullable StringDigester digester)
      Set a StringDigester to use to generate CSP hashes.
      Specified by:
      setCSPDigester in interface HTMLMessageEncoder
      Parameters:
      digester - string digester
    • setCSPNonceGenerator

      public void setCSPNonceGenerator(@Nullable IdentifierGenerationStrategy strategy)
      Set a IdentifierGenerationStrategy to use to generate CSP nonces.
      Specified by:
      setCSPNonceGenerator in interface HTMLMessageEncoder
      Parameters:
      strategy - nonce strategy
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractHttpServletResponseMessageEncoder
      Throws:
      ComponentInitializationException
    • doEncode

      protected void doEncode() throws MessageEncodingException
      Performs the encoding logic. By the time this is called, this encoder has already been initialized and checked to ensure that it has not been destroyed.
      Specified by:
      doEncode in class AbstractMessageEncoder
      Throws:
      MessageEncodingException - thrown if there is a problem encoding the message
    • postEncode

      protected void postEncode(@Nonnull MessageContext messageContext, @Nonnull String endpointURL) throws MessageEncodingException
      Base64 and POST encodes the outbound message and writes it to the outbound transport.
      Parameters:
      messageContext - current message context
      endpointURL - endpoint URL to which to encode message
      Throws:
      MessageEncodingException - thrown if there is a problem encoding the message
    • populateVelocityContext

      protected void populateVelocityContext(@Nonnull org.apache.velocity.VelocityContext velocityContext, @Nonnull MessageContext messageContext, @Nonnull String endpointURL) throws MessageEncodingException
      Populate the Velocity context instance which will be used to render the POST body.
      Parameters:
      velocityContext - the Velocity context instance to populate with data
      messageContext - the SAML message context source of data
      endpointURL - endpoint URL to which to encode message
      Throws:
      MessageEncodingException - thrown if there is a problem encoding the message