davsclaus opened a new pull request, #3223:
URL: https://github.com/apache/camel-kamelets/pull/3223
Part of #3170: `infinispan-source` and `infinispan-sink` can connect to
Infinispan or Red Hat Data Grid with TLS, and `infinispan-sink` can do
`PUTIFABSENT`, `REPLACE` and `REMOVE` and give entries a lifespan and a max
idle time.
### The options
| Option | Kamelets | Template mapping | What it does |
|---|---|---|---|
| `sslTruststoreLocation` | both |
`configurationProperties[trust_store_file_name]={{?sslTruststoreLocation}}` | A
PKCS12 or JKS trust store, or a PEM file, with the certificate of the server or
of its CA. Setting it turns on TLS. |
| `sslTruststorePassword` | both |
`configurationProperties[trust_store_password]=RAW({{?sslTruststorePassword}})`
| The password of the trust store. Not needed for a PEM file. `format:
password`. |
| `sslSniHostName` | both |
`configurationProperties[sni_host_name]={{?sslSniHostName}}` | The host name in
the certificate of the server. Required with TLS. |
| `operation` | sink | `operation={{?operation}}` | `PUT` (when not set),
`PUTIFABSENT`, `REPLACE` or `REMOVE`. |
| `lifespan`, `lifespanTimeUnit` | sink | headers
`CamelInfinispanLifespanTime` and `CamelInfinispanTimeUnit`, set only when
`lifespan` is set | Removes the entry this long after it is stored. The unit is
`SECONDS` by default. |
| `maxIdle`, `maxIdleTimeUnit` | sink | headers `CamelInfinispanMaxIdleTime`
and `CamelInfinispanMaxIdleTimeUnit`, set only when `maxIdle` is set | Removes
the entry after it has not been read or written for this long. The unit is
`SECONDS` by default. |
- **TLS without a bean.** The component's `configurationProperties` map
option passes Hot Rod client properties (`infinispan.client.hotrod.*`; the
component adds the prefix). In an endpoint URI it binds as
`configurationProperties[key]=value`.
- **No `ssl` switch.** A trust store or an SNI host name turns on TLS. With
TLS, the Hot Rod 16.3 client needs both:
- Without a trust store it fails at start with `ISPN004024: SSL Enabled
but no TrustStore specified`. It does not fall back to the certificates Java
trusts, so a boolean such as `ssl: true` on its own could never connect.
- Hostname validation is on by default and needs an SNI host name
(`ISPN004112`).
The descriptions say all this. Turning off hostname validation is left out
on purpose.
- **Defaults.** None of the new options has a `default`, except the two time
units. Those are used only inside the step that runs when `lifespan` or
`maxIdle` is set. Without them, a lifespan with no unit is silently ignored:
the component only logs a warning. With the new options unset, the endpoint
URIs match `main` exactly, and the template sets no header.
- **Expiry as headers.** The component has no endpoint options for lifespan
or max idle; it reads them only from headers. The template sets those headers
inside a `choice` on `'{{?lifespan}}' != ''`, so an unset option does not
overwrite anything.
- **`maxIdle` alone.** The component applies a max idle time only together
with a lifespan. When only `maxIdle` is set, the template also sends a lifespan
of `-1` (infinite), so `maxIdle` works on its own.
- **`REMOVE`.** The sink always sends the body as the value. For `REMOVE`,
an empty body deletes the entry. A body deletes it only when the stored value
is equal to the body, and the body afterwards is `true` or `false`. The
descriptions say this.
- **Not added:** a client key store for mutual TLS. It would map the same
way (`key_store_file_name`, `key_store_password`) and can be added if someone
needs it.
- **Descriptions and partial pages.** The "Input", "Output" and "Good to
know" paragraphs of both Kamelets are updated. The sink partial has a table of
the operations, an "Expiration" section, and an example with TLS and a
lifespan. The source partial has an example with TLS.
### Verification
Tested with Camel JBang 4.24.0-SNAPSHOT against
`quay.io/infinispan/server:16.3` in Docker. Two servers were used, each with a
user login (`SCRAM-SHA-512`):
- One with TLS on its security realm, using a self-signed PKCS12 key store
generated with `keytool` (CN and SAN `localhost`).
- One without TLS, as the baseline.
The entries were checked through the REST API of the server, including its
`timeToLiveSeconds` and `maxIdleTimeSeconds` response headers.
| Case | Result |
|---|---|
| Options unset, sink and source, Kamelet from `main` and from this branch,
server without TLS | `camel get endpoint` shows identical endpoint URIs. The
sink stores the entry and the source receives the event |
| Sink: `sslTruststoreLocation` (PKCS12) + password + `sslSniHostName:
localhost`, TLS server | Stored |
| The same with a JKS trust store | Stored |
| The same with a PEM file (the server certificate) and no password | Stored
|
| The same with the password `p&a+ss%w#rd` (`RAW()`) | Stored |
| Source with the trust store and the SNI host name, TLS server | Event
`CLIENT_CACHE_ENTRY_CREATED` received, also with a PEM file |
| Options unset, TLS server: sink from `main` and from this branch, source
from this branch | Both fail: `ISPN004071: Connection ... was closed while
waiting for response`. Nothing is stored |
| Trust store with another certificate, sink and source | Fails:
`SSLHandshakeException: No trusted certificate found` |
| Wrong trust store password | Fails at start: `keystore password was
incorrect` |
| PKCS12 trust store without a password | Fails at start: `ISPN004026: A
password is required to open the TrustStore` |
| Trust store without `sslSniHostName` | Fails at start: `ISPN004112: The
SNI hostname is required when hostname validation is enabled` |
| `sslSniHostName: wronghost.example.com` | Fails: `No subject alternative
DNS name matching wronghost.example.com found` |
| `sslSniHostName` without a trust store | Fails at start: `ISPN004024: SSL
Enabled but no TrustStore specified` |
| `operation` unset | `PUT`: stored. Body afterwards empty |
| `PUTIFABSENT`, key with value `old` / new key | `old` kept / `new` stored |
| `REPLACE`, key with value `old` / missing key | Replaced by `new` / not
created |
| `REMOVE`, empty body | Entry deleted (REST 404). Body afterwards empty |
| `REMOVE`, missing key | Nothing happens. Body afterwards empty |
| `REMOVE`, body `y`, stored `x` | Kept. Body afterwards `false` |
| `REMOVE`, body `x`, stored `x` | Deleted. Body afterwards `true` |
| `lifespan: 4` | `timeToLiveSeconds: 4`; present after 3 s, gone after 5 s |
| `lifespan: 4000`, `lifespanTimeUnit: MILLISECONDS` | `timeToLiveSeconds:
4`; gone after 5 s |
| `maxIdle: 4` alone | `maxIdleTimeSeconds: 4`, no lifespan. A read after
2.5 s kept it alive past 5 s; gone 5 s after the last read |
| `lifespan: 2` `HOURS`, `maxIdle: 30` `MINUTES` | `timeToLiveSeconds:
7200`, `maxIdleTimeSeconds: 1800` |
| `REPLACE` with `lifespan: 600`; `PUTIFABSENT` with `lifespan: 700` |
`timeToLiveSeconds` 600 and 700 |
| `lifespan` unset, cache with a 15 s lifespan on the server |
`timeToLiveSeconds: 15`: the server setting applies |
| All options set (TLS, `PUTIFABSENT`, `lifespan: 90`, `maxIdle: 30`) |
`camel get endpoint` shows `operation=PUTIFABSENT` and the three
`configurationProperties[...]` parameters. Stored with TTL 90 and max idle 30 |
`./mvnw clean verify -DskipTests` and then `./mvnw clean verify` passed from
the root. Before building, the library copies of the two Kamelets were
refreshed with `./mvnw -pl library/camel-kamelets
resources:copy-resources@copy-resource-one`. The build regenerated
`kamelets-index.json`.
_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]