gnodet-bot commented on code in PR #28347:
URL: https://github.com/apache/camel/pull/28347#discussion_r4439991380
##########
catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/as2-component.adoc:
##########
@@ -54,3 +54,57 @@ producers, strip these internal headers at the trust
boundary -- for example wit
`removeHeaders("Camel*")` -- before the message reaches this component, so
that a sender cannot
override the API call. See xref:manual::security-model.adoc[the Camel security
model] for details.
====
+
+
+== Usage
+
+An `as2://server/listen` consumer receives AS2 messages on `serverPortNumber`,
for the request URIs that match
+`requestUriPattern`. An `as2://client/send` producer sends the message body
(`inBody: ediMessage`) to
+`targetHostname` and `targetPortNumber`. The following routes send a plain
EDIFACT message from one to the other:
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: as2://server/listen
+ parameters:
+ serverPortNumber: 8888
+ requestUriPattern: /receiver
+ steps:
+ - log:
+ message: "Received EDI message: ${body}"
+- route:
+ from:
+ uri: timer:send
+ parameters:
+ repeatCount: 1
+ steps:
+ - setBody:
+ expression:
+ constant:
+ expression: "UNB+UNOA:1+SENDER+RECEIVER+260101:1200+1'UNZ+1+1'"
+ - to:
+ uri: as2://client/send
+ parameters:
+ inBody: ediMessage
+ targetHostname: localhost
+ targetPortNumber: 8888
+ requestUri: /receiver
+ as2From: sender
+ as2To: receiver
+ from: [email protected]
+ subject: Order
+ as2MessageStructure: PLAIN
+ ediMessageContentType: application/edifact
+----
+
+A `SIGNED`, `ENCRYPTED` or `SIGNED_ENCRYPTED` message structure also needs the
keys and certificates of the signing
+and encrypting options.
+
+Several `as2://server/listen` consumers can share a `serverPortNumber`, each
with its own `requestUriPattern`. Each
+consumer applies its own keys and certificates and its own asynchronous MDN
settings (`mdnUserName`, `mdnPassword`,
+`mdnAccessToken` and `asyncMdnAllowedHosts`) to the messages received on its
own pattern.
+
+The settings of the shared server connection still come from the first
endpoint created on the port:
+`sslContextParameters` and `sslContext` (used for the TLS listener and for the
https delivery of asynchronous MDNs),
Review Comment:
⚠️ **Inaccurate documentation (generated catalog copy):** Same incorrect
claim as in the component `.adoc` — this generated file inherits the error.
Will be fixed automatically when the source adoc is corrected and the catalog
is regenerated.
##########
components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerConnection.java:
##########
@@ -583,6 +581,60 @@ public void run() {
}
}
+ private void handleAsynchronousMDN(HttpCoreContext coreContext) throws
HttpException, IOException {
+ // Safely retrieve the AS2 consumer configuration and path from
ThreadLocal storage.
+ AS2ConsumerConfiguration config =
Optional.ofNullable(CURRENT_CONSUMER_CONFIG.get())
+ .map(w -> w.config)
+ .orElse(null);
+
+ String recipientAddress =
coreContext.getAttribute(AS2AsynchronousMDNManager.RECIPIENT_ADDRESS,
+ String.class);
+
+ if (recipientAddress != null && config != null) {
+ // Send the MDN asynchronously.
+
+ DispositionNotificationMultipartReportEntity
multipartReportEntity = coreContext.getAttribute(
+ AS2AsynchronousMDNManager.ASYNCHRONOUS_MDN,
+ DispositionNotificationMultipartReportEntity.class);
+ // The MDN settings come from the matched path's
configuration, like the signing material: the
+ // consumers sharing this connection each deliver their
asynchronous MDNs with their own values.
+ AS2AsynchronousMDNManager asynchronousMDNManager = new
AS2AsynchronousMDNManager(
+ AS2ServerConnection.this.as2Version,
+ AS2ServerConnection.this.originServer,
+ AS2ServerConnection.this.serverFqdn,
+ config.getSigningCertificateChain(),
+ config.getSigningPrivateKey(),
+ config.getMdnUserName(),
+ config.getMdnPassword(),
+ config.getMdnAccessToken(),
+ config.getAsyncMdnAllowedHosts());
+
+ HttpRequest request = coreContext.getRequest();
+ AS2SignedDataGenerator gen =
ResponseMDN.createSigningGenerator(
+ request,
+ config.getSigningAlgorithm(),
+ config.getSigningCertificateChain(),
+ config.getSigningPrivateKey());
+ if (gen != null) {
+ // send a signed MDN
+ MultipartSignedEntity multipartSignedEntity = null;
+ try {
+ multipartSignedEntity =
ResponseMDN.prepareSignedReceipt(gen, multipartReportEntity);
+ } catch (Exception e) {
+ LOG.warn("failed to sign MDN");
Review Comment:
⚠️ **Exception stack trace swallowed:** `e` is caught but never passed to
`LOG.warn` — operators see the warning but lose all diagnostic information
about what failed.
```suggestion
LOG.warn("failed to sign MDN", e);
```
##########
components/camel-as2/camel-as2-component/src/main/docs/as2-component.adoc:
##########
@@ -54,3 +54,57 @@ producers, strip these internal headers at the trust
boundary -- for example wit
`removeHeaders("Camel*")` -- before the message reaches this component, so
that a sender cannot
override the API call. See xref:manual::security-model.adoc[the Camel security
model] for details.
====
+
+
+== Usage
+
+An `as2://server/listen` consumer receives AS2 messages on `serverPortNumber`,
for the request URIs that match
+`requestUriPattern`. An `as2://client/send` producer sends the message body
(`inBody: ediMessage`) to
+`targetHostname` and `targetPortNumber`. The following routes send a plain
EDIFACT message from one to the other:
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: as2://server/listen
+ parameters:
+ serverPortNumber: 8888
+ requestUriPattern: /receiver
+ steps:
+ - log:
+ message: "Received EDI message: ${body}"
+- route:
+ from:
+ uri: timer:send
+ parameters:
+ repeatCount: 1
+ steps:
+ - setBody:
+ expression:
+ constant:
+ expression: "UNB+UNOA:1+SENDER+RECEIVER+260101:1200+1'UNZ+1+1'"
+ - to:
+ uri: as2://client/send
+ parameters:
+ inBody: ediMessage
+ targetHostname: localhost
+ targetPortNumber: 8888
+ requestUri: /receiver
+ as2From: sender
+ as2To: receiver
+ from: [email protected]
+ subject: Order
+ as2MessageStructure: PLAIN
+ ediMessageContentType: application/edifact
+----
+
+A `SIGNED`, `ENCRYPTED` or `SIGNED_ENCRYPTED` message structure also needs the
keys and certificates of the signing
+and encrypting options.
+
+Several `as2://server/listen` consumers can share a `serverPortNumber`, each
with its own `requestUriPattern`. Each
+consumer applies its own keys and certificates and its own asynchronous MDN
settings (`mdnUserName`, `mdnPassword`,
+`mdnAccessToken` and `asyncMdnAllowedHosts`) to the messages received on its
own pattern.
+
+The settings of the shared server connection still come from the first
endpoint created on the port:
+`sslContextParameters` and `sslContext` (used for the TLS listener and for the
https delivery of asynchronous MDNs),
Review Comment:
⚠️ **Inaccurate documentation:** `AS2AsynchronousMDNManager` is constructed
without any `SSLContext` — the async MDN sender has no TLS context. The claim
that `sslContext` is used for "the https delivery of asynchronous MDNs" is not
supported by the code and should be removed or corrected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]