Package org.opensaml.messaging.decoder

# 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 Summary

Fields
Modifier and Type
Field
Description
`static final String`
`BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY`
Logging category for protocol messages.
`private final org.slf4j.Logger`
`log`
Class logger.
`private MessageContext`
`messageContext`
Message context.
`private org.slf4j.Logger`
`protocolMessageLog`
Used to log protocol messages.
`private String`
`protocolMessageLoggerSubCategory`
The configured logging sub-category for protocol messages.

## Constructor Summary

Constructors
Constructor
Description
`AbstractMessageDecoder()`

## Method Summary

Modifier and Type
Method
Description
`void`
`decode()`
Decode message data from the source and store it so that it may be retrieved via `MessageDecoder.getMessageContext()`.
`protected abstract void`
`doDecode()`
Performs the decoding logic.
`MessageContext`
`getMessageContext()`
Get the decoded message context.
`protected Object`
`getMessageToLog()`
Get the XMLObject which will be logged as the protocol message.
`protected org.slf4j.Logger`
`getProtocolMessageLogger()`
Get the protocol message logger.
`protected String`
`getProtocolMessageLoggerSubCategory()`
Get the configured logging sub-category for protocol messages.
`protected void`
`logDecodedMessage()`
Log the decoded message to the protocol message logger.
`protected String`
`serializeMessageForLogging(Object message)`
Serialize the message for logging purposes.
`protected void`
`setMessageContext(MessageContext context)`
Set the message context.
`protected void`
`setProtocolMessageLoggerSubCategory(String category)`
Set the configured logging sub-category for protocol messages.

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface net.shibboleth.shared.component.DestructableComponent

`destroy, isDestroyed`

### Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

`initialize, isInitialized`

## Field Details

### BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY

@Nonnull public static final String BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY
Logging category for protocol messages.

See Also:
  - Constant Field Values

### 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