gnodet-bot commented on code in PR #28347:
URL: https://github.com/apache/camel/pull/28347#discussion_r4358948259


##########
components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerConnection.java:
##########
@@ -89,10 +89,7 @@ public class AS2ServerConnection {
     private final String as2Version;
     private final String originServer;
     private final String serverFqdn;
-    private final String userName;
-    private final String password;
-    private final String accessToken;
-    private final String asyncMdnAllowedHosts;
+    private final SSLContext sslContext;

Review Comment:
   ⛔ **Compilation error (root cause): `AS2AsynchronousMDNManager` has no 
10-arg constructor on `camel-4.22.x`.**
   
   The original commit on `main` rewrote `AS2AsynchronousMDNManager` to add a 
10-arg constructor accepting `SSLContext`. That file change was silently 
dropped during the backport cherry-pick. On `camel-4.22.x`, only these 
constructors exist:
   - 8-arg (deprecated): `(as2Version, userAgent, senderFQDN, signingCertChain, 
signingKey, userName, password, accessToken)`
   - 9-arg: adds `allowedHosts`
   
   Neither accepts `SSLContext`. The `private final SSLContext sslContext` 
field added here feeds only the non-existent 10-arg call — once that call is 
fixed to use the 9-arg constructor, this field is unused and must be removed.
   
   On this branch `AS2AsynchronousMDNManager` explicitly refuses https delivery 
(`throw new HttpException("TLS delivery of asynchronous MDNs is not 
supported")`), so the parameter serves no purpose here.
   
   ```suggestion
   ```



##########
components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerConnection.java:
##########
@@ -583,6 +581,61 @@ 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(),
+                        AS2ServerConnection.this.sslContext);

Review Comment:
   ⛔ **Compilation error: passing `sslContext` as the 10th argument — this 
constructor doesn't exist on `camel-4.22.x`.**
   
   Drop the `sslContext` argument and use the existing 9-arg constructor:
   
   ```suggestion
                   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());
   ```



##########
components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ServerConnection.java:
##########
@@ -621,24 +674,27 @@ public AS2ServerConnection(String as2Version,
                                String accessToken,
                                String asyncMdnAllowedHosts)
                                                             throws IOException 
{
-        this.asyncMdnAllowedHosts = asyncMdnAllowedHosts;
+        this.sslContext = sslContext;

Review Comment:
   ⚠️ After removing the `sslContext` field (line 92) and the 10-arg 
constructor call, this assignment becomes a compilation error too. The 
`sslContext` constructor parameter is already passed to `RequestAcceptorThread` 
— storing it as a field is unnecessary.
   
   ```suggestion
   ```



##########
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 on `camel-4.22.x`:** `AS2AsynchronousMDNManager` on this 
branch explicitly refuses https delivery with `throw new HttpException("TLS 
delivery of asynchronous MDNs is not supported")`. The claim that `sslContext` 
is used "for the https delivery of asynchronous MDNs" is misleading here — it 
is used for the TLS listener only.
   
   ```suggestion
   `sslContextParameters` and `sslContext` (used for the TLS listener),
   ```



-- 
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]

Reply via email to