Class AbstractMessageEncoder

  • All Implemented Interfaces:
    net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.InitializableComponent, net.shibboleth.utilities.java.support.component.UnmodifiableComponent, MessageEncoder
    Direct Known Subclasses:
    AbstractHttpClientRequestMessageEncoder, AbstractHttpServletResponseMessageEncoder

    public abstract class AbstractMessageEncoder
    extends net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
    implements MessageEncoder, net.shibboleth.utilities.java.support.component.UnmodifiableComponent
    Abstract message encoder.
    • Field Detail

      • messageContext

        @Nullable
        private MessageContext messageContext
        The message context.
    • Constructor Detail

      • AbstractMessageEncoder

        public AbstractMessageEncoder()
    • Method Detail

      • prepareContext

        public void prepareContext()
                            throws MessageEncodingException
        This method should prepare the message context by creating and populating any binding-specific data structures required in the MessageContext, prior to actually encoding.

        This method should be called after the MessageContext has been set, and before any binding-specific Handler or HandlerChains are invoked.

        Example: For a SOAP encoder, this method would create and store the basic SOAP Envelope structure in the message context, so that Handlers that are invoked have a place to which to add headers.

        This method may be a no-op if not required by the binding, or if the message type of the context implies that the binding-specific structures have already been created elsewhere (e.g. message-oriented code where the calling code already knows its SOAP, and is operating on the raw SOAP envelope anyway).

        . Default implementation is a no-op.
        Specified by:
        prepareContext in interface MessageEncoder
        Throws:
        MessageEncodingException - if there is a problem preparing the message context for encoding
      • getMessageContext

        @Nullable
        protected MessageContext getMessageContext()
        Get the message context.
        Returns:
        the message context.
      • doDestroy

        protected void doDestroy()
        Overrides:
        doDestroy in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
      • doInitialize

        protected void doInitialize()
                             throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
        Overrides:
        doInitialize in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
        Throws:
        net.shibboleth.utilities.java.support.component.ComponentInitializationException
      • doEncode

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