oscerd opened a new pull request, #29710: URL: https://github.com/apache/camel/pull/29710
Fixes [CAMEL-26879](https://issues.apache.org/jira/browse/CAMEL-26879), the follow-up of CAMEL-26559 (#29144), which added the opa, openfga and spiffe security beans to the bean catalog and left the others out. ### Problem A YAML route that declares `KeycloakSecurityPolicy` or `ShiroSecurityPolicy` under `beans:` fails under `camel run` unless the component is added with `--dep`: ``` $ camel run policy.yaml --camel-version=4.23.0 Caused by: java.lang.ClassNotFoundException: org.apache.camel.component.keycloak.security.KeycloakSecurityPolicy ``` YAML beans are created while the file is pre-parsed, and `camel run` finds the jar of a missing bean class only through the known dependencies (component classes only) or the catalog's pojo-bean metadata, where neither policy had an entry. ### Change The same as #29144: `@Metadata(label = "bean", ...)` and `@Configurer(metadataOnly = true)` on both classes and `@Metadata` on each option. The catalog gets `beans/KeycloakSecurityPolicy.json` and `beans/ShiroSecurityPolicy.json` with their coordinates, `interfaceType` `AuthorizationPolicy` and their options; `ArtifactUtils` is regenerated to name their artifacts. - Both classes already keep their options in fields, so nothing else changes. Keycloak's internal `keycloakClient`, `tokenIntrospector` and `publicKeyResolver` have no setter and are not options. - `clientSecret`, `username` and `password` (Keycloak) and `passPhrase` (Shiro) are marked `security = "secret"`, as the keycloak endpoint marks its credentials. - `ShiroSecurityPolicy.alwaysReauthenticate` is `false` as a field but the constructor sets it to `true`, so the catalog documents `true`. The Shiro INI file is a constructor argument, which a YAML bean passes with `constructors:`; the bean description says so. ### Tests - `CamelCatalogTest.testSecurityBeanNamesItsComponent` gains the two classes: their catalog entries name the class, `org.apache.camel` with the right artifact, `AuthorizationPolicy` and a key option, which is the lookup `camel run` makes. - `KeycloakSecurityPolicyBindingTest` and `ShiroSecurityPolicyBindingTest` bind the options from a YAML-shaped map through `PropertyBindingSupport.setPropertiesOnTarget`, the call the YAML DSL makes, with the generated configurers in place. The Keycloak one checks `requiredRoles` given as a string goes to the `String` setter, despite the `List` overload; the Shiro one checks `passPhrase` from a string, `rolesList[0]`/`[1]` and the `alwaysReauthenticate` default. Full reactor (`clean install -DskipTests`) green; camel-keycloak (177), camel-shiro (29) and camel-catalog (1133) tests green. ### End-to-end `camel run`, the launcher from this build with `--maven-settings` pointing at the build's local repository, on a YAML file that declares both beans and has no `keycloak:` or `shiro:` endpoint, without `--dep`: `camel-keycloak` and `camel-shiro`, neither of which is on the launcher's classpath, are resolved on demand and both beans load with their properties (`realm=camel`, `requiredRoles` as `[admin, user]`, `alwaysReauthenticate=false`). With 4.23.0, the same file fails with the `ClassNotFoundException` above. _Claude Code on behalf of oscerd_ 🤖 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]
