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

   ## Description
   
   JIRA: [CAMEL-28109](https://issues.apache.org/jira/browse/CAMEL-28109)
   
   The SNMPv3 producers, the trap producer and the `POLL` consumer of 
camel-snmp registered their USM in SNMP4J's `SecurityModels.getInstance()`, a 
registry of the whole JVM that holds one USM per security model, and the SNMP4J 
sessions they created looked the USM up there for every request. With more than 
one SNMPv3 endpoint in an application, the endpoint that started last decided 
the user of all SNMPv3 producers and poll consumers: the requests of the other 
endpoints failed with `Unknown security name`, or were sent with a user that is 
not the one configured on the endpoint. Stopping one producer removed the USM, 
and the endpoints still running then failed with `Unsupported security model`. 
The `TRAP` consumer already used its own dispatcher and USM.
   
   ## Changes
   
   - `SnmpHelper.createMessageDispatcher(endpoint, usm)` (moved from 
`SnmpTrapConsumer`) builds a message dispatcher with only the message 
processing models of the `snmpVersion`: `MPv1` and `MPv2c`, or `MPv3` with the 
USM of the endpoint. The producers, the trap producer, the `POLL` consumer and 
the `TRAP` consumer all use it, and Camel no longer registers or removes 
anything in `SecurityModels.getInstance()`.
   - `SnmpHelper.createUSM` registers the default security protocols of SNMP4J, 
as `new Snmp(dispatcher, transport)` does not (the producers got them before 
from `new Snmp(transport)`). The producers still build the USM when they start, 
so a bad passphrase still fails at startup.
   - The `POLL` consumer closes its `Snmp` session when it stops (also stops 
its timer).
   - `authenticationProtocol` accepts the SHA-2 protocols of SNMP4J (RFC 7860): 
`HMAC128SHA224`, `HMAC192SHA256`, `HMAC256SHA384` and `HMAC384SHA512`. These 
are registered by SNMP4J by default, unlike `MD5` and `SHA1`. Option 
description, component doc and generated metadata updated.
   - Upgrade guide entry in `camel-4x-upgrade-guide-4_25.adoc`: a USM that the 
application adds to `SecurityModels.getInstance()` is no longer used by the 
Camel endpoints.
   
   ## Tests
   
   - New `TwoSnmpV3EndpointsTest`: a `POLL` consumer and two producers with 
different SNMPv3 users against the in-JVM responder. Every endpoint gets its 
responses, nothing is registered in `SecurityModels.getInstance()`, and 
stopping one producer leaves the other producer and the poll consumer working. 
Without the change in `src/main`, both tests fail (`Unknown security name`, 
then `Unsupported security model`).
   - `ProducerTest.testSnmpProducerWithSha256Authentication`: an `authNoPriv` 
request with `authenticationProtocol=HMAC192SHA256` (checked that it fails with 
a wrong passphrase).
   - All 46 tests of camel-snmp pass.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 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