Package com.helger.phase4.peppol
Class Phase4PeppolSender.AbstractPeppolUserMessageBuilder<IMPLTYPE extends Phase4PeppolSender.AbstractPeppolUserMessageBuilder<IMPLTYPE>>
java.lang.Object
com.helger.phase4.sender.AbstractAS4MessageBuilder<IMPLTYPE>
com.helger.phase4.sender.AbstractAS4UserMessageBuilder<IMPLTYPE>
com.helger.phase4.sender.AbstractAS4UserMessageBuilderMIMEPayload<IMPLTYPE>
com.helger.phase4.peppol.Phase4PeppolSender.AbstractPeppolUserMessageBuilder<IMPLTYPE>
- Type Parameters:
IMPLTYPE- The implementation type
- All Implemented Interfaces:
com.helger.base.trait.IGenericImplTrait<IMPLTYPE>
- Direct Known Subclasses:
Phase4PeppolSender.PeppolUserMessageBuilder,Phase4PeppolSender.PeppolUserMessageSBDHBuilder
- Enclosing class:
Phase4PeppolSender
@NotThreadSafe
public abstract static class Phase4PeppolSender.AbstractPeppolUserMessageBuilder<IMPLTYPE extends Phase4PeppolSender.AbstractPeppolUserMessageBuilder<IMPLTYPE>>
extends com.helger.phase4.sender.AbstractAS4UserMessageBuilderMIMEPayload<IMPLTYPE>
Abstract builder base class with the minimum requirements configuration
- Since:
- 0.9.6
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final booleanprotected com.helger.security.certificate.TrustedCACheckerprotected com.helger.peppolid.IDocumentTypeIdentifierprotected com.helger.phase4.dynamicdiscovery.IAS4EndpointDetailProviderprotected com.helger.mime.IMimeTypeprotected com.helger.peppolid.IProcessIdentifierprotected com.helger.peppolid.IParticipantIdentifierprotected com.helger.peppolid.IParticipantIdentifierprotected booleanprotected Stringprotected StringFields inherited from class com.helger.phase4.sender.AbstractAS4UserMessageBuilderMIMEPayload
m_aPayloadFields inherited from class com.helger.phase4.sender.AbstractAS4UserMessageBuilder
m_aAttachments, m_aMessageProperties, m_aPMode, m_aSignalMsgConsumer, m_aSignalMsgValidationResultHdl, m_bForceMimeMessage, m_sAction, m_sAgreementRef, m_sAgreementType, m_sConversationID, m_sEndpointURL, m_sFromPartyID, m_sFromPartyIDType, m_sFromRole, m_sPModeID, m_sService, m_sServiceType, m_sToPartyID, m_sToPartyIDType, m_sToRoleFields inherited from class com.helger.phase4.sender.AbstractAS4MessageBuilder
DEFAULT_LOCALE, m_aBuildMessageCallback, m_aCryptoFactoryCrypt, m_aCryptoFactorySign, m_aCryptParams, m_aCustomHttpPoster, m_aDecryptParameterModifier, m_aHttpClientFactory, m_aHttpRetrySettings, m_aIncomingDumper, m_aLocale, m_aOutgoingDumper, m_aResponseConsumer, m_aRetryCallback, m_aSendingDateTime, m_aSendingDTConsumer, m_aSigningParams, m_eSoapVersion, m_sAS4ProfileID, m_sMessageID, m_sRefToMessageID -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new builder, with the defaults fromAbstractAS4UserMessageBuilderMIMEPayload() -
Method Summary
Modifier and TypeMethodDescriptionfinal @NonNull IMPLTYPEapCacheRevocationCheckResult(@NonNull com.helger.base.state.ETriState eCacheRevocationCheckResult) Override the revocation result caching flag for the receiver AP certificate check on a per-send basis.final @NonNull IMPLTYPEapRevocationCheckMode(@Nullable com.helger.security.revocation.ERevocationCheckMode eRevocationCheckMode) Override the revocation check mode for the receiver AP certificate check on a per-send basis.final @NonNull IMPLTYPEapRevocationSoftFail(boolean bRevocationSoftFail) Enable or disable revocation soft-fail for the receiver AP certificate check.final @NonNull IMPLTYPEcertificateConsumer(@Nullable IPhase4PeppolCertificateCheckResultHandler aAPCertificateConsumer) Set an optional Consumer for the retrieved certificate from the endpoint details provider, independent of its usability.final @NonNull IMPLTYPEcheckReceiverAPCertificate(boolean bCheckReceiverAPCertificate) Enable or disable the check of the receiver AP certificate.final @NonNull IMPLTYPEcompressPayload(boolean bCompressPayload) Enable or disable the AS4 compression of the payload.final @NonNull IMPLTYPESet the country code of C1 to be used in the SBDH.final voidcreateAndStorePeppolReportingItemAfterSending(@NonNull @Nonempty String sEndUserID) This is a shortcut for creating and storing a Peppol reporting item in a shot.final @NonNull com.helger.peppol.reporting.api.PeppolReportingItemcreatePeppolReportingItemAfterSending(@NonNull @Nonempty String sEndUserID) Create a Peppol Reporting Item in case sending was successful.protected voidfinal @Nullable com.helger.peppolid.IDocumentTypeIdentifierfinal @NonNull IMPLTYPEdocumentTypeID(@NonNull com.helger.peppolid.IDocumentTypeIdentifier aDocTypeID) Set the document type ID to be send.final @Nullable OffsetDateTimeThe effective sending date time of the message.final @NonNull IMPLTYPEendpointDetailProvider(@NonNull com.helger.phase4.dynamicdiscovery.IAS4EndpointDetailProvider aEndpointDetailProvider) Set the abstract endpoint detail provider to be used.final @NonNull IMPLTYPEendpointURLConsumer(@Nullable Consumer<String> aAPEndpointURLConsumer) Set an optional Consumer for the destination AP address retrieved from the endpoint details provider, independent of its usability.protected com.helger.base.state.ESuccessfinishFields(@NonNull com.helger.phase4.util.AS4ResourceHelper aResHelper) protected final booleanbooleanfinal @NonNull IMPLTYPEpayloadContentID(@Nullable String sPayloadContentID) Set an optional payload "Content-ID".final @NonNull IMPLTYPEpayloadMimeType(@NonNull com.helger.mime.IMimeType aPayloadMimeType) Set the MIME type of the payload.final @NonNull IMPLTYPEpeppolAP_CAChecker(@NonNull com.helger.security.certificate.TrustedCAChecker aCAChecker) Set a custom Peppol AP certificate CA checker.final @Nullable com.helger.peppolid.IProcessIdentifierfinal @NonNull IMPLTYPEprocessID(@NonNull com.helger.peppolid.IProcessIdentifier aProcessID) Set the process ID to be send.final @NonNull IMPLTYPEreceiverEndpointDetails(@NonNull com.helger.xsds.peppol.smp1.EndpointType aEndpoint) Use this method to explicit set the AP certificate and AP endpoint URL that was retrieved from a previous SMP query.final @NonNull IMPLTYPEreceiverEndpointDetails(@NonNull X509Certificate aCert, @NonNull @Nonempty String sDestURL) Use this method to explicit set the AP certificate and AP endpoint URL that was retrieved externally (e.g. via an SMP call or for a static test case).final @NonNull IMPLTYPEreceiverParticipantID(@NonNull com.helger.peppolid.IParticipantIdentifier aReceiverID) Set the receiver participant ID of the message.final @NonNull IMPLTYPEsenderParticipantID(@NonNull com.helger.peppolid.IParticipantIdentifier aSenderID) Set the sender participant ID of the message.final @NonNull IMPLTYPEsenderPartyID(@NonNull @Nonempty String sSenderPartyID) Set the "sender party ID" which is the CN part of the Peppol AP certificate.final @NonNull IMPLTYPEsmpClient(@NonNull com.helger.smpclient.peppol.SMPClientReadOnly aSMPClient) Set the SMP client to be used.final @NonNull IMPLTYPEtechnicalContactConsumer(@Nullable Consumer<String> aAPTechnicalContactConsumer) Set an optional Consumer for the technical contact retrieved from the endpoint details provider, independent of its usability.Methods inherited from class com.helger.phase4.sender.AbstractAS4UserMessageBuilderMIMEPayload
createMainAttachment, createOtherAttachment, mainSendMessage, payload, payload, payloadMethods inherited from class com.helger.phase4.sender.AbstractAS4UserMessageBuilder
action, action, addAttachment, addAttachment, addEbmsProperties, addMessageProperty, addMessageProperty, addMessageProperty, agreementRef, agreementRef, agreementType, agreementType, applyToUserMessage, attachment, attachment, attachments, attachments, attachments, conversationID, conversationID, endpointURL, endpointURL, forceMimeMessage, forceMimeMessage, fromPartyID, fromPartyID, fromPartyIDType, fromPartyIDType, fromRole, fromRole, getAllAttachments, getAllMessageProperties, messageProperties, messageProperties, messageProperties, messageProperty, messageProperty, messageProperty, pmode, pmode, pmodeID, pmodeID, receiverCertificate, receiverCertificateAlias, sendMessageAndCheckForReceipt, sendMessageAndCheckForReceipt, service, service, service, serviceType, signalMsgConsumer, signalMsgConsumer, signalMsgValidationResultHdl, signalMsgValidationResultHdl, toPartyID, toPartyID, toPartyIDType, toPartyIDType, toRole, toRoleMethods inherited from class com.helger.phase4.sender.AbstractAS4MessageBuilder
afterSuccessfulSending, as4ProfileID, as4ProfileID, buildMessageCallback, buildMessageCallback, cryptoFactory, cryptoFactoryCrypt, cryptoFactoryCrypt, cryptoFactorySign, cryptoFactorySign, cryptParams, customHttpPoster, customHttpPoster, decryptRequestDataModifier, decryptRequestDataModifier, httpClientFactory, httpClientFactory, httpClientFactory, httpRetrySettings, httpRetrySettings, incomingAttachmentFactory, incomingAttachmentFactory, incomingDumper, incomingDumper, incomingProfileSelector, incomingProfileSelector, locale, locale, messageID, messageID, outgoingDumper, outgoingDumper, pmodeResolver, pmodeResolver, rawResponseConsumer, rawResponseConsumer, refToMessageID, refToMessageID, retryCallback, retryCallback, senderInterrupt, senderInterrupt, sendingDateTime, sendingDateTime, sendingDateTimeConsumer, sendingDateTimeConsumer, sendMessage, signingParams, soapVersion, soapVersion, withCryptParams, withSigningParamsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.base.trait.IGenericImplTrait
thisAsT
-
Field Details
-
DEFAULT_COMPRESS_PAYLOAD
public static final boolean DEFAULT_COMPRESS_PAYLOAD- See Also:
-
DEFAULT_CHECK_RECEIVER_AP_CERTIFICATE
public static final boolean DEFAULT_CHECK_RECEIVER_AP_CERTIFICATE- See Also:
-
m_aSenderID
protected com.helger.peppolid.IParticipantIdentifier m_aSenderID -
m_aReceiverID
protected com.helger.peppolid.IParticipantIdentifier m_aReceiverID -
m_aDocTypeID
protected com.helger.peppolid.IDocumentTypeIdentifier m_aDocTypeID -
m_aProcessID
protected com.helger.peppolid.IProcessIdentifier m_aProcessID -
m_sCountryC1
-
m_aPayloadMimeType
protected com.helger.mime.IMimeType m_aPayloadMimeType -
m_bCompressPayload
protected boolean m_bCompressPayload -
m_sPayloadContentID
-
m_aEndpointDetailProvider
protected com.helger.phase4.dynamicdiscovery.IAS4EndpointDetailProvider m_aEndpointDetailProvider -
m_aCAChecker
protected com.helger.security.certificate.TrustedCAChecker m_aCAChecker
-
-
Constructor Details
-
AbstractPeppolUserMessageBuilder
public AbstractPeppolUserMessageBuilder()Create a new builder, with the defaults fromAbstractAS4UserMessageBuilderMIMEPayload()
-
-
Method Details
-
senderParticipantID
public final @NonNull IMPLTYPE senderParticipantID(@NonNull com.helger.peppolid.IParticipantIdentifier aSenderID) Set the sender participant ID of the message. The participant ID must be provided prior to sending.- Parameters:
aSenderID- The sender participant ID. May not benull.- Returns:
- this for chaining
-
receiverParticipantID
public final @NonNull IMPLTYPE receiverParticipantID(@NonNull com.helger.peppolid.IParticipantIdentifier aReceiverID) Set the receiver participant ID of the message. The participant ID must be provided prior to sending. This ends up in the "finalRecipient" UserMessage property.- Parameters:
aReceiverID- The receiver participant ID. May not benull.- Returns:
- this for chaining
-
documentTypeID
public final @Nullable com.helger.peppolid.IDocumentTypeIdentifier documentTypeID()- Returns:
- The currently set Document Type ID. May be
null. - Since:
- 2.2.2
-
documentTypeID
public final @NonNull IMPLTYPE documentTypeID(@NonNull com.helger.peppolid.IDocumentTypeIdentifier aDocTypeID) Set the document type ID to be send. The document type must be provided prior to sending. This is a shortcut to theAbstractAS4UserMessageBuilder.action(String)method.- Parameters:
aDocTypeID- The document type ID to be used. May not benull.- Returns:
- this for chaining
-
processID
public final @Nullable com.helger.peppolid.IProcessIdentifier processID()- Returns:
- The currently set Process ID. May be
null. - Since:
- 2.2.2
-
processID
public final @NonNull IMPLTYPE processID(@NonNull com.helger.peppolid.IProcessIdentifier aProcessID) Set the process ID to be send. The process ID must be provided prior to sending. This is a shortcut to theAbstractAS4UserMessageBuilder.service(String, String)method.- Parameters:
aProcessID- The process ID to be used. May not benull.- Returns:
- this for chaining
-
countryC1
Set the country code of C1 to be used in the SBDH. This field was introduced in the Peppol Business Message Envelope specification 2.0.
Note: There is no date yet, when it becomes mandatory.- Parameters:
sCountryC1- The country code of C1 to be used. May benull.- Returns:
- this for chaining
- Since:
- 2.1.3
-
senderPartyID
Set the "sender party ID" which is the CN part of the Peppol AP certificate. An example value is e.g. "POP000123" but it MUST match the certificate you are using. This must be provided prior to sending. This is a shortcut to theAbstractAS4UserMessageBuilder.fromPartyID(String)method.- Parameters:
sSenderPartyID- The sender party ID. May neither benullnor empty.- Returns:
- this for chaining
-
payloadMimeType
Set the MIME type of the payload. By default it isapplication/xmland MUST usually not be changed. This value is required for sending.- Parameters:
aPayloadMimeType- The payload MIME type. May not benull.- Returns:
- this for chaining
-
compressPayload
Enable or disable the AS4 compression of the payload. By default compression is disabled.- Parameters:
bCompressPayload-trueto compress the payload,falseto not compress it.- Returns:
- this for chaining.
-
payloadContentID
Set an optional payload "Content-ID". This method is usually not needed, because in Peppol there are currently no rules on the Content-ID. By default a random Content-ID is created.- Parameters:
sPayloadContentID- The new payload content ID. May be null.- Returns:
- this for chaining
- Since:
- 1.3.1
-
endpointDetailProvider
public final @NonNull IMPLTYPE endpointDetailProvider(@NonNull com.helger.phase4.dynamicdiscovery.IAS4EndpointDetailProvider aEndpointDetailProvider) Set the abstract endpoint detail provider to be used. This can be an SMP lookup routine or in certain test cases a predefined certificate and endpoint URL.- Parameters:
aEndpointDetailProvider- The endpoint detail provider to be used. May not benull.- Returns:
- this for chaining
- See Also:
-
smpClient
public final @NonNull IMPLTYPE smpClient(@NonNull com.helger.smpclient.peppol.SMPClientReadOnly aSMPClient) Set the SMP client to be used. This is the point where e.g. the differentiation between SMK and SML can be done. This must be set prior to sending. If the endpoint information are already known you can also usereceiverEndpointDetails(X509Certificate, String)instead.- Parameters:
aSMPClient- The SMP client to be used. May not benull.- Returns:
- this for chaining
- See Also:
-
receiverEndpointDetails
public final @NonNull IMPLTYPE receiverEndpointDetails(@NonNull com.helger.xsds.peppol.smp1.EndpointType aEndpoint) throws CertificateException Use this method to explicit set the AP certificate and AP endpoint URL that was retrieved from a previous SMP query.- Parameters:
aEndpoint- The Peppol SMP Endpoint instance. May not benull.- Returns:
- this for chaining
- Throws:
CertificateException- In case the conversion from byte array to X509 certificate failed- Since:
- 2.7.6
-
receiverEndpointDetails
public final @NonNull IMPLTYPE receiverEndpointDetails(@NonNull X509Certificate aCert, @Nonempty @NonNull @Nonempty String sDestURL) Use this method to explicit set the AP certificate and AP endpoint URL that was retrieved externally (e.g. via an SMP call or for a static test case).- Parameters:
aCert- The Peppol AP certificate that should be used to encrypt the message for the receiver. May not benull.sDestURL- The destination URL of the receiving AP to send the AS4 message to. Must be a valid URL and may neither benullnor empty.- Returns:
- this for chaining
-
certificateConsumer
public final @NonNull IMPLTYPE certificateConsumer(@Nullable IPhase4PeppolCertificateCheckResultHandler aAPCertificateConsumer) Set an optional Consumer for the retrieved certificate from the endpoint details provider, independent of its usability.- Parameters:
aAPCertificateConsumer- The consumer to be used. May benull.- Returns:
- this for chaining
-
endpointURLConsumer
public final @NonNull IMPLTYPE endpointURLConsumer(@Nullable Consumer<String> aAPEndpointURLConsumer) Set an optional Consumer for the destination AP address retrieved from the endpoint details provider, independent of its usability.- Parameters:
aAPEndpointURLConsumer- The consumer to be used. May benull.- Returns:
- this for chaining
- Since:
- 1.3.3
-
technicalContactConsumer
public final @NonNull IMPLTYPE technicalContactConsumer(@Nullable Consumer<String> aAPTechnicalContactConsumer) Set an optional Consumer for the technical contact retrieved from the endpoint details provider, independent of its usability.- Parameters:
aAPTechnicalContactConsumer- The consumer to be used. May benull.- Returns:
- this for chaining
- Since:
- 3.2.0
-
checkReceiverAPCertificate
Enable or disable the check of the receiver AP certificate. This checks the validity of the certificate as well as the revocation status. It is strongly recommended to enable this check.- Parameters:
bCheckReceiverAPCertificate-trueto enable it,falseto disable it.- Returns:
- this for chaining
- Since:
- 1.3.10
-
peppolAP_CAChecker
public final @NonNull IMPLTYPE peppolAP_CAChecker(@NonNull com.helger.security.certificate.TrustedCAChecker aCAChecker) Set a custom Peppol AP certificate CA checker. This is e.g. needed when a non-standard AP certificate (as for Peppol France PoC or Peppol eB2B) is needed. This CA checker checks the certificate provided by the endpoint detail provider (see below). This checker is only used, ifcheckReceiverAPCertificate(boolean)was called withtrue.- Parameters:
aCAChecker- The Certificate CA checker to be used. May not benull.- Returns:
- this for chaining
- Since:
- 3.0.0-rc1
-
apCacheRevocationCheckResult
public final @NonNull IMPLTYPE apCacheRevocationCheckResult(@NonNull com.helger.base.state.ETriState eCacheRevocationCheckResult) Override the revocation result caching flag for the receiver AP certificate check on a per-send basis. This is only applied ifcheckReceiverAPCertificate(boolean)istrue.- Parameters:
eCacheRevocationCheckResult-ETriState.TRUEto use the global revocation cache,ETriState.FALSEto bypass it,ETriState.UNDEFINED(the default) to use the JVM-wide default fromCertificateRevocationCheckerDefaults. May not benull.- Returns:
- this for chaining
- Since:
- 4.5.0
-
apRevocationCheckMode
public final @NonNull IMPLTYPE apRevocationCheckMode(@Nullable com.helger.security.revocation.ERevocationCheckMode eRevocationCheckMode) Override the revocation check mode for the receiver AP certificate check on a per-send basis. This is only applied ifcheckReceiverAPCertificate(boolean)istrue.- Parameters:
eRevocationCheckMode- The revocation check mode to use.null(the default) means "use the JVM-wide default fromCertificateRevocationCheckerDefaults".- Returns:
- this for chaining
- Since:
- 4.5.0
-
apRevocationSoftFail
Enable or disable revocation soft-fail for the receiver AP certificate check. When enabled, an indeterminable revocation status (e.g. unreachable CRL distribution point with no working OCSP fallback) is logged at WARN level and treated as acceptable. All other invalid states (revoked, expired, untrusted issuer, ...) still cause a hard reject.Security note: Peppol mandates revocation checks. Enabling soft-fail allows a message to be sent with a potentially-revoked AP certificate during a CRL/OCSP outage. Use only as a deliberate operational-continuity measure. Defaults to
false.- Parameters:
bRevocationSoftFail-trueto acceptECertificateCheckResult.REVOCATION_STATUS_UNKNOWNas valid,false(default) to treat it as invalid.- Returns:
- this for chaining
- Since:
- 4.5.0
-
effectiveSendingDateTime
The effective sending date time of the message. That is set only if message sending takes place.- Returns:
- The effective sending date time or
nullif the messages was not sent yet. - Since:
- 2.2.2
-
isEndpointDetailProviderUsable
protected final boolean isEndpointDetailProviderUsable() -
finishFields
@OverridingMethodsMustInvokeSuper protected com.helger.base.state.ESuccess finishFields(@NonNull com.helger.phase4.util.AS4ResourceHelper aResHelper) throws com.helger.phase4.util.Phase4Exception - Overrides:
finishFieldsin classcom.helger.phase4.sender.AbstractAS4UserMessageBuilder<IMPLTYPE extends Phase4PeppolSender.AbstractPeppolUserMessageBuilder<IMPLTYPE>>- Throws:
com.helger.phase4.util.Phase4Exception
-
isEveryRequiredFieldSet
@OverridingMethodsMustInvokeSuper public boolean isEveryRequiredFieldSet()- Overrides:
isEveryRequiredFieldSetin classcom.helger.phase4.sender.AbstractAS4UserMessageBuilderMIMEPayload<IMPLTYPE extends Phase4PeppolSender.AbstractPeppolUserMessageBuilder<IMPLTYPE>>
-
customizeBeforeSending
protected void customizeBeforeSending() throws com.helger.phase4.util.Phase4Exception- Overrides:
customizeBeforeSendingin classcom.helger.phase4.sender.AbstractAS4MessageBuilder<IMPLTYPE extends Phase4PeppolSender.AbstractPeppolUserMessageBuilder<IMPLTYPE>>- Throws:
com.helger.phase4.util.Phase4Exception
-
createPeppolReportingItemAfterSending
public final @NonNull com.helger.peppol.reporting.api.PeppolReportingItem createPeppolReportingItemAfterSending(@Nonempty @NonNull @Nonempty String sEndUserID) throws com.helger.phase4.util.Phase4Exception Create a Peppol Reporting Item in case sending was successful. This The end user ID needs to be provided from the outside, because it cannot be used from the sending data. The end user ID is only needed for grouping the reporting data later on, and is NOT part of the transmission (neither in TSR nor in EUSR).
The item is simply created but not stored.- Parameters:
sEndUserID- The local end user ID, required to group all reporting items. May neither benullnor empty.- Returns:
- The created reporting item. Never
null. - Throws:
com.helger.phase4.util.Phase4Exception- in case something goes wrong- Since:
- 2.2.2
- See Also:
-
createAndStorePeppolReportingItemAfterSending
public final void createAndStorePeppolReportingItemAfterSending(@Nonempty @NonNull @Nonempty String sEndUserID) throws com.helger.phase4.util.Phase4Exception This is a shortcut for creating and storing a Peppol reporting item in a shot. See the creation method for the extended documentation.- Parameters:
sEndUserID- The local end user ID, required to group all reporting items. May neither benullnor empty.- Throws:
com.helger.phase4.util.Phase4Exception- in case something goes wrong- Since:
- 2.2.2
- See Also:
-