Dhairya-007 opened a new pull request, #29955:
URL: https://github.com/apache/camel/pull/29955
## Problem
`KeycloakProducer` reads every header it honours explicitly by constant -
`exchange.getIn().getHeader(KeycloakConstants.REALM_NAME, String.class)` and so
on. Of the 66 headers `KeycloakConstants` publishes with `@Metadata`, 11 appear
nowhere in the main sources at all: not read, not written, not referenced from
a test.
They are not obscure corners. Each sits beside one that does work, so the
component docs read as if a whole set were supported when only part of it is:
| header | what actually carries the value |
| --- | --- |
| `CamelKeycloakRoleId` | the role operations take `CamelKeycloakRoleName` |
| `CamelKeycloakIdpId` | the identity provider operations take
`CamelKeycloakIdpAlias` |
| `CamelKeycloakResourceName`, `CamelKeycloakResourceType`,
`CamelKeycloakResourceUri` | a `ResourceRepresentation` as the POJO request
body |
| `CamelKeycloakPolicyName`, `CamelKeycloakPolicyType` | a
`PolicyRepresentation` as the POJO request body |
| `CamelKeycloakPermissionName` | a `PolicyRepresentation` as the POJO
request body |
| `CamelKeycloakScopeName` | its representation as the POJO request body |
| `CamelKeycloakCredentialType` | a `CredentialRepresentation` as the POJO
request body |
| `CamelKeycloakBatchSize` | nothing - see below |
`createResource` is the clearest case. The docs offer
`CamelKeycloakResourceName`, `...ResourceType` and `...ResourceUri`, and the
producer does this:
```java
if (getConfiguration().isPojoRequest()) {
ResourceRepresentation resourceRepresentation = getPojoRequest(exchange,
ResourceRepresentation.class);
...
} else {
throw new IllegalArgumentException("Create resource requires POJO
request with ResourceRepresentation");
}
```
So setting the three headers and sending the exchange fails with a message
about a POJO request, with nothing to connect that to the headers the docs told
you to use.
`CamelKeycloakBatchSize` is documented as "Batch size for bulk operations",
but the bulk operations have no batching to size - `bulkCreateUsers` and its
siblings walk the list and issue one call per element:
```java
for (UserRepresentation user : users) {
...
Response response =
checkResponse(keycloakClient.realm(realmName).users().create(user),
"createUser");
```
## Fix
Deprecate the 11 constants, each with a `deprecationNote` naming what to use
instead, the same treatment `camelInfluxDB.RetentionPolicy` got in #29667. The
catalog then marks them deprecated and shows the note rather than advertising
them as supported, and the constants themselves stay, so nothing stops
compiling.
The alternative would be to implement them - make the create operations fall
back to building the representation from headers when `pojoRequest` is off.
That is a feature rather than a fix and I did not want to guess at the intended
shape, but I am happy to do it instead if you would rather have the headers
work than see them deprecated.
The regenerated `keycloak.json` files are included.
--
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]