Class AbstractMessageDecoder

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.decoder.AbstractMessageDecoder
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, UnmodifiableComponent, MessageDecoder
Direct Known Subclasses:
AbstractHttpClientResponseMessageDecoder, AbstractHttpServletRequestMessageDecoder

public abstract class AbstractMessageDecoder extends AbstractInitializableComponent implements MessageDecoder, UnmodifiableComponent
Abstract message decoder.
  • Field Details

    • BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY

      @Nonnull public static final String BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY
      Logging category for protocol messages.
      See Also:
    • protocolMessageLog

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

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

      @Nullable private MessageContext messageContext
      Message context.
    • protocolMessageLoggerSubCategory

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

    • AbstractMessageDecoder

      public AbstractMessageDecoder()
  • Method Details

    • getMessageContext

      @Nullable public MessageContext getMessageContext()
      Get the decoded message context.
      Specified by:
      getMessageContext in interface MessageDecoder
      Returns:
      the decoded message context
    • setMessageContext

      protected void setMessageContext(@Nullable MessageContext context)
      Set the message context.
      Parameters:
      context - the message context
    • decode

      public void decode() throws MessageDecodingException
      Decode message data from the source and store it so that it may be retrieved via MessageDecoder.getMessageContext().
      Specified by:
      decode in interface MessageDecoder
      Throws:
      MessageDecodingException - if there is a problem decoding the message context
    • getProtocolMessageLogger

      @Nonnull protected org.slf4j.Logger getProtocolMessageLogger()
      Get the protocol message logger.
      Returns:
      The protocol message logger
    • 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()
      Log the decoded message to the protocol message logger.
    • getMessageToLog

      @Nullable protected Object getMessageToLog()
      Get the XMLObject which will be logged as the protocol message.
      Returns:
      the XMLObject message considered to be the protocol message for logging purposes
    • serializeMessageForLogging

      @Nullable protected String serializeMessageForLogging(@Nullable Object message)
      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:
      message - the message to serialize
      Returns:
      the serialized message, or null if message can not be serialized
    • doDecode

      protected abstract void doDecode() throws MessageDecodingException
      Performs the decoding logic. By the time this is called, this decoder has already been initialized and checked to ensure that it has not been destroyed.
      Throws:
      MessageDecodingException - thrown if there is a problem decoding the message