Class HTTPPostRequestEncoder

All Implemented Interfaces:
Predicate<OAuth2AuthorizationProfileConfiguration.HttpRequestMethod>, OIDCMessageEncoder, Component, DestructableComponent, InitializableComponent, UnmodifiableComponent, MessageEncoder, HttpServletResponseMessageEncoder

public class HTTPPostRequestEncoder extends AbstractOIDCMessageEncoder
A message encoder that encodes an OpenID authentication or logout request by HTTP Form POST Serialization.
  • Field Details

    • DEFAULT_TEMPLATE_ID

      @Nonnull @NotEmpty public static final String DEFAULT_TEMPLATE_ID
      Default template ID for using FORM POST request type for authentication or logout.
      See Also:
    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • 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.
    • cspDigester

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

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

    • HTTPPostRequestEncoder

      public HTTPPostRequestEncoder()
  • Method Details

    • setCSPDigester

      public void setCSPDigester(@Nullable StringDigester digester)
      Sets a StringDigester to use in computing CSP digests in views.
      Parameters:
      digester - digester to set
      Since:
      3.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:
      3.1.0
    • 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
    • setVelocityEngine

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

      public boolean test(@Nullable OAuth2AuthorizationProfileConfiguration.HttpRequestMethod requestMethod)
    • doPostEncode

      private org.apache.velocity.VelocityContext doPostEncode(@Nonnull OIDCAuthenticationRequest request, @Nonnull HttpServletResponse httpResponse) throws MessageEncodingException
      Construct form POST for an authentication request.
      Parameters:
      request - the authentication request.
      httpResponse - the httpResponse.
      Returns:
      response message as velocity context.
      Throws:
      MessageEncodingException - on error building the parameters
    • doPostEncode

      private org.apache.velocity.VelocityContext doPostEncode(@Nonnull OIDCLogoutRequest request, @Nonnull HttpServletResponse httpResponse) throws MessageEncodingException
      Construct form POST for a logout request.
      Parameters:
      request - the logout request.
      httpResponse - the httpResponse.
      Returns:
      response message as velocity context.
      Throws:
      MessageEncodingException - on error building the parameters
    • createContext

      private org.apache.velocity.VelocityContext createContext(@Nonnull URI endpoint, @Nonnull List<Pair<String,String>> params, @Nonnull HttpServletResponse httpResponse)
      Create a Velocity context and encode the response parameters into the context.
      Parameters:
      endpoint - the URL to add to the form action
      params - the parameters to encode in the context
      httpResponse - the HTTP response to use
      Returns:
      the populated Velocity context
    • doEncode

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