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

      public final @NonNull IAS4IncomingMessageMetadata getMessageMetadata()
      Returns:
      The incoming message metadata as provided in the constructor. Never null.
      Since:
      4.2.5 public - was protected previously
    • getCryptoFactorySign

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

      public final @NonNull 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

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

      public final @NonNull 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

      public final @NonNull 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

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

      public final @NonNull 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

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

      public final @NonNull 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

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

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

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

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

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

      public final @NonNull 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

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

      public final @NonNull 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

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

      public final @NonNull 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

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

      public final @NonNull 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

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

      public final @NonNull 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

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

      public final @NonNull 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

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

      public final <T extends IAS4IncomingMessageProcessorSPI> @NonNull 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

      public final @NonNull 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

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

      public final @NonNull 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(@WillClose @NonNull 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: