Package com.helger.phase4.client
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 Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAS4Client(EAS4MessageType eMessageType, AS4ResourceHelper aResHelper) -
Method Summary
Modifier and TypeMethodDescriptionabstract AS4ClientBuiltMessagebuildMessage(String sMessageID, IAS4ClientBuildMessageCallback aCallback) Build the AS4 message to be sent.final Stringfinal AS4CryptParamsfinal IMPLTYPEEnsure the sending date time is set.final AS4ResourceHelperfinal IAS4CryptoFactoryfinal IAS4CryptoFactoryfinal IHttpPosterfinal EAS4MessageTypefinal Stringfinal OffsetDateTimefinal ESoapVersionfinal booleanfinal HttpRetrySettingsprotected IAS4CryptoFactoryprotected IAS4CryptoFactoryfinal <T> AS4ClientSentMessage<T> sendMessageWithRetries(String sURL, org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, IAS4ClientBuildMessageCallback aCallback, IAS4OutgoingDumper aOutgoingDumper, IAS4RetryCallback aRetryCallback) Send the AS4 client message created bybuildMessage(String, IAS4ClientBuildMessageCallback)to the provided URL.final IMPLTYPEsetCryptoFactory(IAS4CryptoFactory aCryptoFactory) Set all the crypto properties at once.final IMPLTYPEsetCryptoFactoryCrypt(IAS4CryptoFactory aCryptoFactoryCrypt) Set the crypto factory to be used for crypting.final IMPLTYPEsetCryptoFactorySign(IAS4CryptoFactory aCryptoFactorySign) Set the crypto factory to be used for signing.final IMPLTYPEsetHttpPoster(IHttpPoster aHttpPoster) Set the HTTP poster to be used.final IMPLTYPEsetMessageID(String sMessageID) Set a constant message IDfinal IMPLTYPEsetMessageIDFactory(Supplier<String> aMessageIDFactory) Set the factory that creates message IDs.final IMPLTYPEsetRefToMessageID(String sRefToMessageID) Set the reference to the original AS4 message.final IMPLTYPEsetSendingDateTime(OffsetDateTime aSendingDateTime) Set the sending date time of the AS4 message.final IMPLTYPEsetSoapVersion(ESoapVersion eSoapVersion) This method sets the SOAP Version.final voidsetValuesFromPMode(IPMode aPMode, PModeLeg aLeg) final AS4SigningParamsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsT
-
Constructor Details
-
AbstractAS4Client
protected AbstractAS4Client(@Nonnull EAS4MessageType eMessageType, @Nonnull @WillNotClose AS4ResourceHelper aResHelper)
-
-
Method Details
-
createDefaultMessageIDFactory
- Returns:
- The default message ID factory to be used.
- Since:
- 0.8.3
-
getMessageType
- Returns:
- The message type handled by this client. Never
null. - Since:
- 0.12.0
-
getAS4ResourceHelper
- Returns:
- The resource helper provided in the constructor. Never
null.
-
getCryptoFactorySign
- Returns:
- The currently set crypto factory for signing.
nullby default. - Since:
- 2.2.0
-
setCryptoFactorySign
Set the crypto factory to be used for signing.- Parameters:
aCryptoFactorySign- The crypto factory to be used. May benull.- Returns:
- this for chaining
- Since:
- 2.2.0
- See Also:
-
getCryptoFactoryCrypt
- Returns:
- The currently set crypto factory for crypting.
nullby 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 benull.- Returns:
- this for chaining
- Since:
- 2.2.0
- See Also:
-
setCryptoFactory
Set all the crypto properties at once.- Parameters:
aCryptoFactory- The crypto factory to be used. May benull.- Returns:
- this for chaining
-
signingParams
- Returns:
- The signing algorithm to use. Never
null. - Since:
- 0.9.0
-
cryptParams
- Returns:
- The encrypt and decrypt parameters to use. Never null
null. - Since:
- 0.9.0
-
getHttpPoster
- Returns:
- The underlying HTTP poster to use. May not be
null. - Since:
- 0.13.0
-
setHttpPoster
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 benull.- Returns:
- this for chaining
- Since:
- 0.13.0
-
getMessageIDFactory
- Returns:
- The Message ID factory to be used. May not be
null.
-
setMessageID
Set a constant message ID- Parameters:
sMessageID- Message to be used. May neither benullnor empty.- Returns:
- this for chaining
-
setMessageIDFactory
Set the factory that creates message IDs. By default a random UUID is used.- Parameters:
aMessageIDFactory- Factory to be used. May not benull.- Returns:
- this for chaining
-
createMessageID
- Returns:
- A new message ID created by the contained factory. Neither
nullnor empty.
-
getRefToMessageID
- Returns:
- The AS4 reference to the original message. My be
null.
-
hasRefToMessageID
public final boolean hasRefToMessageID()- Returns:
trueif an AS4 reference to the original message exists.
-
setRefToMessageID
Set the reference to the original AS4 message.- Parameters:
sRefToMessageID- The Message ID of the original AS4 message. May benull.- Returns:
- this for chaining
-
getSendingDateTime
- Returns:
- The sending time stamp of the message. If this is
nullthe current time should be used in the EBMS messages. - Since:
- 0.12.0
-
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
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 benull.- Returns:
- this for chaining
-
getSoapVersion
- Returns:
- The SOAP version to be used. May not be
null. - Since:
- v0.9.8
-
setSoapVersion
This method sets the SOAP Version. AS4 - Profile default is SOAP 1.2- Parameters:
eSoapVersion- SOAP version which should be set. May not benull.- Returns:
- this for chaining
- Since:
- v0.9.8
-
httpRetrySettings
- Returns:
- The HTTP retry settings to be used. Never
null. Modify the response object. - Since:
- 0.13.0
-
internalGetCryptoFactorySign
-
internalGetCryptoFactoryCrypt
-
setValuesFromPMode
-
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. Neithernullnor empty.aCallback- Optional callback for in-between states. May benull.- Returns:
- The HTTP entity to be sent. Never
null. - Throws:
IOException- in case of an IO errororg.apache.wss4j.common.ext.WSSecurityException- In case there is an issue with signing/encryptionjakarta.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 bybuildMessage(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 toaResponseHandler- The response handler that converts the HTTP response to a domain object. May not benull.aCallback- An optional callback for the different stages of building the document. May benull.aOutgoingDumper- An outgoing dumper to be used. Maybenull. Ifnullthe global outgoing dumper fromAS4DumpManageris used.aRetryCallback- An optional callback to be invoked if a retry happens on HTTP level. May benull.- Returns:
- The sent message that contains
- Throws:
IOException- in case of error when building or sending the messageorg.apache.wss4j.common.ext.WSSecurityException- In case there is an issue with signing/encryptionjakarta.mail.MessagingException- in case something happens in MIME wrapping- Since:
- 0.9.14
-