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.commons.traits.IGenericImplTrait<IMPLTYPE>
Direct Known Subclasses:
AbstractAS4ClientSignalMessage, AS4ClientUserMessage

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

  • Method Details

    • createDefaultMessageIDFactory

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

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

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

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

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

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

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

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

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

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

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

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

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

      @Nonnull public final IMPLTYPE setMessageID(@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

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

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

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

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

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

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

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

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

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

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

      @Nonnull protected IAS4CryptoFactory internalGetCryptoFactorySign()
    • internalGetCryptoFactoryCrypt

      @Nonnull protected IAS4CryptoFactory internalGetCryptoFactoryCrypt()
    • setValuesFromPMode

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

      @Nonnull public abstract AS4ClientBuiltMessage buildMessage(@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

      @Nonnull public final <T> 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