Class AbstractJSONResponseDecoderFunction<T>

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.oidc.profile.decoding.impl.AbstractJSONResponseDecoderFunction<T>
Type Parameters:
T - the return type of the function.
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
Direct Known Subclasses:
AccessTokenResponseDecoder, UserInfoResponseDecoder

@NotThreadSafe public abstract class AbstractJSONResponseDecoderFunction<T> extends AbstractInitializableComponent implements org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
Abstract class for JSON based Http client response decoders.

Note, any input stream obtained by the decoder MUST ensure the stream is closed.

  • Field Details

    • BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY

      @Nonnull public static final String BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY
      See Also:
    • protocolMessageLog

      @Nonnull private org.slf4j.Logger protocolMessageLog
      Used to log protocol messages.
    • protocolMessageLoggerSubCategory

      @Nullable private String protocolMessageLoggerSubCategory
      The configured logging sub-category for protocol messages.
    • objectMapper

      @NonnullAfterInit private com.fasterxml.jackson.databind.ObjectMapper objectMapper
      JSON object mapper.
  • Constructor Details

    • AbstractJSONResponseDecoderFunction

      public AbstractJSONResponseDecoderFunction()
  • Method Details

    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractInitializableComponent
      Throws:
      ComponentInitializationException
    • setObjectMapper

      public void setObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper mapper)
      Set the JSON Object Mapper to use.
      Parameters:
      mapper - the object mapper.
    • getObjectMapper

      @NonnullAfterInit protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Get the object mapper.
      Returns:
      the object mapper.
    • getProtocolMessageLoggerSubCategory

      @Nullable protected String getProtocolMessageLoggerSubCategory()
      Get the configured logging sub-category for protocol messages.
      Returns:
      the logging sub-category
    • setProtocolMessageLoggerSubCategory

      protected void setProtocolMessageLoggerSubCategory(@Nullable String category)
      Set the configured logging sub-category for protocol messages.
      Parameters:
      category - the logging sub-category
    • logDecodedMessage

      protected void logDecodedMessage(T response)
      Log the decoded message to the protocol message logger.
    • serializeMessageForLogging

      @Nullable protected String serializeMessageForLogging(@Nullable T response)
      Serialize the message for logging purposes.

      Default implementation is to return the message object's Object.toString(), but subclasses should override if a better message-specific serialization mechanism exists.

      Parameters:
      response - the response message to serialize
      Returns:
      the serialized message, or null if message can not be serialized
    • handleResponse

      public final T handleResponse(org.apache.hc.core5.http.ClassicHttpResponse httpResponse) throws org.apache.hc.core5.http.HttpException, IOException
      Specified by:
      handleResponse in interface org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
      Throws:
      org.apache.hc.core5.http.HttpException
      IOException
    • getProtocolMessageForErrorObject

      @Nullable protected static String getProtocolMessageForErrorObject(@Nullable com.nimbusds.oauth2.sdk.ErrorObject errorObject)
      Helper method for getting protocol message for error object.
      Parameters:
      errorObject - The error object
      Returns:
      The log message
    • doHandleResponse

      protected abstract T doHandleResponse(org.apache.hc.core5.http.ClassicHttpResponse httpResponse) throws org.apache.hc.core5.http.HttpException, IOException
      Do the actual response processing and return a result. Overridden by implementation classes.
      Parameters:
      httpResponse - the http response
      Throws:
      org.apache.hc.core5.http.HttpException
      IOException