[
https://issues.apache.org/jira/browse/CAMEL-24637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150667#comment-18150667
]
Karol Krawczyk commented on CAMEL-24637:
----------------------------------------
I went through the code on main again, including CAMEL-26692, and I am closing
this one with documentation only, as CAMEL-24639 did for camel-http. Option 1
of my earlier comment, not option 2.
What heals on a reload, without a SecretRotationAware implementation:
* {{InternalRouteController#reloadAllRoutes}} removes the routes and clears the
endpoint registry, so JMS endpoints are created again with the newly resolved
{{username}}/{{password}} of their URI.
* On Camel Main, {{BaseMainSupport#doAutoConfigurationFromProperties}}
recreates the component when a {{camel.component.jms.*}} placeholder option is
re-applied.
* [~fmariani], your note checks out: the adapter cache is keyed by username,
but {{CredentialsConnectionFactory#isFor}} compares the connection factory
instance and the password too, so a rotated password with the same username
gets a new {{UserCredentialsConnectionFactoryAdapter}}.
{{JmsComponentCredentialsConnectionFactoryTest#newPasswordGivesANewConnectionFactory}}
already covers it. Clearing the cache on rotation would change nothing.
Why not the narrow reset:
* Spring's {{SingleConnectionFactory#createConnection(String, String)}} throws
"does not support custom username and password", so a
{{CachingConnectionFactory}} can never sit behind the component's credentials.
Its credentials always come from the factory it wraps, a bean the reload does
not touch ({{bindReloadedBeans}} leaves existing {{camel.beans.*}} beans
alone). Resetting it would reopen connections with the same, possibly revoked,
credentials, on every reload of any kind, and drop connections that other code
uses.
* {{pooled-jms}} is still test scope, and its pool is keyed by username and
password anyway: with credentials on the component or the endpoint, a rotated
password already leads to new connections.
The jms page gets a "Rotated credentials" section that says what is refreshed
(URI and component credentials, a new adapter, pooled-jms following with new
connections) and what is not (a broker client factory keeps its credentials, a
pool or {{CachingConnectionFactory}} keeps its open connections). It recommends
setting rotating credentials on the component or the endpoints, or else having
the application recreate the factory. The URI example wraps the vault
placeholder in {{RAW()}}, because a generated secret with {{+}}, {{&}} or {{%}}
would otherwise break the URI after a rotation.
_Reported by Claude Code on behalf of Karol Krawczyk_
> camel-jms: implement SecretRotationAware to re-authenticate on secret rotation
> ------------------------------------------------------------------------------
>
> Key: CAMEL-24637
> URL: https://issues.apache.org/jira/browse/CAMEL-24637
> Project: Camel
> Issue Type: Sub-task
> Components: camel-jms
> Reporter: Andrea Cosentino
> Assignee: Karol Krawczyk
> Priority: Major
>
> Sub-task of CAMEL-24636.
> Adopt the {{SecretRotationAware}} SPI in camel-jms.
> {{JmsComponent#setUsername}} and {{setPassword}} delegate to a shared
> {{JmsConfiguration}}, whose values are resolved from property placeholders
> once at configure time. The {{ConnectionFactory}} itself is normally a
> registry bean (often a pooled one) created at bootstrap with the credentials
> valid at that moment.
> Neither is refreshed by {{RouteController.reloadAllRoutes()}}, so after a
> secret rotation the component keeps presenting the old credentials.
> On {{onSecretRotation}} the component should re-resolve its configured
> username and password and re-authenticate the connection factory in place,
> closing and re-establishing pooled connections as needed.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)