Package com.helger.as2lib.client
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 Summary
Fields Modifier and Type Field Description static booleanDEFAULT_COMPRESS_BEFORE_SIGNINGIf compression and signing are enabled, compression happens before singingstatic org.apache.hc.core5.util.TimeoutDEFAULT_CONNECT_TIMEOUTDefault connection timeout: 60 secondsstatic booleanDEFAULT_IS_MDN_REQUESTEDBy default an MDN is requested.static StringDEFAULT_MDN_OPTIONSThe default MDN options to be used.static StringDEFAULT_MESSAGE_ID_FORMATThe default message ID format to use.static booleanDEFAULT_QUOTE_HEADER_VALUESDefault quote header values: falsestatic org.apache.hc.core5.util.TimeoutDEFAULT_RESPONSE_TIMEOUTDefault read timeout: 60 secondsstatic intDEFAULT_RETRY_COUNTBy default no retry happens.
-
Constructor Summary
Constructors Constructor Description AS2ClientSettings()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.helger.commons.http.HttpHeaderMapcustomHeaders()StringgetAsyncMDNUrl()ECompressionTypegetCompressionType()org.apache.hc.core5.util.TimeoutgetConnectTimeout()ECryptoAlgorithmCryptgetCryptAlgo()StringgetCryptAlgoID()StringgetDestinationAS2URL()IHTTPIncomingDumpergetHttpIncomingDumper()IHTTPOutgoingDumperFactorygetHttpOutgoingDumperFactory()byte[]getKeyStoreBytes()FilegetKeyStoreFile()StringgetKeyStorePassword()com.helger.security.keystore.IKeyStoreTypegetKeyStoreType()StringgetMDNOptions()Get the current MDN options.StringgetMessageIDFormat()IMICMatchingHandlergetMICMatchingHandler()StringgetPartnershipName()StringgetReceiverAS2ID()X509CertificategetReceiverCertificate()StringgetReceiverKeyAlias()org.apache.hc.core5.util.TimeoutgetResponseTimeout()intgetRetryCount()StringgetSenderAS2ID()StringgetSenderEmailAddress()StringgetSenderKeyAlias()ECryptoAlgorithmSigngetSignAlgo()StringgetSignAlgoID()Consumer<? super X509Certificate>getVerificationCertificateConsumer()booleanhasMDNOptions()booleanisAsyncMDNRequested()booleanisCompressBeforeSigning()Check if compress before sign or sign before compress is used.booleanisMDNRequested()booleanisQuoteHeaderValues()booleanisSaveKeyStoreChangesToFile()AS2ClientSettingssetAsyncMDNUrl(String sAsyncMDNUrl)Set the asynchronous MDN URL to be used.AS2ClientSettingssetCompress(ECompressionType eCompressionType, boolean bCompressBeforeSigning)Enable or disable the compression of the message.AS2ClientSettingssetConnectTimeout(org.apache.hc.core5.util.Timeout aConnectTimeout)Set the connect timeout.AS2ClientSettingssetEncryptAndSign(ECryptoAlgorithmCrypt eCryptAlgo, ECryptoAlgorithmSign eSignAlgo)Set the encryption and signing algorithms to use.AS2ClientSettingssetHttpIncomingDumper(IHTTPIncomingDumper aHttpIncomingDumper)Set the HTTP incoming dumper.AS2ClientSettingssetHttpOutgoingDumperFactory(IHTTPOutgoingDumperFactory aHttpOutgoingDumperFactory)Set the HTTP outgoing dumper factory.AS2ClientSettingssetKeyStore(com.helger.security.keystore.IKeyStoreType aKeyStoreType, byte[] aBytes, String sPassword)Set the details of the certificate store of the client.AS2ClientSettingssetKeyStore(com.helger.security.keystore.IKeyStoreType aKeyStoreType, File aFile, String sPassword)Set the details of the certificate store of the client.AS2ClientSettingssetMDNOptions(DispositionOptions aDispositionOptions)Set the MDN options to be used.AS2ClientSettingssetMDNOptions(String sMDNOptions)Set the MDN options to be used.AS2ClientSettingssetMDNRequested(boolean bMDNRequested)Determine if an MDN is requested at all.AS2ClientSettingssetMessageIDFormat(String sMessageIDFormat)Set the Message ID format.AS2ClientSettingssetMICMatchingHandler(IMICMatchingHandler aMICMatchingHandler)Set a custom MIC matching handlerAS2ClientSettingssetPartnershipName(String sPartnershipName)Set the name of the partnership for lookup and dynamic creation.AS2ClientSettingssetQuoteHeaderValues(boolean bQuoteHeaderValues)Set whether HTTP header values for outgoing messages should be quoted or not according to RFC 2616.AS2ClientSettingssetReceiverCertificate(X509Certificate aReceiverCertificate)Explicitly set the receiver certificate to be used.AS2ClientSettingssetReceiverData(String sAS2ID, String sKeyAlias, String sAS2URL)Set the receiver data.AS2ClientSettingssetResponseTimeout(org.apache.hc.core5.util.Timeout aResponseTimeout)Set the response/read timeout.AS2ClientSettingssetRetryCount(int nRetryCount)Set the retry count for sending,AS2ClientSettingssetSaveKeyStoreChangesToFile(boolean bSaveKeyStoreChangesToFile)Change the behavior if all changes to the keystore should trigger a saving to the original file.AS2ClientSettingssetSenderData(String sAS2ID, String sEmailAddress, String sKeyAlias)Set the sender data.AS2ClientSettingssetVerificationCertificateConsumer(Consumer<? super X509Certificate> aVerificationCertificateConsumer)Set a custom MIC matching handler
-
-
-
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_MDN_OPTIONS
public static final String DEFAULT_MDN_OPTIONS
The default MDN options to be used.- See Also:
setMDNOptions(DispositionOptions)
-
DEFAULT_MESSAGE_ID_FORMAT
public static final String DEFAULT_MESSAGE_ID_FORMAT
The default message ID format to use.- See Also:
setMessageIDFormat(String), 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
-
-
Method Detail
-
getKeyStoreType
@Nonnull public final com.helger.security.keystore.IKeyStoreType getKeyStoreType()
- Returns:
- The key store type. May not be
null. - See Also:
setKeyStore(IKeyStoreType, File, String),setKeyStore(IKeyStoreType, byte[], String)
-
getKeyStoreFile
@Nullable public final File getKeyStoreFile()
- Returns:
- The key store file. May be
nullif not yet set. Either File or byte[] may be set. Never both. - See Also:
setKeyStore(IKeyStoreType, File, String)
-
getKeyStoreBytes
@Nullable public final byte[] getKeyStoreBytes()
- Returns:
- The key store bytes. May be
nullif not yet set. Either File or byte[] may be set. Never both. - Since:
- 4.3.1
- See Also:
setKeyStore(IKeyStoreType, byte[], String)
-
getKeyStorePassword
@Nullable public final String getKeyStorePassword()
- Returns:
- The key store password. May be
nullif not yet set. - See Also:
setKeyStore(IKeyStoreType, File, String),setKeyStore(IKeyStoreType, byte[], String)
-
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 benull.aFile- The key store file. May not benull.sPassword- The password used to open the key store. May not benull.- 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 benull.aBytes- The key store bytes. May not benull.sPassword- The password used to open the key store. May not benull.- Returns:
- this for chaining
- Since:
- 4.3.1
-
isSaveKeyStoreChangesToFile
public final boolean isSaveKeyStoreChangesToFile()
- Returns:
trueif key store changes should be written back to the file,falseif 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-trueif key store changes should be written back to the file,falseif not.- Returns:
- this for chaining
-
getSenderAS2ID
@Nullable public final String getSenderAS2ID()
- Returns:
- The sender AS2 ID. May be
nullif not set. - See Also:
setSenderData(String, String, String)
-
getSenderEmailAddress
@Nullable public final String getSenderEmailAddress()
- Returns:
- The sender's email address. May be
nullif not set. - See Also:
setSenderData(String, String, String)
-
getSenderKeyAlias
@Nullable public final String getSenderKeyAlias()
- Returns:
- The senders key alias in the keystore. May be
nullif not set. - See Also:
setSenderData(String, String, String),setKeyStore(IKeyStoreType, File, String)
-
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 benull.sEmailAddress- Sender email address. May not benull.sKeyAlias- Alias into the keystore for identifying the sender's key. May not benull.- Returns:
- this for chaining
-
getReceiverAS2ID
@Nullable public final String getReceiverAS2ID()
- Returns:
- The receiver AS2 ID. May be
nullif not set. - See Also:
setReceiverData(String, String, String)
-
getReceiverKeyAlias
@Nullable public final String getReceiverKeyAlias()
- Returns:
- The receivers key alias in the keystore. May be
nullif not set. - See Also:
setReceiverData(String, String, String),setKeyStore(IKeyStoreType, File, String)
-
getDestinationAS2URL
@Nullable public final String getDestinationAS2URL()
- Returns:
- The destination URL to send the request to. May be
nullif not set. - See Also:
setReceiverData(String, String, String)
-
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 benull.sKeyAlias- Alias into the keystore for identifying the receivers certificate. May not benull.sAS2URL- Destination URL to send the request to. May not benull.- 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 benull.- Returns:
- this for chaining
-
getCryptAlgo
@Nullable public final ECryptoAlgorithmCrypt getCryptAlgo()
- Returns:
- The algorithm used to encrypt the message. May be
nullif not set. - See Also:
setEncryptAndSign(ECryptoAlgorithmCrypt, ECryptoAlgorithmSign)
-
getCryptAlgoID
@Nullable public final String getCryptAlgoID()
- Returns:
- The ID of the algorithm used to encrypt the message. May be
nullif not set. - See Also:
setEncryptAndSign(ECryptoAlgorithmCrypt, ECryptoAlgorithmSign)
-
getSignAlgo
@Nullable public final ECryptoAlgorithmSign getSignAlgo()
- Returns:
- The algorithm used to sign the message. May be
nullif not set. - See Also:
setEncryptAndSign(ECryptoAlgorithmCrypt, ECryptoAlgorithmSign)
-
getSignAlgoID
@Nullable public final String getSignAlgoID()
- Returns:
- The ID of the algorithm used to sign the message. May be
nullif not set. - See Also:
setEncryptAndSign(ECryptoAlgorithmCrypt, ECryptoAlgorithmSign)
-
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 benullto indicate that the message should not be encrypted.eSignAlgo- The signing algorithm. May benullto 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
nullto indicate no compression. - See Also:
setCompress(ECompressionType, boolean)
-
isCompressBeforeSigning
public final boolean isCompressBeforeSigning()
Check if compress before sign or sign before compress is used. This flag is only evaluated ifgetCompressionType()is notnull.- Returns:
trueto compress before signing,falseto 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. Passnullto not compress the message (that is also the default).bCompressBeforeSigning-trueto compress the data before it is signed,falseto sign first and than compress the message. The default istrue.- Returns:
- this for chaining
-
getPartnershipName
@Nullable public final String getPartnershipName()
- Returns:
- The partnership name to be used. May be
nullif not set. - See Also:
setPartnershipName(String)
-
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 benull.- Returns:
- this for chaining
-
isMDNRequested
public final boolean isMDNRequested()
- Returns:
trueif an MDN is requested at all (sync or async),falseif not.- Since:
- 4.2.0
-
setMDNRequested
@Nonnull public final AS2ClientSettings setMDNRequested(boolean bMDNRequested)
Determine if an MDN is requested at all.- Parameters:
bMDNRequested-trueto request an MDN (is the default),falseto 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 benull.- Returns:
- The MDN options (
Disposition-Notification-Optionsheader) to be used. May benull. The default is defined inDEFAULT_MDN_OPTIONS. - See Also:
setMDNOptions(DispositionOptions),setMDNOptions(String)
-
hasMDNOptions
public final boolean hasMDNOptions()
- Returns:
trueif MDN options are specified (the default),falseif 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 benull.- Parameters:
sMDNOptions- TheDisposition-Notification-OptionsString to be used. May benull.- Returns:
- this for chaining
- See Also:
setMDNOptions(DispositionOptions)
-
setMDNOptions
@Nonnull public final AS2ClientSettings setMDNOptions(@Nonnull DispositionOptions aDispositionOptions)
Set the MDN options to be used.- Parameters:
aDispositionOptions- TheDisposition-Notification-Optionsstructured object to be used. May not benull.- Returns:
- this for chaining
- See Also:
setMDNOptions(String)
-
getAsyncMDNUrl
@Nullable public final String getAsyncMDNUrl()
- Returns:
- The URL for the asynchronous MDN. If this is
nullthan a synchronous MDN is requested. By default a synchronous MDN is requested. - Since:
- 3.0.4
-
isAsyncMDNRequested
public final boolean isAsyncMDNRequested()
- Returns:
trueif an asynchronous MDN is requested,falseif 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 benullin 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:
DEFAULT_MESSAGE_ID_FORMAT,setMessageIDFormat(String)
-
setMessageIDFormat
@Nonnull public final AS2ClientSettings setMessageIDFormat(@Nonnull String sMessageIDFormat)
Set the Message ID format. This string may contain placeholders as supported by thecom.helger.as2lib.paramsparameters parsers.- Parameters:
sMessageIDFormat- The message ID format to use. May not benull.- 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 benull.- 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 benull.- Returns:
- this for chaining
- Since:
- 3.0.2
- See Also:
getResponseTimeout()
-
isQuoteHeaderValues
public final boolean isQuoteHeaderValues()
- Returns:
trueif HTTP header values should be quoted according to RFC 2616,falseif 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-trueif quoting should be enabled,falseif 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 benull.- 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 benull.- 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 benull.- 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 benull.- Returns:
- this for chaining
- Since:
- 4.4.5
-
-