Class 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 Detail

      • DEFAULT_COMPRESS_BEFORE_SIGNING

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

        public static final boolean DEFAULT_IS_MDN_REQUESTED
        By default an MDN is requested.
        See Also:
        Constant Field Values
      • DEFAULT_RETRY_COUNT

        public static final int DEFAULT_RETRY_COUNT
        By default no retry happens.
        See Also:
        Constant Field Values
      • 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:
        Constant Field Values
    • Constructor Detail

      • AS2ClientSettings

        public AS2ClientSettings()
    • Method Detail

      • 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
      • 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
      • 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(X509Certificate)
      • 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
      • 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.
      • 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(ECompressionType, boolean)
      • 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
      • 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
      • 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(DispositionOptions)
      • 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:
        getAsyncMDNUrl()
      • 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
      • 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(int)
      • 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:
        getRetryCount()
      • 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:
        getConnectTimeout()
      • 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:
        getResponseTimeout()
      • 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