Package com.helger.phase4.incoming
Class AS4RequestHandler
java.lang.Object
com.helger.phase4.incoming.AS4RequestHandler
- All Implemented Interfaces:
AutoCloseable
Process incoming AS4 transmissions. This class is responsible for handling data in a provider
independent way (so e.g. not Servlet specific), only based on InputStream and OutputStream. For
each incoming request, a new instance of this class is created.
- Author:
- Martin Bayerl, Philip Helger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()final @Nullable IAS4CryptoFactoryfinal @Nullable IAS4CryptoFactoryfinal @Nullable IAS4RequestHandlerErrorConsumerfinal @Nullable IAS4IncomingAttachmentFactoryfinal @Nullable IAS4IncomingDumperfinal @NonNull IAS4IncomingProfileSelectorfinal @Nullable IAS4IncomingReceiverConfigurationfinal @Nullable IAS4IncomingSecurityConfigurationfinal @NonNull Localefinal @NonNull IAS4IncomingMessageMetadatafinal @Nullable IAS4OutgoingDumperfinal @Nullable IAS4PModeResolverfinal <T extends IAS4IncomingMessageProcessorSPI>
@NonNull TgetProcessorOfType(@NonNull Class<T> aTargetClass) Find the message processor of the specified type.final @NonNull Supplier<? extends com.helger.collection.commons.ICommonsList<IAS4IncomingMessageProcessorSPI>> final @Nullable IAS4RetryCallbackfinal @Nullable IAS4SoapProcessingFinalizedCallbackvoidhandleRequest(@NonNull InputStream aRequestInputStream, @NonNull com.helger.http.header.HttpHeaderMap aRequestHttpHeaders, @NonNull IAS4ResponseAbstraction aHttpResponse) This is the main handling routine when called from an abstract (non-Servlet) APIfinal @NonNull AS4RequestHandlersetCryptoFactory(@NonNull IAS4CryptoFactory aCryptoFactory) Set the same crypto factory for signing and crypting.final @NonNull AS4RequestHandlersetCryptoFactoryCrypt(@NonNull IAS4CryptoFactory aCryptoFactoryCrypt) Set the crypto factory crypting.final @NonNull AS4RequestHandlersetCryptoFactorySign(@NonNull IAS4CryptoFactory aCryptoFactorySign) Set the crypto factory for signing.final @NonNull AS4RequestHandlersetErrorConsumer(@Nullable IAS4RequestHandlerErrorConsumer aErrorConsumer) Set an optional error consumer that is invoked with all errors determined during message processing.final @NonNull AS4RequestHandlersetIncomingAttachmentFactory(@NonNull IAS4IncomingAttachmentFactory aIAF) final @NonNull AS4RequestHandlersetIncomingDumper(@Nullable IAS4IncomingDumper aIncomingDumper) Set the specific dumper for incoming messages.final @NonNull AS4RequestHandlersetIncomingProfileSelector(@NonNull IAS4IncomingProfileSelector aIncomingProfileSelector) Set the AS4 profile selector for incoming messages.final @NonNull AS4RequestHandlerfinal @NonNull AS4RequestHandlerfinal @NonNull AS4RequestHandlerSet the error for EBMS error messages.final @NonNull AS4RequestHandlersetOutgoingDumper(@Nullable IAS4OutgoingDumper aOutgoingDumper) Set the specific dumper for outgoing messages.final @NonNull AS4RequestHandlersetPModeResolver(@NonNull IAS4PModeResolver aPModeResolver) final @NonNull AS4RequestHandlersetProcessorSupplier(@NonNull Supplier<? extends com.helger.collection.commons.ICommonsList<IAS4IncomingMessageProcessorSPI>> aProcessorSupplier) Set a different processor supplierfinal @NonNull AS4RequestHandlersetRetryCallback(@Nullable IAS4RetryCallback aRetryCallback) Set the HTTP retry callback for outgoing messages.final @NonNull AS4RequestHandlersetSoapProcessingFinalizedCallback(@Nullable IAS4SoapProcessingFinalizedCallback aSoapProcessingFinalizedCB) Set the internal SOAP processing finalized callback.
-
Field Details
-
MT_MULTIPART_RELATED
public static final com.helger.mime.IMimeType MT_MULTIPART_RELATED
-
-
Constructor Details
-
AS4RequestHandler
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getMessageMetadata
- Returns:
- The incoming message metadata as provided in the constructor. Never
null. - Since:
- 4.2.5 public - was protected previously
-
getCryptoFactorySign
- Returns:
- The
IAS4CryptoFactoryfor signing. May benullif not initialized. - Since:
- 3.0.0
- See Also:
-
setCryptoFactorySign
public final @NonNull AS4RequestHandler setCryptoFactorySign(@NonNull IAS4CryptoFactory aCryptoFactorySign) Set the crypto factory for signing.- Parameters:
aCryptoFactorySign- Crypto factory for signing to use. May not benull.- Returns:
- this for chaining
- Since:
- 3.0.0
- See Also:
-
getCryptoFactoryCrypt
- Returns:
- The
IAS4CryptoFactoryfor crypting. May benullif not initialized. - Since:
- 3.0.0
- See Also:
-
setCryptoFactoryCrypt
public final @NonNull AS4RequestHandler setCryptoFactoryCrypt(@NonNull IAS4CryptoFactory aCryptoFactoryCrypt) Set the crypto factory crypting.- Parameters:
aCryptoFactoryCrypt- Crypto factory for crypting to use. May not benull.- Returns:
- this for chaining
- Since:
- 3.0.0
- See Also:
-
setCryptoFactory
Set the same crypto factory for signing and crypting. This is a sanity wrapper aroundsetCryptoFactory(IAS4CryptoFactory).- Parameters:
aCryptoFactory- Crypto factory to use. May not benull.- Returns:
- this for chaining
- Since:
- 3.0.0
- See Also:
-
getPModeResolver
- Returns:
- The
IAS4PModeResolverto be used. May benullif not initialized. - Since:
- 3.0.0
-
setPModeResolver
- Parameters:
aPModeResolver- PMode resolved to be used. May not benull.- Returns:
- this for chaining
- Since:
- 3.0.0
-
getIncomingAttachmentFactory
- Returns:
- The
IAS4IncomingAttachmentFactoryto be used. May benullif not initialized. - Since:
- 3.0.0
-
setIncomingAttachmentFactory
public final @NonNull AS4RequestHandler setIncomingAttachmentFactory(@NonNull IAS4IncomingAttachmentFactory aIAF) - Parameters:
aIAF- The attachment factory for incoming attachments. May not benull.- Returns:
- this for chaining
- Since:
- 3.0.0
-
getIncomingSecurityConfiguration
- Returns:
- The
IAS4IncomingSecurityConfigurationto be used. May benullif not initialized. - Since:
- 3.0.0
-
setIncomingSecurityConfiguration
public final @NonNull AS4RequestHandler setIncomingSecurityConfiguration(@NonNull IAS4IncomingSecurityConfiguration aICS) - Parameters:
aICS- The incoming security configuration. May not benull.- Returns:
- this for chaining
- Since:
- 3.0.0
-
getIncomingReceiverConfiguration
- Returns:
- The
IAS4IncomingReceiverConfigurationto be used. May benullif not initialized. - Since:
- 3.0.0
-
setIncomingReceiverConfiguration
public final @NonNull AS4RequestHandler setIncomingReceiverConfiguration(@NonNull IAS4IncomingReceiverConfiguration aIRC) - Parameters:
aIRC- The incoming receiver configuration. May not benull.- Returns:
- this for chaining
- Since:
- 3.0.0
-
getIncomingProfileSelector
- Returns:
- The current AS4 profile selector for incoming messages. Never
null. - Since:
- 0.13.0
-
setIncomingProfileSelector
public final @NonNull AS4RequestHandler setIncomingProfileSelector(@NonNull IAS4IncomingProfileSelector aIncomingProfileSelector) Set the AS4 profile selector for incoming messages.- Parameters:
aIncomingProfileSelector- The new profile selector to be used. May not benull.- Returns:
- this for chaining
- Since:
- 0.13.0
-
getLocale
- Returns:
- The locale for error messages. Never
null.
-
setLocale
Set the error for EBMS error messages.- Parameters:
aLocale- The locale. May not benull.- Returns:
- this for chaining
-
getIncomingDumper
- Returns:
- The specific dumper for incoming messages. May be
null. - Since:
- v0.9.7
-
setIncomingDumper
public final @NonNull AS4RequestHandler setIncomingDumper(@Nullable IAS4IncomingDumper aIncomingDumper) Set the specific dumper for incoming messages. If none is set, the global incoming dumper is used.- Parameters:
aIncomingDumper- The specific incoming dumper. May benull.- Returns:
- this for chaining
- Since:
- v0.9.7
-
getOutgoingDumper
- Returns:
- The specific dumper for outgoing messages. May be
null. - Since:
- v0.9.9
-
setOutgoingDumper
public final @NonNull AS4RequestHandler setOutgoingDumper(@Nullable IAS4OutgoingDumper aOutgoingDumper) Set the specific dumper for outgoing messages. If none is set, the global outgoing dumper is used.- Parameters:
aOutgoingDumper- The specific outgoing dumper. May benull.- Returns:
- this for chaining
- Since:
- v0.9.9
-
getRetryCallback
- Returns:
- The HTTP retry callback for outgoing messages. May be
null. - Since:
- v0.9.14
-
setRetryCallback
public final @NonNull AS4RequestHandler setRetryCallback(@Nullable IAS4RetryCallback aRetryCallback) Set the HTTP retry callback for outgoing messages.- Parameters:
aRetryCallback- The specific retry callback. May benull.- Returns:
- this for chaining
- Since:
- v0.9.14
-
getSoapProcessingFinalizedCallback
- Returns:
- The internal SOAP processing finalized callback.
nullby default. - Since:
- 0.13.1
-
setSoapProcessingFinalizedCallback
public final @NonNull AS4RequestHandler setSoapProcessingFinalizedCallback(@Nullable IAS4SoapProcessingFinalizedCallback aSoapProcessingFinalizedCB) Set the internal SOAP processing finalized callback. Only use when you know what you are doing. This callback is invoked both in the synchronous AND the asynchronous processing. A simple way to await the finalization could e.g. be ajava.util.concurrent.CountDownLatch.- Parameters:
aSoapProcessingFinalizedCB- The callback to be invoked. May benull. Only non-nullcallbacks are invoked ;-)- Returns:
- this for chaining
- Since:
- 0.13.1
-
getProcessorSupplier
public final @NonNull Supplier<? extends com.helger.collection.commons.ICommonsList<IAS4IncomingMessageProcessorSPI>> getProcessorSupplier()- Returns:
- The supplier used to get all SPIs. By default this is
AS4IncomingMessageProcessorManager.getAllProcessors().
-
getProcessorOfType
public final <T extends IAS4IncomingMessageProcessorSPI> @NonNull T getProcessorOfType(@NonNull Class<T> aTargetClass) Find the message processor of the specified type.- Parameters:
aTargetClass- The target processor class to search.- Returns:
nullif no such processor was found- Since:
- 2.8.2
-
setProcessorSupplier
public final @NonNull AS4RequestHandler setProcessorSupplier(@NonNull Supplier<? extends com.helger.collection.commons.ICommonsList<IAS4IncomingMessageProcessorSPI>> aProcessorSupplier) Set a different processor supplier- Parameters:
aProcessorSupplier- The processor supplier to be used. May not benull.- Returns:
- this for chaining
-
getErrorConsumer
- Returns:
- An optional error consumer.
nullby default. - Since:
- 0.9.7
-
setErrorConsumer
public final @NonNull AS4RequestHandler setErrorConsumer(@Nullable IAS4RequestHandlerErrorConsumer aErrorConsumer) Set an optional error consumer that is invoked with all errors determined during message processing. The consumed list MUST NOT be modified.
Note: the error consumer is ONLY called if the error list is non-empty.
Note: the AS4 error message is sent back automatically - this is just informational.- Parameters:
aErrorConsumer- The consumer to be used. May benull.- Returns:
- this for chaining
- Since:
- 0.9.7
-
handleRequest
public void handleRequest(@WillClose @NonNull InputStream aRequestInputStream, @NonNull com.helger.http.header.HttpHeaderMap aRequestHttpHeaders, @NonNull IAS4ResponseAbstraction aHttpResponse) throws Phase4Exception, IOException, jakarta.mail.MessagingException, org.apache.wss4j.common.ext.WSSecurityException This is the main handling routine when called from an abstract (non-Servlet) API- Parameters:
aRequestInputStream- The input stream with the raw AS4 request data. May not benull.aRequestHttpHeaders- The HTTP headers of the request. May not benull.aHttpResponse- The AS4 response abstraction to be filled. May not benull.- Throws:
Phase4Exception- in case the request is missing certain prerequisites. Since 0.9.11IOException- In case of IO errorsjakarta.mail.MessagingException- MIME related errorsorg.apache.wss4j.common.ext.WSSecurityException- In case of WSS4J errors- See Also:
-