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
FieldsModifier and TypeFieldDescriptionstatic final StringLogging category for protocol messages.private final org.slf4j.LoggerClass logger.private MessageContextMessage context.private org.slf4j.LoggerUsed to log protocol messages.private StringThe configured logging sub-category for protocol messages. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddecode()Decode message data from the source and store it so that it may be retrieved viaMessageDecoder.getMessageContext().protected abstract voiddoDecode()Performs the decoding logic.Get the decoded message context.protected ObjectGet the XMLObject which will be logged as the protocol message.protected org.slf4j.LoggerGet the protocol message logger.protected StringGet the configured logging sub-category for protocol messages.protected voidLog the decoded message to the protocol message logger.protected StringserializeMessageForLogging(Object message) Serialize the message for logging purposes.protected voidsetMessageContext(MessageContext context) Set the message context.protected voidsetProtocolMessageLoggerSubCategory(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, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.DestructableComponent
destroy, isDestroyedMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY
Logging category for protocol messages.- See Also:
-
protocolMessageLog
@Nonnull private org.slf4j.Logger protocolMessageLogUsed to log protocol messages. -
log
@Nonnull private final org.slf4j.Logger logClass logger. -
messageContext
Message context. -
protocolMessageLoggerSubCategory
The configured logging sub-category for protocol messages.
-
-
Constructor Details
-
AbstractMessageDecoder
public AbstractMessageDecoder()
-
-
Method Details
-
getMessageContext
Get the decoded message context.- Specified by:
getMessageContextin interfaceMessageDecoder- Returns:
- the decoded message context
-
setMessageContext
Set the message context.- Parameters:
context- the message context
-
decode
Decode message data from the source and store it so that it may be retrieved viaMessageDecoder.getMessageContext().- Specified by:
decodein interfaceMessageDecoder- 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
Get the configured logging sub-category for protocol messages.- Returns:
- the logging sub-category
-
setProtocolMessageLoggerSubCategory
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
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
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
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
-