Package org.opensaml.messaging.encoder.servlet

# Class BaseHttpServletResponseXMLMessageEncoder

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.encoder.AbstractMessageEncoder
org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
org.opensaml.messaging.encoder.servlet.BaseHttpServletResponseXMLMessageEncoder

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `UnmodifiableComponent`, `MessageEncoder`, `HttpServletResponseMessageEncoder`

Direct Known Subclasses:
  `BaseSAMLHttpServletResponseEncoder`, `HTTPSOAP11Encoder`

public abstract class BaseHttpServletResponseXMLMessageEncoder extends AbstractHttpServletResponseMessageEncoder
Base class for message encoders which encode XML messages to HttpServletResponse.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.slf4j.Logger`
`log`
Class logger.
`private org.slf4j.Logger`
`protocolMessageLog`
Used to log protocol messages.

### Fields inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder

`BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY`

## Constructor Summary

Constructors
Constructor
Description
`BaseHttpServletResponseXMLMessageEncoder()`

## Method Summary

Modifier and Type
Method
Description
`void`
`encode()`
Encode the `MessageContext` supplied via `MessageEncoder.setMessageContext(MessageContext)` to the sink.
`protected Element`
`marshallMessage(XMLObject message)`
Helper method that marshalls the given message.
`protected String`
`serializeMessageForLogging(Object message)`
Serialize the message for logging purposes.

### Methods inherited from class org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder

`doInitialize, getHttpServletResponse, getHttpServletResponseSupplier, setHttpServletResponseSupplier`

### Methods inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder

`doEncode, getMessageContext, getMessageToLog, getProtocolMessageLogger, getProtocolMessageLoggerSubCategory, logEncodedMessage, prepareContext, setMessageContext, setProtocolMessageLoggerSubCategory`

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

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, 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`

### Methods inherited from interface org.opensaml.messaging.encoder.MessageEncoder

`prepareContext, setMessageContext`

## Field Details

### protocolMessageLog

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

### log

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

## Constructor Details

### BaseHttpServletResponseXMLMessageEncoder

public BaseHttpServletResponseXMLMessageEncoder()

## Method Details

### encode

public void encode() throws MessageEncodingException
Encode the `MessageContext` supplied via `MessageEncoder.setMessageContext(MessageContext)` to the sink.

Specified by:
  `encode` in interface `MessageEncoder`
Overrides:
  `encode` in class `AbstractMessageEncoder`
Throws:
  `MessageEncodingException` - if there is a problem encoding the message context

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

Overrides:
  `serializeMessageForLogging` in class `AbstractMessageEncoder`
Parameters:
  `message` - the message to serialize
Returns:
  the serialized message, or null if message can not be serialized

### marshallMessage

@Nonnull protected Element marshallMessage(@Nonnull XMLObject message) throws MessageEncodingException
Helper method that marshalls the given message.

Parameters:
  `message` - message the marshall and serialize
Returns:
  marshalled message
Throws:
  `MessageEncodingException` - thrown if the give message can not be marshalled into its DOM representation