davsclaus opened a new pull request, #30598:
URL: https://github.com/apache/camel/pull/30598

   ## What was missing
   
   [CAMEL-27369](https://issues.apache.org/jira/browse/CAMEL-27369): encryption 
and the timeouts of the smbj client could only be set with a 
`com.hierynomus.smbj.SmbConfig` bean in `smbConfig`. YAML and Kamelet users 
cannot easily create one. With the defaults, a share that requires encryption 
(`smb encrypt = required`) refuses the connection with `STATUS_ACCESS_DENIED`, 
and other shares get the file content unencrypted.
   
   ## The change
   
   New endpoint options. When no `smbConfig` is set, they build the 
`SmbConfig`. Names, units and defaults follow smbj 0.15.0:
   
   | Option | Label | Default | smbj |
   |---|---|---|---|
   | `encryptData` | security | `false` | `SmbConfig.Builder.withEncryptData` |
   | `connectTimeout` | advanced | `5000` (Duration) | `withSocketFactory(new 
ProxySocketFactory(connectTimeout))`. smbj has no connect timeout setting in 
`SmbConfig`; its default `ProxySocketFactory` connects with 5000 ms |
   | `readTimeout` | advanced | `60000` (Duration) | `withReadTimeout` (file 
content reads) |
   | `writeTimeout` | advanced | `60000` (Duration) | `withWriteTimeout` (file 
content writes) |
   | `transactTimeout` | advanced | `60000` (Duration) | `withTransactTimeout` 
(listing, create/open, close, rename, delete, logoff, ...) |
   
   I added `transactTimeout` beyond the ticket's list. Directory listings and 
every request other than reading and writing file content use it, so without it 
the read and write timeouts would not cover a poll that waits for the server.
   
   With all options at their defaults, the built `SmbConfig` equals 
`SmbConfig.createDefaultConfig()`, which the component used before. So nothing 
changes for existing endpoints.
   
   **Both `smbConfig` and an option set:** the endpoint fails when the consumer 
or producer is created, so the route fails to start. The message is `The 
smbConfig option cannot be combined with the encryptData, connectTimeout, 
readTimeout, writeTimeout and transactTimeout options, as the SmbConfig is used 
as is: set them on the SmbConfig instead ...`. A `SmbConfig` cannot be copied 
into a builder, so merging is not possible. Ignoring the options silently would 
be bad for `encryptData=true`, as the content would go unencrypted. `smbConfig` 
is autowired: a single `SmbConfig` bean in the registry is used by every smb 
endpoint, and the message says so. "Set" means "not the default value", so 
`encryptData=false` with a bean is accepted.
   
   Docs: a new section "Encryption and timeouts" in `smb-component.adoc` 
(catalog copy updated), and the `smbConfig` description says it cannot be 
combined with the options. Regenerated: the component JSON (and its catalog 
copy), the configurer and URI factory, and the endpoint DSL. The component DSL 
has no changes, as the options are endpoint options.
   
   Test infra: the Samba test image has a new share `data-encrypted` 
(`/data/encrypted`, `smb encrypt = required`). This is additive; the other 
shares are unchanged.
   
   About CAMEL-27370 (#30596): that PR bounds how long a disconnect waits for a 
server that does not answer (2 s, then it completes in the background), without 
a new option. The `transactTimeout` here is the smbj timeout of each request, 
including the close of the share and the logoff. The two do not overlap.
   
   ## Tests
   
   - `SmbConfigurationSmbConfigTest` (new, unit): the defaults equal smbj's 
defaults; the options (`2s`, `5s`, `6000`, `7s`) end up in the `SmbConfig`; an 
`smbConfig` bean is used as is; a single `SmbConfig` bean is autowired; 
`smbConfig` with each option fails. 5 tests, pass.
   - `SmbEncryptDataIT` (new, Samba container with the new share): without 
`encryptData` the encrypted share refuses the connection with 
`STATUS_ACCESS_DENIED`. With `encryptData=true` a file is written and consumed. 
2 tests, pass. This needs the changed `camel-test-infra-smb`, which I installed 
into a private scratch Maven repo for the run.
   - Full camel-smb suite with Docker: `mvn verify` in `components/camel-smb`: 
31 unit tests and 88 ITs, all pass (with the scratch-installed 
`camel-test-infra-smb`).
   
   Not tested: `connectTimeout` against an unreachable host. The unit test 
checks only that the value is bound; smbj's `ProxySocketFactory` uses it in 
`Socket.connect`.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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