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
FieldsModifier and TypeFieldDescriptionstatic final com.helger.commons.mime.IMimeType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()final IAS4CryptoFactoryfinal IAS4CryptoFactoryfinal IAS4IncomingDumperfinal Localeprotected final IAS4IncomingMessageMetadatafinal IAS4OutgoingDumperfinal IAS4PModeResolverfinal <T extends IAS4IncomingMessageProcessorSPI>
TgetProcessorOfType(Class<T> aTargetClass) Find the message processor of the specified type.final Supplier<? extends com.helger.commons.collection.impl.ICommonsList<IAS4IncomingMessageProcessorSPI>> final IAS4RetryCallbackvoidhandleRequest(InputStream aRequestInputStream, com.helger.commons.http.HttpHeaderMap aRequestHttpHeaders, IAS4ResponseAbstraction aHttpResponse) This is the main handling routine when called from an abstract (non-Servlet) APIfinal AS4RequestHandlersetCryptoFactory(IAS4CryptoFactory aCryptoFactory) Set the same crypto factory for signing and crypting.final AS4RequestHandlersetCryptoFactoryCrypt(IAS4CryptoFactory aCryptoFactoryCrypt) Set the crypto factory crypting.final AS4RequestHandlersetCryptoFactorySign(IAS4CryptoFactory aCryptoFactorySign) Set the crypto factory for signing.final AS4RequestHandlersetErrorConsumer(IAS4RequestHandlerErrorConsumer aErrorConsumer) Set an optional error consumer that is invoked with all errors determined during message processing.final AS4RequestHandlerfinal AS4RequestHandlersetIncomingDumper(IAS4IncomingDumper aIncomingDumper) Set the specific dumper for incoming messages.final AS4RequestHandlersetIncomingProfileSelector(IAS4IncomingProfileSelector aIncomingProfileSelector) Set the AS4 profile selector for incoming messages.final AS4RequestHandlerfinal AS4RequestHandlerfinal AS4RequestHandlerSet the error for EBMS error messages.final AS4RequestHandlersetOutgoingDumper(IAS4OutgoingDumper aOutgoingDumper) Set the specific dumper for outgoing messages.final AS4RequestHandlersetPModeResolver(IAS4PModeResolver aPModeResolver) final AS4RequestHandlersetProcessorSupplier(Supplier<? extends com.helger.commons.collection.impl.ICommonsList<IAS4IncomingMessageProcessorSPI>> aProcessorSupplier) Set a different processor supplierfinal AS4RequestHandlersetRetryCallback(IAS4RetryCallback aRetryCallback) Set the HTTP retry callback for outgoing messages.final AS4RequestHandlersetSoapProcessingFinalizedCallback(IAS4SoapProcessingFinalizedCallback aSoapProcessingFinalizedCB) Set the internal SOAP processing finalized callback.
-
Field Details
-
MT_MULTIPART_RELATED
public static final com.helger.commons.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.
-
getCryptoFactorySign
- Returns:
- The
IAS4CryptoFactoryfor signing. May benullif not initialized. - Since:
- 3.0.0
- See Also:
-
setCryptoFactorySign
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final 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
@Nonnull public final Supplier<? extends com.helger.commons.collection.impl.ICommonsList<IAS4IncomingMessageProcessorSPI>> getProcessorSupplier()- Returns:
- The supplier used to get all SPIs. By default this is
AS4IncomingMessageProcessorManager.getAllProcessors().
-
getProcessorOfType
@Nonnull public final <T extends IAS4IncomingMessageProcessorSPI> 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
@Nonnull public final AS4RequestHandler setProcessorSupplier(@Nonnull Supplier<? extends com.helger.commons.collection.impl.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
@Nonnull public final 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(@Nonnull @WillClose InputStream aRequestInputStream, @Nonnull com.helger.commons.http.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:
-