Class AS4RequestHandler

java.lang.Object
com.helger.phase4.incoming.AS4RequestHandler
All Implemented Interfaces:
AutoCloseable

@NotThreadSafe public class AS4RequestHandler extends Object implements AutoCloseable
Process incoming AS4 transmissions. This class is responsible for handling data in a provider independent way (so e.g. not Servlet specific), only based on InputStream and OutputStream. For each incoming request, a new instance of this class is created.
Author:
Martin Bayerl, Philip Helger
  • Field Details

  • Constructor Details

  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getMessageMetadata

      @Nonnull protected final IAS4IncomingMessageMetadata getMessageMetadata()
      Returns:
      The incoming message metadata as provided in the constructor. Never null.
    • getCryptoFactorySign

      @Nullable public final IAS4CryptoFactory getCryptoFactorySign()
      Returns:
      The IAS4CryptoFactory for signing. May be null if not initialized.
      Since:
      3.0.0
      See Also:
    • setCryptoFactorySign

      @Nonnull public final AS4RequestHandler setCryptoFactorySign(@Nonnull IAS4CryptoFactory aCryptoFactorySign)
      Set the crypto factory for signing.
      Parameters:
      aCryptoFactorySign - Crypto factory for signing to use. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.0
      See Also:
    • getCryptoFactoryCrypt

      @Nullable public final IAS4CryptoFactory getCryptoFactoryCrypt()
      Returns:
      The IAS4CryptoFactory for crypting. May be null if not initialized.
      Since:
      3.0.0
      See Also:
    • setCryptoFactoryCrypt

      @Nonnull public final AS4RequestHandler setCryptoFactoryCrypt(@Nonnull IAS4CryptoFactory aCryptoFactoryCrypt)
      Set the crypto factory crypting.
      Parameters:
      aCryptoFactoryCrypt - Crypto factory for crypting to use. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.0
      See Also:
    • setCryptoFactory

      @Nonnull public final AS4RequestHandler setCryptoFactory(@Nonnull IAS4CryptoFactory aCryptoFactory)
      Set the same crypto factory for signing and crypting. This is a sanity wrapper around setCryptoFactory(IAS4CryptoFactory).
      Parameters:
      aCryptoFactory - Crypto factory to use. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.0
      See Also:
    • getPModeResolver

      @Nullable public final IAS4PModeResolver getPModeResolver()
      Returns:
      The IAS4PModeResolver to be used. May be null if not initialized.
      Since:
      3.0.0
    • setPModeResolver

      @Nonnull public final AS4RequestHandler setPModeResolver(@Nonnull IAS4PModeResolver aPModeResolver)
      Parameters:
      aPModeResolver - PMode resolved to be used. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.0
    • getIncomingAttachmentFactory

      @Nullable public final IAS4IncomingAttachmentFactory getIncomingAttachmentFactory()
      Returns:
      The IAS4IncomingAttachmentFactory to be used. May be null if not initialized.
      Since:
      3.0.0
    • setIncomingAttachmentFactory

      @Nonnull public final AS4RequestHandler setIncomingAttachmentFactory(@Nonnull IAS4IncomingAttachmentFactory aIAF)
      Parameters:
      aIAF - The attachment factory for incoming attachments. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.0
    • getIncomingSecurityConfiguration

      @Nullable public final IAS4IncomingSecurityConfiguration getIncomingSecurityConfiguration()
      Returns:
      The IAS4IncomingSecurityConfiguration to be used. May be null if not initialized.
      Since:
      3.0.0
    • setIncomingSecurityConfiguration

      @Nonnull public final AS4RequestHandler setIncomingSecurityConfiguration(@Nonnull IAS4IncomingSecurityConfiguration aICS)
      Parameters:
      aICS - The incoming security configuration. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.0
    • getIncomingReceiverConfiguration

      @Nullable public final IAS4IncomingReceiverConfiguration getIncomingReceiverConfiguration()
      Returns:
      The IAS4IncomingReceiverConfiguration to be used. May be null if not initialized.
      Since:
      3.0.0
    • setIncomingReceiverConfiguration

      @Nonnull public final AS4RequestHandler setIncomingReceiverConfiguration(@Nonnull IAS4IncomingReceiverConfiguration aIRC)
      Parameters:
      aIRC - The incoming receiver configuration. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.0
    • getIncomingProfileSelector

      @Nonnull public final IAS4IncomingProfileSelector getIncomingProfileSelector()
      Returns:
      The current AS4 profile selector for incoming messages. Never null.
      Since:
      0.13.0
    • setIncomingProfileSelector

      @Nonnull public final AS4RequestHandler setIncomingProfileSelector(@Nonnull IAS4IncomingProfileSelector aIncomingProfileSelector)
      Set the AS4 profile selector for incoming messages.
      Parameters:
      aIncomingProfileSelector - The new profile selector to be used. May not be null.
      Returns:
      this for chaining
      Since:
      0.13.0
    • getLocale

      @Nonnull public final Locale getLocale()
      Returns:
      The locale for error messages. Never null.
    • setLocale

      @Nonnull public final AS4RequestHandler setLocale(@Nonnull Locale aLocale)
      Set the error for EBMS error messages.
      Parameters:
      aLocale - The locale. May not be null.
      Returns:
      this for chaining
    • getIncomingDumper

      @Nullable public final IAS4IncomingDumper getIncomingDumper()
      Returns:
      The specific dumper for incoming messages. May be null.
      Since:
      v0.9.7
    • setIncomingDumper

      @Nonnull public final AS4RequestHandler setIncomingDumper(@Nullable IAS4IncomingDumper aIncomingDumper)
      Set the specific dumper for incoming messages. If none is set, the global incoming dumper is used.
      Parameters:
      aIncomingDumper - The specific incoming dumper. May be null.
      Returns:
      this for chaining
      Since:
      v0.9.7
    • getOutgoingDumper

      @Nullable public final IAS4OutgoingDumper getOutgoingDumper()
      Returns:
      The specific dumper for outgoing messages. May be null.
      Since:
      v0.9.9
    • setOutgoingDumper

      @Nonnull public final AS4RequestHandler setOutgoingDumper(@Nullable IAS4OutgoingDumper aOutgoingDumper)
      Set the specific dumper for outgoing messages. If none is set, the global outgoing dumper is used.
      Parameters:
      aOutgoingDumper - The specific outgoing dumper. May be null.
      Returns:
      this for chaining
      Since:
      v0.9.9
    • getRetryCallback

      @Nullable public final IAS4RetryCallback getRetryCallback()
      Returns:
      The HTTP retry callback for outgoing messages. May be null.
      Since:
      v0.9.14
    • setRetryCallback

      @Nonnull public final AS4RequestHandler setRetryCallback(@Nullable IAS4RetryCallback aRetryCallback)
      Set the HTTP retry callback for outgoing messages.
      Parameters:
      aRetryCallback - The specific retry callback. May be null.
      Returns:
      this for chaining
      Since:
      v0.9.14
    • getSoapProcessingFinalizedCallback

      @Nullable public final IAS4SoapProcessingFinalizedCallback getSoapProcessingFinalizedCallback()
      Returns:
      The internal SOAP processing finalized callback. null by default.
      Since:
      0.13.1
    • setSoapProcessingFinalizedCallback

      @Nonnull public final AS4RequestHandler setSoapProcessingFinalizedCallback(@Nullable IAS4SoapProcessingFinalizedCallback aSoapProcessingFinalizedCB)
      Set the internal SOAP processing finalized callback. Only use when you know what you are doing. This callback is invoked both in the synchronous AND the asynchronous processing. A simple way to await the finalization could e.g. be a java.util.concurrent.CountDownLatch.
      Parameters:
      aSoapProcessingFinalizedCB - The callback to be invoked. May be null. Only non-null callbacks are invoked ;-)
      Returns:
      this for chaining
      Since:
      0.13.1
    • getProcessorSupplier

      @Nonnull public final Supplier<? extends com.helger.collection.commons.ICommonsList<IAS4IncomingMessageProcessorSPI>> getProcessorSupplier()
      Returns:
      The supplier used to get all SPIs. By default this is AS4IncomingMessageProcessorManager.getAllProcessors().
    • getProcessorOfType

      @Nonnull public final <T extends IAS4IncomingMessageProcessorSPI> T getProcessorOfType(@Nonnull Class<T> aTargetClass)
      Find the message processor of the specified type.
      Parameters:
      aTargetClass - The target processor class to search.
      Returns:
      null if no such processor was found
      Since:
      2.8.2
    • setProcessorSupplier

      @Nonnull public final AS4RequestHandler setProcessorSupplier(@Nonnull Supplier<? extends com.helger.collection.commons.ICommonsList<IAS4IncomingMessageProcessorSPI>> aProcessorSupplier)
      Set a different processor supplier
      Parameters:
      aProcessorSupplier - The processor supplier to be used. May not be null.
      Returns:
      this for chaining
    • getErrorConsumer

      @Nullable public final IAS4RequestHandlerErrorConsumer getErrorConsumer()
      Returns:
      An optional error consumer. null by default.
      Since:
      0.9.7
    • setErrorConsumer

      @Nonnull public final AS4RequestHandler setErrorConsumer(@Nullable IAS4RequestHandlerErrorConsumer aErrorConsumer)
      Set an optional error consumer that is invoked with all errors determined during message processing. The consumed list MUST NOT be modified.
      Note: the error consumer is ONLY called if the error list is non-empty.
      Note: the AS4 error message is sent back automatically - this is just informational.
      Parameters:
      aErrorConsumer - The consumer to be used. May be null.
      Returns:
      this for chaining
      Since:
      0.9.7
    • handleRequest

      public void handleRequest(@Nonnull @WillClose InputStream aRequestInputStream, @Nonnull com.helger.http.header.HttpHeaderMap aRequestHttpHeaders, @Nonnull IAS4ResponseAbstraction aHttpResponse) throws Phase4Exception, IOException, jakarta.mail.MessagingException, org.apache.wss4j.common.ext.WSSecurityException
      This is the main handling routine when called from an abstract (non-Servlet) API
      Parameters:
      aRequestInputStream - The input stream with the raw AS4 request data. May not be null.
      aRequestHttpHeaders - The HTTP headers of the request. May not be null.
      aHttpResponse - The AS4 response abstraction to be filled. May not be null.
      Throws:
      Phase4Exception - in case the request is missing certain prerequisites. Since 0.9.11
      IOException - In case of IO errors
      jakarta.mail.MessagingException - MIME related errors
      org.apache.wss4j.common.ext.WSSecurityException - In case of WSS4J errors
      See Also: