Class AbstractAS4Client<IMPLTYPE extends AbstractAS4Client<IMPLTYPE>>

java.lang.Object
com.helger.phase4.client.AbstractAS4Client<IMPLTYPE>
Type Parameters:
IMPLTYPE - Implementation type
All Implemented Interfaces:
com.helger.base.trait.IGenericImplTrait<IMPLTYPE>
Direct Known Subclasses:
AbstractAS4ClientSignalMessage, AS4ClientUserMessage

public abstract class AbstractAS4Client<IMPLTYPE extends AbstractAS4Client<IMPLTYPE>> extends Object implements com.helger.base.trait.IGenericImplTrait<IMPLTYPE>
Abstract AS4 client based on HTTP client
Author:
Philip Helger
  • Constructor Details

  • Method Details

    • createDefaultMessageIDFactory

      public static @NonNull Supplier<String> createDefaultMessageIDFactory()
      Returns:
      The default message ID factory to be used.
      Since:
      0.8.3
    • getMessageType

      public final @NonNull EAS4MessageType getMessageType()
      Returns:
      The message type handled by this client. Never null.
      Since:
      0.12.0
    • getAS4ResourceHelper

      public final @NonNull AS4ResourceHelper getAS4ResourceHelper()
      Returns:
      The resource helper provided in the constructor. Never null.
    • getCryptoFactorySign

      public final @Nullable IAS4CryptoFactory getCryptoFactorySign()
      Returns:
      The currently set crypto factory for signing. null by default.
      Since:
      2.2.0
    • setCryptoFactorySign

      public final @NonNull IMPLTYPE setCryptoFactorySign(@Nullable IAS4CryptoFactory aCryptoFactorySign)
      Set the crypto factory to be used for signing.
      Parameters:
      aCryptoFactorySign - The crypto factory to be used. May be null.
      Returns:
      this for chaining
      Since:
      2.2.0
      See Also:
    • getCryptoFactoryCrypt

      public final @Nullable IAS4CryptoFactory getCryptoFactoryCrypt()
      Returns:
      The currently set crypto factory for crypting. null by default.
      Since:
      2.2.0
    • setCryptoFactoryCrypt

      public final @NonNull IMPLTYPE setCryptoFactoryCrypt(@Nullable IAS4CryptoFactory aCryptoFactoryCrypt)
      Set the crypto factory to be used for crypting.
      Parameters:
      aCryptoFactoryCrypt - The crypto factory to be used. May be null.
      Returns:
      this for chaining
      Since:
      2.2.0
      See Also:
    • setCryptoFactory

      public final @NonNull IMPLTYPE setCryptoFactory(@Nullable IAS4CryptoFactory aCryptoFactory)
      Set all the crypto properties at once.
      Parameters:
      aCryptoFactory - The crypto factory to be used. May be null.
      Returns:
      this for chaining
    • signingParams

      @ReturnsMutableObject public final @NonNull AS4SigningParams signingParams()
      Returns:
      The signing algorithm to use. Never null.
      Since:
      0.9.0
    • cryptParams

      @ReturnsMutableObject public final @NonNull AS4CryptParams cryptParams()
      Returns:
      The encrypt and decrypt parameters to use. Never null null.
      Since:
      0.9.0
    • getHttpPoster

      public final @NonNull IHttpPoster getHttpPoster()
      Returns:
      The underlying HTTP poster to use. May not be null.
      Since:
      0.13.0
    • setHttpPoster

      public final @NonNull IMPLTYPE setHttpPoster(@NonNull IHttpPoster aHttpPoster)
      Set the HTTP poster to be used. This is the instance that is responsible for the HTTP transmission of the AS4 messages.
      Parameters:
      aHttpPoster - Instance to be used. May not be null.
      Returns:
      this for chaining
      Since:
      0.13.0
    • getMessageIDFactory

      public final @NonNull Supplier<String> getMessageIDFactory()
      Returns:
      The Message ID factory to be used. May not be null.
    • setMessageID

      public final @NonNull IMPLTYPE setMessageID(@Nonempty @NonNull @Nonempty String sMessageID)
      Set a constant message ID
      Parameters:
      sMessageID - Message to be used. May neither be null nor empty.
      Returns:
      this for chaining
    • setMessageIDFactory

      public final @NonNull IMPLTYPE setMessageIDFactory(@NonNull Supplier<String> aMessageIDFactory)
      Set the factory that creates message IDs. By default a random UUID is used.
      Parameters:
      aMessageIDFactory - Factory to be used. May not be null.
      Returns:
      this for chaining
    • createMessageID

      @Nonempty public final @NonNull @Nonempty String createMessageID()
      Returns:
      A new message ID created by the contained factory. Neither null nor empty.
    • getRefToMessageID

      public final @Nullable String getRefToMessageID()
      Returns:
      The AS4 reference to the original message. My be null.
    • hasRefToMessageID

      public final boolean hasRefToMessageID()
      Returns:
      true if an AS4 reference to the original message exists.
    • setRefToMessageID

      public final @NonNull IMPLTYPE setRefToMessageID(@Nullable String sRefToMessageID)
      Set the reference to the original AS4 message.
      Parameters:
      sRefToMessageID - The Message ID of the original AS4 message. May be null.
      Returns:
      this for chaining
    • getSendingDateTime

      public final @Nullable OffsetDateTime getSendingDateTime()
      Returns:
      The sending time stamp of the message. If this is null the current time should be used in the EBMS messages.
      Since:
      0.12.0
    • ensureSendingDateTime

      public final @NonNull IMPLTYPE ensureSendingDateTime()
      Ensure the sending date time is set. If it is already set, nothing happens, else it is set to the current point in time.
      Returns:
      this for chaining Never null.
      Since:
      2.2.2
    • setSendingDateTime

      public final @NonNull IMPLTYPE setSendingDateTime(@Nullable OffsetDateTime aSendingDateTime)
      Set the sending date time of the AS4 message. If not set, the current point in time will be used onwards.
      Parameters:
      aSendingDateTime - The sending date time to be used. May be null.
      Returns:
      this for chaining
    • getSoapVersion

      public final @NonNull ESoapVersion getSoapVersion()
      Returns:
      The SOAP version to be used. May not be null.
      Since:
      v0.9.8
    • setSoapVersion

      public final @NonNull IMPLTYPE setSoapVersion(@NonNull ESoapVersion eSoapVersion)
      This method sets the SOAP Version. AS4 - Profile default is SOAP 1.2
      Parameters:
      eSoapVersion - SOAP version which should be set. May not be null.
      Returns:
      this for chaining
      Since:
      v0.9.8
    • httpRetrySettings

      public final @NonNull HttpRetrySettings httpRetrySettings()
      Returns:
      The HTTP retry settings to be used. Never null. Modify the response object.
      Since:
      0.13.0
    • internalGetCryptoFactorySign

      protected @NonNull IAS4CryptoFactory internalGetCryptoFactorySign()
    • internalGetCryptoFactoryCrypt

      protected @NonNull IAS4CryptoFactory internalGetCryptoFactoryCrypt()
    • setValuesFromPMode

      public final void setValuesFromPMode(@Nullable IPMode aPMode, @Nullable PModeLeg aLeg)
    • buildMessage

      public abstract @NonNull AS4ClientBuiltMessage buildMessage(@Nonempty @NonNull @Nonempty String sMessageID, @Nullable IAS4ClientBuildMessageCallback aCallback) throws IOException, org.apache.wss4j.common.ext.WSSecurityException, jakarta.mail.MessagingException
      Build the AS4 message to be sent. It uses all the attributes of this class to build the final message. Compression, signing and encryption happens in this methods.
      Parameters:
      sMessageID - The message ID to be used. Neither null nor empty.
      aCallback - Optional callback for in-between states. May be null.
      Returns:
      The HTTP entity to be sent. Never null.
      Throws:
      IOException - in case of an IO error
      org.apache.wss4j.common.ext.WSSecurityException - In case there is an issue with signing/encryption
      jakarta.mail.MessagingException - in case something happens in MIME wrapping
    • sendMessageWithRetries

      public final <T> @NonNull AS4ClientSentMessage<T> sendMessageWithRetries(@NonNull String sURL, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, @Nullable IAS4ClientBuildMessageCallback aCallback, @Nullable IAS4OutgoingDumper aOutgoingDumper, @Nullable IAS4RetryCallback aRetryCallback) throws IOException, org.apache.wss4j.common.ext.WSSecurityException, jakarta.mail.MessagingException
      Send the AS4 client message created by buildMessage(String, IAS4ClientBuildMessageCallback) to the provided URL. This methods does take retries into account. It synchronously handles the retries and only returns after the last retry.
      Type Parameters:
      T - The response data type
      Parameters:
      sURL - The URL to send the HTTP POST to
      aResponseHandler - The response handler that converts the HTTP response to a domain object. May not be null.
      aCallback - An optional callback for the different stages of building the document. May be null.
      aOutgoingDumper - An outgoing dumper to be used. Maybe null. If null the global outgoing dumper from AS4DumpManager is used.
      aRetryCallback - An optional callback to be invoked if a retry happens on HTTP level. May be null.
      Returns:
      The sent message that contains
      Throws:
      IOException - in case of error when building or sending the message
      org.apache.wss4j.common.ext.WSSecurityException - In case there is an issue with signing/encryption
      jakarta.mail.MessagingException - in case something happens in MIME wrapping
      Since:
      0.9.14