This is an automated email from the ASF dual-hosted git repository.

oscerd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new e601c4a3c54b CAMEL-21955: camel-ibm-secrets-manager - add Secrets Dev 
Console (#25013)
e601c4a3c54b is described below

commit e601c4a3c54bd1a888ff72ca660951d9c2900169
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Jul 22 15:02:57 2026 +0200

    CAMEL-21955: camel-ibm-secrets-manager - add Secrets Dev Console (#25013)
    
    IBM Secrets Manager was the only supported secrets backend without a dev 
console. Add one following the AWS pattern, reporting service URL, refresh 
state, Event Stream topic/servers, last check/reload times and the secrets in 
use. Only non-sensitive configuration is reported.
    
    Co-authored-by: Claude Fable 5 <[email protected]>
---
 .../apache/camel/catalog/dev-consoles.properties   |   1 +
 .../camel/catalog/dev-consoles/ibm-secrets.json    |  15 ++
 .../camel-ibm/camel-ibm-secrets-manager/pom.xml    |   4 +
 .../org/apache/camel/dev-console/ibm-secrets.json  |  15 ++
 .../org/apache/camel/dev-console/ibm-secrets       |   2 +
 .../org/apache/camel/dev-consoles.properties       |   7 +
 .../ibm/secrets/manager/SecretsDevConsole.java     | 159 +++++++++++++++++++++
 7 files changed, 203 insertions(+)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
index f91f5034b386..434dd5ca3d55 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles.properties
@@ -24,6 +24,7 @@ hashicorp-secrets
 health
 heap-dump
 heap-histogram
+ibm-secrets
 inflight
 internal-tasks
 java-security
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/ibm-secrets.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/ibm-secrets.json
new file mode 100644
index 000000000000..ae5ff13637c5
--- /dev/null
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dev-consoles/ibm-secrets.json
@@ -0,0 +1,15 @@
+{
+  "console": {
+    "kind": "console",
+    "group": "camel",
+    "name": "ibm-secrets",
+    "title": "IBM Secrets",
+    "description": "IBM Secrets Manager",
+    "deprecated": false,
+    "javaType": 
"org.apache.camel.component.ibm.secrets.manager.SecretsDevConsole",
+    "groupId": "org.apache.camel",
+    "artifactId": "camel-ibm-secrets-manager",
+    "version": "4.22.0-SNAPSHOT"
+  }
+}
+
diff --git a/components/camel-ibm/camel-ibm-secrets-manager/pom.xml 
b/components/camel-ibm/camel-ibm-secrets-manager/pom.xml
index c13e15d1f39a..8c470b76acd4 100644
--- a/components/camel-ibm/camel-ibm-secrets-manager/pom.xml
+++ b/components/camel-ibm/camel-ibm-secrets-manager/pom.xml
@@ -42,6 +42,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-util-json</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>com.ibm.cloud</groupId>
diff --git 
a/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/org/apache/camel/dev-console/ibm-secrets.json
 
b/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/org/apache/camel/dev-console/ibm-secrets.json
new file mode 100644
index 000000000000..ae5ff13637c5
--- /dev/null
+++ 
b/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/org/apache/camel/dev-console/ibm-secrets.json
@@ -0,0 +1,15 @@
+{
+  "console": {
+    "kind": "console",
+    "group": "camel",
+    "name": "ibm-secrets",
+    "title": "IBM Secrets",
+    "description": "IBM Secrets Manager",
+    "deprecated": false,
+    "javaType": 
"org.apache.camel.component.ibm.secrets.manager.SecretsDevConsole",
+    "groupId": "org.apache.camel",
+    "artifactId": "camel-ibm-secrets-manager",
+    "version": "4.22.0-SNAPSHOT"
+  }
+}
+
diff --git 
a/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/services/org/apache/camel/dev-console/ibm-secrets
 
b/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/services/org/apache/camel/dev-console/ibm-secrets
new file mode 100644
index 000000000000..390033fdfc92
--- /dev/null
+++ 
b/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/services/org/apache/camel/dev-console/ibm-secrets
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.ibm.secrets.manager.SecretsDevConsole
diff --git 
a/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties
 
b/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties
new file mode 100644
index 000000000000..d6043f1d814f
--- /dev/null
+++ 
b/components/camel-ibm/camel-ibm-secrets-manager/src/generated/resources/META-INF/services/org/apache/camel/dev-consoles.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+dev-consoles=ibm-secrets
+groupId=org.apache.camel
+artifactId=camel-ibm-secrets-manager
+version=4.22.0-SNAPSHOT
+projectName=Camel :: IBM :: Secrets Manager
+projectDescription=Camel IBM Secrets Manager Component
diff --git 
a/components/camel-ibm/camel-ibm-secrets-manager/src/main/java/org/apache/camel/component/ibm/secrets/manager/SecretsDevConsole.java
 
b/components/camel-ibm/camel-ibm-secrets-manager/src/main/java/org/apache/camel/component/ibm/secrets/manager/SecretsDevConsole.java
new file mode 100644
index 000000000000..48a4ff45f384
--- /dev/null
+++ 
b/components/camel-ibm/camel-ibm-secrets-manager/src/main/java/org/apache/camel/component/ibm/secrets/manager/SecretsDevConsole.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ibm.secrets.manager;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import 
org.apache.camel.component.ibm.secrets.manager.vault.IBMEventStreamReloadTriggerTask;
+import org.apache.camel.spi.PeriodTaskScheduler;
+import org.apache.camel.spi.PropertiesFunction;
+import org.apache.camel.spi.annotations.DevConsole;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.console.AbstractDevConsole;
+import org.apache.camel.util.TimeUtils;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.camel.vault.IBMSecretsManagerVaultConfiguration;
+
+@DevConsole(name = "ibm-secrets", displayName = "IBM Secrets", description = 
"IBM Secrets Manager")
+public class SecretsDevConsole extends AbstractDevConsole {
+
+    private IBMSecretsManagerPropertiesFunction propertiesFunction;
+    private IBMEventStreamReloadTriggerTask secretsRefreshTask;
+
+    public SecretsDevConsole() {
+        super("camel", "ibm-secrets", "IBM Secrets", "IBM Secrets Manager");
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+
+        if 
(getCamelContext().getPropertiesComponent().hasPropertiesFunction("ibm")) {
+            PropertiesFunction pf = 
getCamelContext().getPropertiesComponent().getPropertiesFunction("ibm");
+            if (pf instanceof IBMSecretsManagerPropertiesFunction 
ibmPropertiesFunction) {
+                propertiesFunction = ibmPropertiesFunction;
+            }
+        }
+        IBMSecretsManagerVaultConfiguration ibm
+                = 
getCamelContext().getVaultConfiguration().getIBMSecretsManagerVaultConfiguration();
+        if (ibm != null && ibm.isRefreshEnabled()) {
+            PeriodTaskScheduler scheduler = 
PluginHelper.getPeriodTaskScheduler(getCamelContext());
+            secretsRefreshTask = 
scheduler.getTaskByType(IBMEventStreamReloadTriggerTask.class);
+        }
+    }
+
+    @Override
+    protected String doCallText(Map<String, Object> options) {
+        StringBuilder sb = new StringBuilder();
+
+        if (propertiesFunction != null) {
+            IBMSecretsManagerVaultConfiguration ibm
+                    = 
getCamelContext().getVaultConfiguration().getIBMSecretsManagerVaultConfiguration();
+            sb.append("IBM Secrets Manager:");
+            if (ibm != null) {
+                sb.append(String.format("%n    Service URL: %s", 
ibm.getServiceUrl()));
+                sb.append("\n    Login: IAM Token");
+                sb.append(String.format("%n    Refresh Enabled: %s", 
ibm.isRefreshEnabled()));
+                if (ibm.isRefreshEnabled()) {
+                    sb.append(String.format("%n    Event Stream Topic: %s", 
ibm.getEventStreamTopic()));
+                    sb.append(String.format("%n    Event Stream Bootstrap 
Servers: %s",
+                            ibm.getEventStreamBootstrapServers()));
+                }
+            }
+            if (secretsRefreshTask != null) {
+                Instant last = secretsRefreshTask.getLastCheckTime();
+                String s = last != null ? 
TimeUtils.printSince(last.toEpochMilli()) : "none";
+                sb.append(String.format("%n    Last Check: %s", s));
+                last = secretsRefreshTask.getLastReloadTime();
+                s = last != null ? TimeUtils.printSince(last.toEpochMilli()) : 
"none";
+                sb.append(String.format("%n    Last Reload: %s", s));
+            }
+            sb.append("\n\nSecrets in use:");
+
+            List<String> sorted = new 
ArrayList<>(propertiesFunction.getSecrets());
+            Collections.sort(sorted);
+
+            for (String sec : sorted) {
+                Instant last = secretsRefreshTask != null ? 
secretsRefreshTask.getUpdates().get(sec) : null;
+                String age = last != null ? 
TimeUtils.printSince(last.toEpochMilli()) : null;
+                if (age != null) {
+                    sb.append(String.format("%n    %s (age: %s)", sec, age));
+                } else {
+                    sb.append(String.format("%n    %s", sec));
+                }
+            }
+        }
+
+        return sb.toString();
+    }
+
+    @Override
+    protected JsonObject doCallJson(Map<String, Object> options) {
+        JsonObject root = new JsonObject();
+
+        if (propertiesFunction != null) {
+            IBMSecretsManagerVaultConfiguration ibm
+                    = 
getCamelContext().getVaultConfiguration().getIBMSecretsManagerVaultConfiguration();
+            if (ibm != null) {
+                root.put("serviceUrl", ibm.getServiceUrl());
+                root.put("login", "IAM Token");
+                root.put("refreshEnabled", ibm.isRefreshEnabled());
+                if (ibm.isRefreshEnabled()) {
+                    root.put("eventStreamTopic", ibm.getEventStreamTopic());
+                    root.put("eventStreamBootstrapServers", 
ibm.getEventStreamBootstrapServers());
+                }
+            }
+            if (secretsRefreshTask != null) {
+                Instant last = secretsRefreshTask.getLastCheckTime();
+                if (last != null) {
+                    root.put("lastCheckTimestamp", last.toEpochMilli());
+                    root.put("lastCheckAge", 
TimeUtils.printSince(last.toEpochMilli()));
+                }
+                last = secretsRefreshTask.getLastReloadTime();
+                if (last != null) {
+                    root.put("lastReloadTimestamp", last.toEpochMilli());
+                    root.put("lastReloadAge", 
TimeUtils.printSince(last.toEpochMilli()));
+                }
+            }
+
+            JsonArray arr = new JsonArray();
+            List<String> sorted = new 
ArrayList<>(propertiesFunction.getSecrets());
+            Collections.sort(sorted);
+
+            for (String sec : sorted) {
+                JsonObject jo = new JsonObject();
+                jo.put("name", sec);
+                Instant last = secretsRefreshTask != null ? 
secretsRefreshTask.getUpdates().get(sec) : null;
+                if (last != null) {
+                    jo.put("timestamp", last.toEpochMilli());
+                    jo.put("age", TimeUtils.printSince(last.toEpochMilli()));
+                }
+                arr.add(jo);
+            }
+            if (!arr.isEmpty()) {
+                root.put("secrets", arr);
+            }
+        }
+
+        return root;
+    }
+}

Reply via email to