Class AS2ClientSettings

java.lang.Object
com.helger.as2lib.client.AS2ClientSettings

public class AS2ClientSettings extends Object
Settings object for a message delivery.
Author:
oleo Date: May 12, 2010 Time: 5:16:57 PM, Philip Helger
  • Field Details

    • DEFAULT_COMPRESS_BEFORE_SIGNING

      public static final boolean DEFAULT_COMPRESS_BEFORE_SIGNING
      If compression and signing are enabled, compression happens before singing
      See Also:
    • DEFAULT_IS_MDN_REQUESTED

      public static final boolean DEFAULT_IS_MDN_REQUESTED
      By default an MDN is requested.
      See Also:
    • DEFAULT_MDN_OPTIONS

      public static final String DEFAULT_MDN_OPTIONS
      The default MDN options to be used.
      See Also:
    • DEFAULT_MESSAGE_ID_FORMAT

      public static final String DEFAULT_MESSAGE_ID_FORMAT
      The default message ID format to use.
      See Also:
    • DEFAULT_RETRY_COUNT

      public static final int DEFAULT_RETRY_COUNT
      By default no retry happens.
      See Also:
    • DEFAULT_CONNECT_TIMEOUT

      public static final org.apache.hc.core5.util.Timeout DEFAULT_CONNECT_TIMEOUT
      Default connection timeout: 60 seconds
    • DEFAULT_RESPONSE_TIMEOUT

      public static final org.apache.hc.core5.util.Timeout DEFAULT_RESPONSE_TIMEOUT
      Default read timeout: 60 seconds
    • DEFAULT_QUOTE_HEADER_VALUES

      public static final boolean DEFAULT_QUOTE_HEADER_VALUES
      Default quote header values: false
      See Also:
  • Constructor Details

    • AS2ClientSettings

      public AS2ClientSettings()
  • Method Details

    • getKeyStoreType

      @Nonnull public final com.helger.security.keystore.IKeyStoreType getKeyStoreType()
      Returns:
      The key store type. May not be null.
      See Also:
    • getKeyStoreFile

      @Nullable public final File getKeyStoreFile()
      Returns:
      The key store file. May be null if not yet set. Either File or byte[] may be set. Never both.
      See Also:
    • getKeyStoreBytes

      @Nullable public final byte[] getKeyStoreBytes()
      Returns:
      The key store bytes. May be null if not yet set. Either File or byte[] may be set. Never both.
      Since:
      4.3.1
      See Also:
    • getKeyStorePassword

      @Nullable public final String getKeyStorePassword()
      Returns:
      The key store password. May be null if not yet set.
      See Also:
    • setKeyStore

      @Nonnull public final AS2ClientSettings setKeyStore(@Nonnull com.helger.security.keystore.IKeyStoreType aKeyStoreType, @Nonnull File aFile, @Nonnull String sPassword)
      Set the details of the certificate store of the client.
      Parameters:
      aKeyStoreType - Key store type. May not be null.
      aFile - The key store file. May not be null.
      sPassword - The password used to open the key store. May not be null.
      Returns:
      this for chaining
    • setKeyStore

      @Nonnull public final AS2ClientSettings setKeyStore(@Nonnull com.helger.security.keystore.IKeyStoreType aKeyStoreType, @Nonnull byte[] aBytes, @Nonnull String sPassword)
      Set the details of the certificate store of the client. If the keystore is provided as a byte array using this method, changes will NOT be saved.
      Parameters:
      aKeyStoreType - Key store type. May not be null.
      aBytes - The key store bytes. May not be null.
      sPassword - The password used to open the key store. May not be null.
      Returns:
      this for chaining
      Since:
      4.3.1
    • isSaveKeyStoreChangesToFile

      public final boolean isSaveKeyStoreChangesToFile()
      Returns:
      true if key store changes should be written back to the file, false if not.
    • setSaveKeyStoreChangesToFile

      @Nonnull public final AS2ClientSettings setSaveKeyStoreChangesToFile(boolean bSaveKeyStoreChangesToFile)
      Change the behavior if all changes to the keystore should trigger a saving to the original file.
      Parameters:
      bSaveKeyStoreChangesToFile - true if key store changes should be written back to the file, false if not.
      Returns:
      this for chaining
    • getSenderAS2ID

      @Nullable public final String getSenderAS2ID()
      Returns:
      The sender AS2 ID. May be null if not set.
      See Also:
    • getSenderEmailAddress

      @Nullable public final String getSenderEmailAddress()
      Returns:
      The sender's email address. May be null if not set.
      See Also:
    • getSenderKeyAlias

      @Nullable public final String getSenderKeyAlias()
      Returns:
      The senders key alias in the keystore. May be null if not set.
      See Also:
    • setSenderData

      @Nonnull public final AS2ClientSettings setSenderData(@Nonnull String sAS2ID, @Nonnull String sEmailAddress, @Nonnull String sKeyAlias)
      Set the sender data.
      Parameters:
      sAS2ID - Sender AS2 ID. May not be null.
      sEmailAddress - Sender email address. May not be null.
      sKeyAlias - Alias into the keystore for identifying the sender's key. May not be null.
      Returns:
      this for chaining
    • getReceiverAS2ID

      @Nullable public final String getReceiverAS2ID()
      Returns:
      The receiver AS2 ID. May be null if not set.
      See Also:
    • getReceiverKeyAlias

      @Nullable public final String getReceiverKeyAlias()
      Returns:
      The receivers key alias in the keystore. May be null if not set.
      See Also:
    • getDestinationAS2URL

      @Nullable public final String getDestinationAS2URL()
      Returns:
      The destination URL to send the request to. May be null if not set.
      See Also:
    • setReceiverData

      @Nonnull public final AS2ClientSettings setReceiverData(@Nonnull String sAS2ID, @Nonnull String sKeyAlias, @Nonnull String sAS2URL)
      Set the receiver data.
      Parameters:
      sAS2ID - Receiver AS2 ID. May not be null.
      sKeyAlias - Alias into the keystore for identifying the receivers certificate. May not be null.
      sAS2URL - Destination URL to send the request to. May not be null .
      Returns:
      this for chaining
    • getReceiverCertificate

      @Nullable public final X509Certificate getReceiverCertificate()
      Returns:
      The explicit certificate of the recipient. This might be used to dynamically add it to the certificate factory for dynamic partnership handling (like in PEPPOL). May be null.
      See Also:
    • setReceiverCertificate

      @Nonnull public final AS2ClientSettings setReceiverCertificate(@Nullable X509Certificate aReceiverCertificate)
      Explicitly set the receiver certificate to be used. This might be used to dynamically add it to the certificate factory for dynamic partnership handling (like in PEPPOL).
      Parameters:
      aReceiverCertificate - The receiver certificate. May be null.
      Returns:
      this for chaining
    • getCryptAlgo

      @Nullable public final ECryptoAlgorithmCrypt getCryptAlgo()
      Returns:
      The algorithm used to encrypt the message. May be null if not set.
      See Also:
    • getCryptAlgoID

      @Nullable public final String getCryptAlgoID()
      Returns:
      The ID of the algorithm used to encrypt the message. May be null if not set.
      See Also:
    • getSignAlgo

      @Nullable public final ECryptoAlgorithmSign getSignAlgo()
      Returns:
      The algorithm used to sign the message. May be null if not set.
      See Also:
    • getSignAlgoID

      @Nullable public final String getSignAlgoID()
      Returns:
      The ID of the algorithm used to sign the message. May be null if not set.
      See Also:
    • setEncryptAndSign

      @Nonnull public final AS2ClientSettings setEncryptAndSign(@Nullable ECryptoAlgorithmCrypt eCryptAlgo, @Nullable ECryptoAlgorithmSign eSignAlgo)
      Set the encryption and signing algorithms to use.
      Parameters:
      eCryptAlgo - The encryption algorithm. May be null to indicate that the message should not be encrypted.
      eSignAlgo - The signing algorithm. May be null to indicate that the message should not be signed.
      Returns:
      this for chaining.
    • getCompressionType

      @Nullable public final ECompressionType getCompressionType()
      Returns:
      The compression type used to compress the message. May be null to indicate no compression.
      See Also:
    • isCompressBeforeSigning

      public final boolean isCompressBeforeSigning()
      Check if compress before sign or sign before compress is used. This flag is only evaluated if getCompressionType() is not null.
      Returns:
      true to compress before signing, false to sign before compressing
      See Also:
    • setCompress

      @Nonnull public final AS2ClientSettings setCompress(@Nullable ECompressionType eCompressionType, boolean bCompressBeforeSigning)
      Enable or disable the compression of the message. Note: compression requires the receiver to support AS2 version 1.1!
      Parameters:
      eCompressionType - The compression type to use. Pass null to not compress the message (that is also the default).
      bCompressBeforeSigning - true to compress the data before it is signed, false to sign first and than compress the message. The default is true.
      Returns:
      this for chaining
    • getPartnershipName

      @Nullable public final String getPartnershipName()
      Returns:
      The partnership name to be used. May be null if not set.
      See Also:
    • setPartnershipName

      @Nonnull public final AS2ClientSettings setPartnershipName(@Nonnull String sPartnershipName)
      Set the name of the partnership for lookup and dynamic creation.
      Parameters:
      sPartnershipName - The partnership name. May not be null.
      Returns:
      this for chaining
    • isMDNRequested

      public final boolean isMDNRequested()
      Returns:
      true if an MDN is requested at all (sync or async), false if not.
      Since:
      4.2.0
    • setMDNRequested

      @Nonnull public final AS2ClientSettings setMDNRequested(boolean bMDNRequested)
      Determine if an MDN is requested at all.
      Parameters:
      bMDNRequested - true to request an MDN (is the default), false to not request one.
      Returns:
      this for chaining
      Since:
      4.2.0
    • getMDNOptions

      @Nullable public final String getMDNOptions()
      Get the current MDN options. Since 3.0.4 the MDN options (corresponding to the 'Disposition-Notification-Options' header) may be null.
      Returns:
      The MDN options (Disposition-Notification-Options header) to be used. May be null. The default is defined in DEFAULT_MDN_OPTIONS.
      See Also:
    • hasMDNOptions

      public final boolean hasMDNOptions()
      Returns:
      true if MDN options are specified (the default), false if not.
      Since:
      3.0.4
    • setMDNOptions

      @Nonnull public final AS2ClientSettings setMDNOptions(@Nullable String sMDNOptions)
      Set the MDN options to be used. Since 3.0.4 the MDN options (corresponding to the 'Disposition-Notification-Options' header) may be null.
      Parameters:
      sMDNOptions - The Disposition-Notification-Options String to be used. May be null.
      Returns:
      this for chaining
      See Also:
    • setMDNOptions

      @Nonnull public final AS2ClientSettings setMDNOptions(@Nonnull DispositionOptions aDispositionOptions)
      Set the MDN options to be used.
      Parameters:
      aDispositionOptions - The Disposition-Notification-Options structured object to be used. May not be null.
      Returns:
      this for chaining
      See Also:
    • getAsyncMDNUrl

      @Nullable public final String getAsyncMDNUrl()
      Returns:
      The URL for the asynchronous MDN. If this is null than a synchronous MDN is requested. By default a synchronous MDN is requested.
      Since:
      3.0.4
    • isAsyncMDNRequested

      public final boolean isAsyncMDNRequested()
      Returns:
      true if an asynchronous MDN is requested, false if not (default).
      Since:
      3.0.4
      See Also:
    • setAsyncMDNUrl

      @Nonnull public final AS2ClientSettings setAsyncMDNUrl(@Nullable String sAsyncMDNUrl)
      Set the asynchronous MDN URL to be used.
      Parameters:
      sAsyncMDNUrl - May be null in which case a synchronous MDN is requested (which is also the default).
      Returns:
      this for chaining
      Since:
      3.0.4
    • getMessageIDFormat

      @Nonnull public final String getMessageIDFormat()
      Returns:
      The message ID format to use. Never null. It defaults to "as2-lib-$date.ddMMuuuuHHmmssZ$-$rand.1234$@$msg.sender.as2_id$_$msg.receiver.as2_id$".
      See Also:
    • setMessageIDFormat

      @Nonnull public final AS2ClientSettings setMessageIDFormat(@Nonnull String sMessageIDFormat)
      Set the Message ID format. This string may contain placeholders as supported by the com.helger.as2lib.params parameters parsers.
      Parameters:
      sMessageIDFormat - The message ID format to use. May not be null.
      Returns:
      this for chaining
    • getRetryCount

      public final int getRetryCount()
      Returns:
      The number of retries to be performed. May be ≤ 0 meaning that no retry will happen. The default value is DEFAULT_RETRY_COUNT.
      See Also:
    • setRetryCount

      @Nonnull public final AS2ClientSettings setRetryCount(int nRetryCount)
      Set the retry count for sending,
      Parameters:
      nRetryCount - Sending retry count. Values ≤ 0 mean "no retry".
      Returns:
      this for chaining
      See Also:
    • getConnectTimeout

      public final org.apache.hc.core5.util.Timeout getConnectTimeout()
      Returns:
      The connection timeout. The default value is DEFAULT_CONNECT_TIMEOUT.
      Since:
      3.0.2
    • setConnectTimeout

      @Nonnull public final AS2ClientSettings setConnectTimeout(@Nonnull org.apache.hc.core5.util.Timeout aConnectTimeout)
      Set the connect timeout.
      Parameters:
      aConnectTimeout - Connect timeout. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.2
      See Also:
    • getResponseTimeout

      @Nonnull public final org.apache.hc.core5.util.Timeout getResponseTimeout()
      Returns:
      The response/read timeout. The default value is DEFAULT_RESPONSE_TIMEOUT.
      Since:
      3.0.2
    • setResponseTimeout

      @Nonnull public final AS2ClientSettings setResponseTimeout(@Nonnull org.apache.hc.core5.util.Timeout aResponseTimeout)
      Set the response/read timeout.
      Parameters:
      aResponseTimeout - Response timeout. May not be null.
      Returns:
      this for chaining
      Since:
      3.0.2
      See Also:
    • isQuoteHeaderValues

      public final boolean isQuoteHeaderValues()
      Returns:
      true if HTTP header values should be quoted according to RFC 2616, false if not.
      Since:
      4.4.2
    • setQuoteHeaderValues

      @Nonnull public final AS2ClientSettings setQuoteHeaderValues(boolean bQuoteHeaderValues)
      Set whether HTTP header values for outgoing messages should be quoted or not according to RFC 2616. By default the headers are not quoted, as this might be an interoperability issue.
      Parameters:
      bQuoteHeaderValues - true if quoting should be enabled, false if not.
      Returns:
      this for chaining
      Since:
      4.4.2
    • getHttpOutgoingDumperFactory

      @Nullable public final IHTTPOutgoingDumperFactory getHttpOutgoingDumperFactory()
      Returns:
      The outgoing dumper factory. May be null.
      Since:
      4.4.0
    • setHttpOutgoingDumperFactory

      @Nonnull public final AS2ClientSettings setHttpOutgoingDumperFactory(@Nullable IHTTPOutgoingDumperFactory aHttpOutgoingDumperFactory)
      Set the HTTP outgoing dumper factory.
      Parameters:
      aHttpOutgoingDumperFactory - The factory to be used. May be null.
      Returns:
      this for chaining
      Since:
      4.4.0
    • getHttpIncomingDumper

      @Nullable public final IHTTPIncomingDumper getHttpIncomingDumper()
      Returns:
      The incoming dumper. May be null.
      Since:
      4.4.5
    • setHttpIncomingDumper

      @Nonnull public final AS2ClientSettings setHttpIncomingDumper(@Nullable IHTTPIncomingDumper aHttpIncomingDumper)
      Set the HTTP incoming dumper.
      Parameters:
      aHttpIncomingDumper - The dumper to be used. May be null.
      Returns:
      this for chaining
      Since:
      4.4.5
    • customHeaders

      @Nonnull @ReturnsMutableObject public final com.helger.commons.http.HttpHeaderMap customHeaders()
      Returns:
      The mutable custom header map. Never null.
      Since:
      3.0.5
    • getMICMatchingHandler

      @Nullable public final IMICMatchingHandler getMICMatchingHandler()
      Returns:
      An optional MIC Matching handler. May be null.
      Since:
      4.4.5
    • setMICMatchingHandler

      @Nonnull public final AS2ClientSettings setMICMatchingHandler(@Nullable IMICMatchingHandler aMICMatchingHandler)
      Set a custom MIC matching handler
      Parameters:
      aMICMatchingHandler - The handler to be used. May be null.
      Returns:
      this for chaining
      Since:
      4.4.5
    • getVerificationCertificateConsumer

      @Nullable public final Consumer<? super X509Certificate> getVerificationCertificateConsumer()
      Returns:
      The custom verification certificate consumer to be used. May be null.
      Since:
      4.4.5
    • setVerificationCertificateConsumer

      @Nonnull public final AS2ClientSettings setVerificationCertificateConsumer(@Nullable Consumer<? super X509Certificate> aVerificationCertificateConsumer)
      Set a custom MIC matching handler
      Parameters:
      aVerificationCertificateConsumer - The factory to be used. May be null.
      Returns:
      this for chaining
      Since:
      4.4.5