You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2025/10/08 10:15:08 UTC
(camel) 01/01: CAMEL-22509 - Camel-docling: Add Authentication mechanism to docling-serve side
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch CAMEL-22509
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 67719549d80e9911b35e8eb4cbec6da480d4852c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Oct 8 12:14:06 2025 +0200
CAMEL-22509 - Camel-docling: Add Authentication mechanism to docling-serve side
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../apache/camel/catalog/components/docling.json | 24 ++-
.../apache/camel/catalog/main/sensitive-keys.json | 1 +
.../docling/DoclingComponentConfigurer.java | 24 +++
.../docling/DoclingConfigurationConfigurer.java | 24 +++
.../docling/DoclingEndpointConfigurer.java | 24 +++
.../docling/DoclingEndpointUriFactory.java | 10 +-
.../apache/camel/component/docling/docling.json | 24 ++-
.../src/main/docs/docling-component.adoc | 184 +++++++++++++++++++++
.../component/docling/AuthenticationScheme.java | 39 +++++
.../component/docling/DoclingConfiguration.java | 49 ++++++
.../camel/component/docling/DoclingProducer.java | 12 +-
.../component/docling/DoclingServeClient.java | 57 ++++++-
.../java/org/apache/camel/util/SensitiveUtils.java | 4 +-
.../dsl/DoclingComponentBuilderFactory.java | 71 ++++++++
.../dsl/DoclingEndpointBuilderFactory.java | 78 +++++++++
15 files changed, 601 insertions(+), 24 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/docling.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/docling.json
index 518cde34a089..c04a0fe85843 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/docling.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/docling.json
@@ -35,10 +35,14 @@
"outputFormat": { "index": 8, "kind": "property", "displayName": "Output Format", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "markdown", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Output format for document conversion" },
"useDoclingServe": { "index": 9, "kind": "property", "displayName": "Use Docling Serve", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Use docling-serve API instead of CLI command" },
"autowiredEnabled": { "index": 10, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching [...]
- "doclingCommand": { "index": 11, "kind": "property", "displayName": "Docling Command", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Path to Docling Python executable or command" },
- "processTimeout": { "index": 12, "kind": "property", "displayName": "Process Timeout", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Timeout for Docling process execution in milliseconds" },
- "workingDirectory": { "index": 13, "kind": "property", "displayName": "Working Directory", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Working directory for Docling execution" },
- "maxFileSize": { "index": 14, "kind": "property", "displayName": "Max File Size", "group": "security", "label": "security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 52428800, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Maximum file size in bytes for processing" }
+ "convertEndpoint": { "index": 11, "kind": "property", "displayName": "Convert Endpoint", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "\/v1\/convert\/source", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Docling-serve API convert endp [...]
+ "doclingCommand": { "index": 12, "kind": "property", "displayName": "Docling Command", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Path to Docling Python executable or command" },
+ "processTimeout": { "index": 13, "kind": "property", "displayName": "Process Timeout", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Timeout for Docling process execution in milliseconds" },
+ "workingDirectory": { "index": 14, "kind": "property", "displayName": "Working Directory", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Working directory for Docling execution" },
+ "apiKeyHeader": { "index": 15, "kind": "property", "displayName": "Api Key Header", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "X-API-Key", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Header name for API key authentication" },
+ "authenticationScheme": { "index": 16, "kind": "property", "displayName": "Authentication Scheme", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.docling.AuthenticationScheme", "enum": [ "NONE", "BEARER", "API_KEY" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "NONE", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configuration [...]
+ "authenticationToken": { "index": 17, "kind": "property", "displayName": "Authentication Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Authentication token for docling-serve API (Bearer token or API [...]
+ "maxFileSize": { "index": 18, "kind": "property", "displayName": "Max File Size", "group": "security", "label": "security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 52428800, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Maximum file size in bytes for processing" }
},
"headers": {
"CamelDoclingOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "DoclingOperations", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.docling.DoclingHeaders#OPERATION" },
@@ -61,9 +65,13 @@
"outputFormat": { "index": 7, "kind": "parameter", "displayName": "Output Format", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "markdown", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Output format for document conversion" },
"useDoclingServe": { "index": 8, "kind": "parameter", "displayName": "Use Docling Serve", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Use docling-serve API instead of CLI command" },
"lazyStartProducer": { "index": 9, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produc [...]
- "doclingCommand": { "index": 10, "kind": "parameter", "displayName": "Docling Command", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Path to Docling Python executable or command" },
- "processTimeout": { "index": 11, "kind": "parameter", "displayName": "Process Timeout", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Timeout for Docling process execution in milliseconds" },
- "workingDirectory": { "index": 12, "kind": "parameter", "displayName": "Working Directory", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Working directory for Docling execution" },
- "maxFileSize": { "index": 13, "kind": "parameter", "displayName": "Max File Size", "group": "security", "label": "security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 52428800, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Maximum file size in bytes for processing" }
+ "convertEndpoint": { "index": 10, "kind": "parameter", "displayName": "Convert Endpoint", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "\/v1\/convert\/source", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Docling-serve API convert end [...]
+ "doclingCommand": { "index": 11, "kind": "parameter", "displayName": "Docling Command", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Path to Docling Python executable or command" },
+ "processTimeout": { "index": 12, "kind": "parameter", "displayName": "Process Timeout", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Timeout for Docling process execution in milliseconds" },
+ "workingDirectory": { "index": 13, "kind": "parameter", "displayName": "Working Directory", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Working directory for Docling execution" },
+ "apiKeyHeader": { "index": 14, "kind": "parameter", "displayName": "Api Key Header", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "X-API-Key", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Header name for API key authentication" },
+ "authenticationScheme": { "index": 15, "kind": "parameter", "displayName": "Authentication Scheme", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.docling.AuthenticationScheme", "enum": [ "NONE", "BEARER", "API_KEY" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "NONE", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configuratio [...]
+ "authenticationToken": { "index": 16, "kind": "parameter", "displayName": "Authentication Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Authentication token for docling-serve API (Bearer token or API [...]
+ "maxFileSize": { "index": 17, "kind": "parameter", "displayName": "Max File Size", "group": "security", "label": "security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 52428800, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Maximum file size in bytes for processing" }
}
}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json
index 2fea4455676c..d97480c5a54e 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/sensitive-keys.json
@@ -11,6 +11,7 @@
"apipassword",
"apiuser",
"apiusername",
+ "authenticationtoken",
"authkey",
"authorizationtoken",
"blobaccesskey",
diff --git a/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingComponentConfigurer.java b/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingComponentConfigurer.java
index 840207c9d1c5..270856eb5ef8 100644
--- a/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingComponentConfigurer.java
+++ b/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingComponentConfigurer.java
@@ -30,11 +30,19 @@ public class DoclingComponentConfigurer extends PropertyConfigurerSupport implem
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
DoclingComponent target = (DoclingComponent) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": getOrCreateConfiguration(target).setApiKeyHeader(property(camelContext, java.lang.String.class, value)); return true;
+ case "authenticationscheme":
+ case "authenticationScheme": getOrCreateConfiguration(target).setAuthenticationScheme(property(camelContext, org.apache.camel.component.docling.AuthenticationScheme.class, value)); return true;
+ case "authenticationtoken":
+ case "authenticationToken": getOrCreateConfiguration(target).setAuthenticationToken(property(camelContext, java.lang.String.class, value)); return true;
case "autowiredenabled":
case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.docling.DoclingConfiguration.class, value)); return true;
case "contentinbody":
case "contentInBody": getOrCreateConfiguration(target).setContentInBody(property(camelContext, boolean.class, value)); return true;
+ case "convertendpoint":
+ case "convertEndpoint": getOrCreateConfiguration(target).setConvertEndpoint(property(camelContext, java.lang.String.class, value)); return true;
case "doclingcommand":
case "doclingCommand": getOrCreateConfiguration(target).setDoclingCommand(property(camelContext, java.lang.String.class, value)); return true;
case "doclingserveurl":
@@ -65,11 +73,19 @@ public class DoclingComponentConfigurer extends PropertyConfigurerSupport implem
@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": return java.lang.String.class;
+ case "authenticationscheme":
+ case "authenticationScheme": return org.apache.camel.component.docling.AuthenticationScheme.class;
+ case "authenticationtoken":
+ case "authenticationToken": return java.lang.String.class;
case "autowiredenabled":
case "autowiredEnabled": return boolean.class;
case "configuration": return org.apache.camel.component.docling.DoclingConfiguration.class;
case "contentinbody":
case "contentInBody": return boolean.class;
+ case "convertendpoint":
+ case "convertEndpoint": return java.lang.String.class;
case "doclingcommand":
case "doclingCommand": return java.lang.String.class;
case "doclingserveurl":
@@ -101,11 +117,19 @@ public class DoclingComponentConfigurer extends PropertyConfigurerSupport implem
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
DoclingComponent target = (DoclingComponent) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": return getOrCreateConfiguration(target).getApiKeyHeader();
+ case "authenticationscheme":
+ case "authenticationScheme": return getOrCreateConfiguration(target).getAuthenticationScheme();
+ case "authenticationtoken":
+ case "authenticationToken": return getOrCreateConfiguration(target).getAuthenticationToken();
case "autowiredenabled":
case "autowiredEnabled": return target.isAutowiredEnabled();
case "configuration": return target.getConfiguration();
case "contentinbody":
case "contentInBody": return getOrCreateConfiguration(target).isContentInBody();
+ case "convertendpoint":
+ case "convertEndpoint": return getOrCreateConfiguration(target).getConvertEndpoint();
case "doclingcommand":
case "doclingCommand": return getOrCreateConfiguration(target).getDoclingCommand();
case "doclingserveurl":
diff --git a/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingConfigurationConfigurer.java b/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingConfigurationConfigurer.java
index 73a53e60adea..585af1165493 100644
--- a/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingConfigurationConfigurer.java
+++ b/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingConfigurationConfigurer.java
@@ -23,8 +23,16 @@ public class DoclingConfigurationConfigurer extends org.apache.camel.support.com
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
org.apache.camel.component.docling.DoclingConfiguration target = (org.apache.camel.component.docling.DoclingConfiguration) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": target.setApiKeyHeader(property(camelContext, java.lang.String.class, value)); return true;
+ case "authenticationscheme":
+ case "authenticationScheme": target.setAuthenticationScheme(property(camelContext, org.apache.camel.component.docling.AuthenticationScheme.class, value)); return true;
+ case "authenticationtoken":
+ case "authenticationToken": target.setAuthenticationToken(property(camelContext, java.lang.String.class, value)); return true;
case "contentinbody":
case "contentInBody": target.setContentInBody(property(camelContext, boolean.class, value)); return true;
+ case "convertendpoint":
+ case "convertEndpoint": target.setConvertEndpoint(property(camelContext, java.lang.String.class, value)); return true;
case "doclingcommand":
case "doclingCommand": target.setDoclingCommand(property(camelContext, java.lang.String.class, value)); return true;
case "doclingserveurl":
@@ -53,8 +61,16 @@ public class DoclingConfigurationConfigurer extends org.apache.camel.support.com
@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": return java.lang.String.class;
+ case "authenticationscheme":
+ case "authenticationScheme": return org.apache.camel.component.docling.AuthenticationScheme.class;
+ case "authenticationtoken":
+ case "authenticationToken": return java.lang.String.class;
case "contentinbody":
case "contentInBody": return boolean.class;
+ case "convertendpoint":
+ case "convertEndpoint": return java.lang.String.class;
case "doclingcommand":
case "doclingCommand": return java.lang.String.class;
case "doclingserveurl":
@@ -84,8 +100,16 @@ public class DoclingConfigurationConfigurer extends org.apache.camel.support.com
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
org.apache.camel.component.docling.DoclingConfiguration target = (org.apache.camel.component.docling.DoclingConfiguration) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": return target.getApiKeyHeader();
+ case "authenticationscheme":
+ case "authenticationScheme": return target.getAuthenticationScheme();
+ case "authenticationtoken":
+ case "authenticationToken": return target.getAuthenticationToken();
case "contentinbody":
case "contentInBody": return target.isContentInBody();
+ case "convertendpoint":
+ case "convertEndpoint": return target.getConvertEndpoint();
case "doclingcommand":
case "doclingCommand": return target.getDoclingCommand();
case "doclingserveurl":
diff --git a/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingEndpointConfigurer.java b/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingEndpointConfigurer.java
index 8cd8bc60aff3..88e14d5862c2 100644
--- a/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingEndpointConfigurer.java
+++ b/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingEndpointConfigurer.java
@@ -23,8 +23,16 @@ public class DoclingEndpointConfigurer extends PropertyConfigurerSupport impleme
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
DoclingEndpoint target = (DoclingEndpoint) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": target.getConfiguration().setApiKeyHeader(property(camelContext, java.lang.String.class, value)); return true;
+ case "authenticationscheme":
+ case "authenticationScheme": target.getConfiguration().setAuthenticationScheme(property(camelContext, org.apache.camel.component.docling.AuthenticationScheme.class, value)); return true;
+ case "authenticationtoken":
+ case "authenticationToken": target.getConfiguration().setAuthenticationToken(property(camelContext, java.lang.String.class, value)); return true;
case "contentinbody":
case "contentInBody": target.getConfiguration().setContentInBody(property(camelContext, boolean.class, value)); return true;
+ case "convertendpoint":
+ case "convertEndpoint": target.getConfiguration().setConvertEndpoint(property(camelContext, java.lang.String.class, value)); return true;
case "doclingcommand":
case "doclingCommand": target.getConfiguration().setDoclingCommand(property(camelContext, java.lang.String.class, value)); return true;
case "doclingserveurl":
@@ -55,8 +63,16 @@ public class DoclingEndpointConfigurer extends PropertyConfigurerSupport impleme
@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": return java.lang.String.class;
+ case "authenticationscheme":
+ case "authenticationScheme": return org.apache.camel.component.docling.AuthenticationScheme.class;
+ case "authenticationtoken":
+ case "authenticationToken": return java.lang.String.class;
case "contentinbody":
case "contentInBody": return boolean.class;
+ case "convertendpoint":
+ case "convertEndpoint": return java.lang.String.class;
case "doclingcommand":
case "doclingCommand": return java.lang.String.class;
case "doclingserveurl":
@@ -88,8 +104,16 @@ public class DoclingEndpointConfigurer extends PropertyConfigurerSupport impleme
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
DoclingEndpoint target = (DoclingEndpoint) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "apikeyheader":
+ case "apiKeyHeader": return target.getConfiguration().getApiKeyHeader();
+ case "authenticationscheme":
+ case "authenticationScheme": return target.getConfiguration().getAuthenticationScheme();
+ case "authenticationtoken":
+ case "authenticationToken": return target.getConfiguration().getAuthenticationToken();
case "contentinbody":
case "contentInBody": return target.getConfiguration().isContentInBody();
+ case "convertendpoint":
+ case "convertEndpoint": return target.getConfiguration().getConvertEndpoint();
case "doclingcommand":
case "doclingCommand": return target.getConfiguration().getDoclingCommand();
case "doclingserveurl":
diff --git a/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingEndpointUriFactory.java b/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingEndpointUriFactory.java
index 8b6173443452..257c975eafa8 100644
--- a/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingEndpointUriFactory.java
+++ b/components/camel-ai/camel-docling/src/generated/java/org/apache/camel/component/docling/DoclingEndpointUriFactory.java
@@ -23,8 +23,12 @@ public class DoclingEndpointUriFactory extends org.apache.camel.support.componen
private static final Set<String> SECRET_PROPERTY_NAMES;
private static final Map<String, String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(14);
+ Set<String> props = new HashSet<>(18);
+ props.add("apiKeyHeader");
+ props.add("authenticationScheme");
+ props.add("authenticationToken");
props.add("contentInBody");
+ props.add("convertEndpoint");
props.add("doclingCommand");
props.add("doclingServeUrl");
props.add("enableOCR");
@@ -39,7 +43,9 @@ public class DoclingEndpointUriFactory extends org.apache.camel.support.componen
props.add("useDoclingServe");
props.add("workingDirectory");
PROPERTY_NAMES = Collections.unmodifiableSet(props);
- SECRET_PROPERTY_NAMES = Collections.emptySet();
+ Set<String> secretProps = new HashSet<>(1);
+ secretProps.add("authenticationToken");
+ SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps);
MULTI_VALUE_PREFIXES = Collections.emptyMap();
}
diff --git a/components/camel-ai/camel-docling/src/generated/resources/META-INF/org/apache/camel/component/docling/docling.json b/components/camel-ai/camel-docling/src/generated/resources/META-INF/org/apache/camel/component/docling/docling.json
index 518cde34a089..c04a0fe85843 100644
--- a/components/camel-ai/camel-docling/src/generated/resources/META-INF/org/apache/camel/component/docling/docling.json
+++ b/components/camel-ai/camel-docling/src/generated/resources/META-INF/org/apache/camel/component/docling/docling.json
@@ -35,10 +35,14 @@
"outputFormat": { "index": 8, "kind": "property", "displayName": "Output Format", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "markdown", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Output format for document conversion" },
"useDoclingServe": { "index": 9, "kind": "property", "displayName": "Use Docling Serve", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Use docling-serve API instead of CLI command" },
"autowiredEnabled": { "index": 10, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching [...]
- "doclingCommand": { "index": 11, "kind": "property", "displayName": "Docling Command", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Path to Docling Python executable or command" },
- "processTimeout": { "index": 12, "kind": "property", "displayName": "Process Timeout", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Timeout for Docling process execution in milliseconds" },
- "workingDirectory": { "index": 13, "kind": "property", "displayName": "Working Directory", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Working directory for Docling execution" },
- "maxFileSize": { "index": 14, "kind": "property", "displayName": "Max File Size", "group": "security", "label": "security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 52428800, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Maximum file size in bytes for processing" }
+ "convertEndpoint": { "index": 11, "kind": "property", "displayName": "Convert Endpoint", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "\/v1\/convert\/source", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Docling-serve API convert endp [...]
+ "doclingCommand": { "index": 12, "kind": "property", "displayName": "Docling Command", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Path to Docling Python executable or command" },
+ "processTimeout": { "index": 13, "kind": "property", "displayName": "Process Timeout", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Timeout for Docling process execution in milliseconds" },
+ "workingDirectory": { "index": 14, "kind": "property", "displayName": "Working Directory", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Working directory for Docling execution" },
+ "apiKeyHeader": { "index": 15, "kind": "property", "displayName": "Api Key Header", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "X-API-Key", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Header name for API key authentication" },
+ "authenticationScheme": { "index": 16, "kind": "property", "displayName": "Authentication Scheme", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.docling.AuthenticationScheme", "enum": [ "NONE", "BEARER", "API_KEY" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "NONE", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configuration [...]
+ "authenticationToken": { "index": 17, "kind": "property", "displayName": "Authentication Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Authentication token for docling-serve API (Bearer token or API [...]
+ "maxFileSize": { "index": 18, "kind": "property", "displayName": "Max File Size", "group": "security", "label": "security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 52428800, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Maximum file size in bytes for processing" }
},
"headers": {
"CamelDoclingOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "DoclingOperations", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.docling.DoclingHeaders#OPERATION" },
@@ -61,9 +65,13 @@
"outputFormat": { "index": 7, "kind": "parameter", "displayName": "Output Format", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "markdown", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Output format for document conversion" },
"useDoclingServe": { "index": 8, "kind": "parameter", "displayName": "Use Docling Serve", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Use docling-serve API instead of CLI command" },
"lazyStartProducer": { "index": 9, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produc [...]
- "doclingCommand": { "index": 10, "kind": "parameter", "displayName": "Docling Command", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Path to Docling Python executable or command" },
- "processTimeout": { "index": 11, "kind": "parameter", "displayName": "Process Timeout", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Timeout for Docling process execution in milliseconds" },
- "workingDirectory": { "index": 12, "kind": "parameter", "displayName": "Working Directory", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Working directory for Docling execution" },
- "maxFileSize": { "index": 13, "kind": "parameter", "displayName": "Max File Size", "group": "security", "label": "security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 52428800, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Maximum file size in bytes for processing" }
+ "convertEndpoint": { "index": 10, "kind": "parameter", "displayName": "Convert Endpoint", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "\/v1\/convert\/source", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Docling-serve API convert end [...]
+ "doclingCommand": { "index": 11, "kind": "parameter", "displayName": "Docling Command", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Path to Docling Python executable or command" },
+ "processTimeout": { "index": 12, "kind": "parameter", "displayName": "Process Timeout", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 30000, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Timeout for Docling process execution in milliseconds" },
+ "workingDirectory": { "index": 13, "kind": "parameter", "displayName": "Working Directory", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Working directory for Docling execution" },
+ "apiKeyHeader": { "index": 14, "kind": "parameter", "displayName": "Api Key Header", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "X-API-Key", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Header name for API key authentication" },
+ "authenticationScheme": { "index": 15, "kind": "parameter", "displayName": "Authentication Scheme", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.docling.AuthenticationScheme", "enum": [ "NONE", "BEARER", "API_KEY" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "NONE", "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configuratio [...]
+ "authenticationToken": { "index": 16, "kind": "parameter", "displayName": "Authentication Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Authentication token for docling-serve API (Bearer token or API [...]
+ "maxFileSize": { "index": 17, "kind": "parameter", "displayName": "Max File Size", "group": "security", "label": "security", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 52428800, "configurationClass": "org.apache.camel.component.docling.DoclingConfiguration", "configurationField": "configuration", "description": "Maximum file size in bytes for processing" }
}
}
diff --git a/components/camel-ai/camel-docling/src/main/docs/docling-component.adoc b/components/camel-ai/camel-docling/src/main/docs/docling-component.adoc
index c3fc080033bf..fb2a9d4cb4a9 100644
--- a/components/camel-ai/camel-docling/src/main/docs/docling-component.adoc
+++ b/components/camel-ai/camel-docling/src/main/docs/docling-component.adoc
@@ -572,6 +572,189 @@ YAML::
----
====
+=== Authentication with docling-serve
+
+The component supports multiple authentication mechanisms for secured docling-serve instances.
+
+==== Bearer Token Authentication
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+ .to("docling:CONVERT_TO_MARKDOWN?" +
+ "useDoclingServe=true&" +
+ "doclingServeUrl=http://localhost:5001&" +
+ "authenticationScheme=BEARER&" +
+ "authenticationToken=your-bearer-token-here&" +
+ "contentInBody=true")
+ .to("file:///data/output");
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: "file:///data/documents"
+ parameters:
+ include: ".*\\.pdf"
+ steps:
+ - to:
+ uri: "docling:CONVERT_TO_MARKDOWN"
+ parameters:
+ useDoclingServe: true
+ doclingServeUrl: "http://localhost:5001"
+ authenticationScheme: "BEARER"
+ authenticationToken: "your-bearer-token-here"
+ contentInBody: true
+ - to:
+ uri: "file:///data/output"
+----
+====
+
+==== API Key Authentication
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+ .to("docling:CONVERT_TO_MARKDOWN?" +
+ "useDoclingServe=true&" +
+ "doclingServeUrl=http://localhost:5001&" +
+ "authenticationScheme=API_KEY&" +
+ "authenticationToken=your-api-key-here&" +
+ "apiKeyHeader=X-API-Key&" +
+ "contentInBody=true")
+ .to("file:///data/output");
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: "file:///data/documents"
+ parameters:
+ include: ".*\\.pdf"
+ steps:
+ - to:
+ uri: "docling:CONVERT_TO_MARKDOWN"
+ parameters:
+ useDoclingServe: true
+ doclingServeUrl: "http://localhost:5001"
+ authenticationScheme: "API_KEY"
+ authenticationToken: "your-api-key-here"
+ apiKeyHeader: "X-API-Key"
+ contentInBody: true
+ - to:
+ uri: "file:///data/output"
+----
+====
+
+==== Using Custom API Key Header
+
+If your docling-serve instance uses a custom header name for API keys:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+ .to("docling:CONVERT_TO_MARKDOWN?" +
+ "useDoclingServe=true&" +
+ "doclingServeUrl=http://localhost:5001&" +
+ "authenticationScheme=API_KEY&" +
+ "authenticationToken=your-api-key-here&" +
+ "apiKeyHeader=X-Custom-API-Key&" +
+ "contentInBody=true")
+ .to("file:///data/output");
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: "file:///data/documents"
+ parameters:
+ include: ".*\\.pdf"
+ steps:
+ - to:
+ uri: "docling:CONVERT_TO_MARKDOWN"
+ parameters:
+ useDoclingServe: true
+ doclingServeUrl: "http://localhost:5001"
+ authenticationScheme: "API_KEY"
+ authenticationToken: "your-api-key-here"
+ apiKeyHeader: "X-Custom-API-Key"
+ contentInBody: true
+ - to:
+ uri: "file:///data/output"
+----
+====
+
+==== Using Authentication Token from Properties
+
+For better security, store authentication tokens in properties or environment variables:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+ .to("docling:CONVERT_TO_MARKDOWN?" +
+ "useDoclingServe=true&" +
+ "doclingServeUrl={{docling.serve.url}}&" +
+ "authenticationScheme=BEARER&" +
+ "authenticationToken={{docling.serve.token}}&" +
+ "contentInBody=true")
+ .to("file:///data/output");
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: "file:///data/documents"
+ parameters:
+ include: ".*\\.pdf"
+ steps:
+ - to:
+ uri: "docling:CONVERT_TO_MARKDOWN"
+ parameters:
+ useDoclingServe: true
+ doclingServeUrl: "{{docling.serve.url}}"
+ authenticationScheme: "BEARER"
+ authenticationToken: "{{docling.serve.token}}"
+ contentInBody: true
+ - to:
+ uri: "file:///data/output"
+----
+====
+
+Then define in `application.properties`:
+[source,properties]
+----
+docling.serve.url=http://localhost:5001
+docling.serve.token=your-bearer-token-here
+----
+
== Error Handling
The component handles various error scenarios:
@@ -581,6 +764,7 @@ The component handles various error scenarios:
- **Invalid file formats**: Unsupported file formats result in processing errors
- **Docling not found**: Missing Docling installation causes startup failures (CLI mode)
- **Connection errors**: When using docling-serve API mode, connection failures to the API endpoint will result in errors
+- **Authentication errors**: Invalid or missing authentication credentials will result in 401 Unauthorized errors from the docling-serve API
== Performance Considerations
diff --git a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/AuthenticationScheme.java b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/AuthenticationScheme.java
new file mode 100644
index 000000000000..ee175f8df115
--- /dev/null
+++ b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/AuthenticationScheme.java
@@ -0,0 +1,39 @@
+/*
+ * 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.docling;
+
+/**
+ * Authentication schemes for docling-serve API
+ */
+public enum AuthenticationScheme {
+
+ /**
+ * No authentication
+ */
+ NONE,
+
+ /**
+ * Bearer token authentication (Authorization: Bearer token)
+ */
+ BEARER,
+
+ /**
+ * API Key authentication via custom header
+ */
+ API_KEY
+
+}
diff --git a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingConfiguration.java b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingConfiguration.java
index 5c60f75c17b1..b0bc2418e708 100644
--- a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingConfiguration.java
+++ b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingConfiguration.java
@@ -81,6 +81,23 @@ public class DoclingConfiguration implements Cloneable {
@Metadata(description = "Docling-serve API URL (e.g., http://localhost:5001)", defaultValue = "http://localhost:5001")
private String doclingServeUrl = "http://localhost:5001";
+ @UriParam(label = "security")
+ @Metadata(description = "Authentication token for docling-serve API (Bearer token or API key)", secret = true)
+ private String authenticationToken;
+
+ @UriParam(label = "security")
+ @Metadata(description = "Authentication scheme (BEARER, API_KEY, NONE)", defaultValue = "NONE",
+ enums = "BEARER,API_KEY,NONE")
+ private AuthenticationScheme authenticationScheme = AuthenticationScheme.NONE;
+
+ @UriParam(label = "security")
+ @Metadata(description = "Header name for API key authentication", defaultValue = "X-API-Key")
+ private String apiKeyHeader = "X-API-Key";
+
+ @UriParam(label = "advanced")
+ @Metadata(description = "Docling-serve API convert endpoint path", defaultValue = "/v1/convert/source")
+ private String convertEndpoint = "/v1/convert/source";
+
public DoclingOperations getOperation() {
return operation;
}
@@ -177,6 +194,38 @@ public class DoclingConfiguration implements Cloneable {
this.doclingServeUrl = doclingServeUrl;
}
+ public String getAuthenticationToken() {
+ return authenticationToken;
+ }
+
+ public void setAuthenticationToken(String authenticationToken) {
+ this.authenticationToken = authenticationToken;
+ }
+
+ public AuthenticationScheme getAuthenticationScheme() {
+ return authenticationScheme;
+ }
+
+ public void setAuthenticationScheme(AuthenticationScheme authenticationScheme) {
+ this.authenticationScheme = authenticationScheme;
+ }
+
+ public String getApiKeyHeader() {
+ return apiKeyHeader;
+ }
+
+ public void setApiKeyHeader(String apiKeyHeader) {
+ this.apiKeyHeader = apiKeyHeader;
+ }
+
+ public String getConvertEndpoint() {
+ return convertEndpoint;
+ }
+
+ public void setConvertEndpoint(String convertEndpoint) {
+ this.convertEndpoint = convertEndpoint;
+ }
+
public DoclingConfiguration copy() {
try {
return (DoclingConfiguration) super.clone();
diff --git a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java
index b88725b8e8e3..3a440b7d349d 100644
--- a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java
+++ b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java
@@ -54,8 +54,16 @@ public class DoclingProducer extends DefaultProducer {
protected void doStart() throws Exception {
super.doStart();
if (configuration.isUseDoclingServe()) {
- doclingServeClient = new DoclingServeClient(configuration.getDoclingServeUrl());
- LOG.info("DoclingProducer configured to use docling-serve API at: {}", configuration.getDoclingServeUrl());
+ doclingServeClient = new DoclingServeClient(
+ configuration.getDoclingServeUrl(),
+ configuration.getAuthenticationScheme(),
+ configuration.getAuthenticationToken(),
+ configuration.getApiKeyHeader(),
+ configuration.getConvertEndpoint());
+ LOG.info("DoclingProducer configured to use docling-serve API at: {}{} with authentication: {}",
+ configuration.getDoclingServeUrl(),
+ configuration.getConvertEndpoint(),
+ configuration.getAuthenticationScheme());
} else {
LOG.info("DoclingProducer configured to use docling CLI command");
}
diff --git a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingServeClient.java b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingServeClient.java
index 375e76c00952..9da6af787708 100644
--- a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingServeClient.java
+++ b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingServeClient.java
@@ -42,16 +42,36 @@ import org.slf4j.LoggerFactory;
public class DoclingServeClient {
private static final Logger LOG = LoggerFactory.getLogger(DoclingServeClient.class);
- private static final String CONVERT_ENDPOINT = "/v1/convert/source";
+ private static final String DEFAULT_CONVERT_ENDPOINT = "/v1/convert/source";
private final String baseUrl;
private final ObjectMapper objectMapper;
private final CloseableHttpClient httpClient;
+ private final AuthenticationScheme authenticationScheme;
+ private final String authenticationToken;
+ private final String apiKeyHeader;
+ private final String convertEndpoint;
public DoclingServeClient(String baseUrl) {
+ this(baseUrl, AuthenticationScheme.NONE, null, "X-API-Key", DEFAULT_CONVERT_ENDPOINT);
+ }
+
+ public DoclingServeClient(
+ String baseUrl, AuthenticationScheme authenticationScheme, String authenticationToken,
+ String apiKeyHeader) {
+ this(baseUrl, authenticationScheme, authenticationToken, apiKeyHeader, DEFAULT_CONVERT_ENDPOINT);
+ }
+
+ public DoclingServeClient(
+ String baseUrl, AuthenticationScheme authenticationScheme, String authenticationToken,
+ String apiKeyHeader, String convertEndpoint) {
this.baseUrl = baseUrl.endsWith("/") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
this.objectMapper = new ObjectMapper();
this.httpClient = HttpClients.createDefault();
+ this.authenticationScheme = authenticationScheme != null ? authenticationScheme : AuthenticationScheme.NONE;
+ this.authenticationToken = authenticationToken;
+ this.apiKeyHeader = apiKeyHeader != null ? apiKeyHeader : "X-API-Key";
+ this.convertEndpoint = convertEndpoint != null ? convertEndpoint : DEFAULT_CONVERT_ENDPOINT;
}
/**
@@ -90,9 +110,10 @@ public class DoclingServeClient {
String jsonRequest = objectMapper.writeValueAsString(requestBody);
LOG.debug("Request body: {}", jsonRequest);
- HttpPost httpPost = new HttpPost(baseUrl + CONVERT_ENDPOINT);
+ HttpPost httpPost = new HttpPost(baseUrl + convertEndpoint);
httpPost.setEntity(new StringEntity(jsonRequest, ContentType.APPLICATION_JSON));
httpPost.setHeader("Accept", "application/json");
+ applyAuthentication(httpPost);
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getCode();
@@ -140,9 +161,10 @@ public class DoclingServeClient {
String jsonRequest = objectMapper.writeValueAsString(requestBody);
LOG.debug("Request body: {}", jsonRequest);
- HttpPost httpPost = new HttpPost(baseUrl + CONVERT_ENDPOINT);
+ HttpPost httpPost = new HttpPost(baseUrl + convertEndpoint);
httpPost.setEntity(new StringEntity(jsonRequest, ContentType.APPLICATION_JSON));
httpPost.setHeader("Accept", "application/json");
+ applyAuthentication(httpPost);
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getCode();
@@ -216,6 +238,35 @@ public class DoclingServeClient {
}
}
+ /**
+ * Apply authentication headers to the HTTP request based on the configured authentication scheme.
+ *
+ * @param httpPost The HTTP POST request to add authentication to
+ */
+ private void applyAuthentication(HttpPost httpPost) {
+ if (authenticationScheme == null || authenticationScheme == AuthenticationScheme.NONE) {
+ return;
+ }
+
+ if (authenticationToken == null || authenticationToken.isEmpty()) {
+ LOG.warn("Authentication scheme is set to {} but no authentication token provided", authenticationScheme);
+ return;
+ }
+
+ switch (authenticationScheme) {
+ case BEARER:
+ httpPost.setHeader("Authorization", "Bearer " + authenticationToken);
+ LOG.debug("Applied Bearer token authentication");
+ break;
+ case API_KEY:
+ httpPost.setHeader(apiKeyHeader, authenticationToken);
+ LOG.debug("Applied API Key authentication with header: {}", apiKeyHeader);
+ break;
+ default:
+ LOG.warn("Unknown authentication scheme: {}", authenticationScheme);
+ }
+ }
+
public void close() throws IOException {
if (httpClient != null) {
httpClient.close();
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java b/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java
index 0376f07dc232..9d6662a45a15 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/SensitiveUtils.java
@@ -40,6 +40,7 @@ public final class SensitiveUtils {
"apipassword",
"apiuser",
"apiusername",
+ "authenticationtoken",
"authkey",
"authorizationtoken",
"blobaccesskey",
@@ -124,6 +125,7 @@ public final class SensitiveUtils {
+ "|\\Qapipassword\\E"
+ "|\\Qapiuser\\E"
+ "|\\Qapiusername\\E"
+ + "|\\Qauthenticationtoken\\E"
+ "|\\Qauthkey\\E"
+ "|\\Qauthorizationtoken\\E"
+ "|\\Qblobaccesskey\\E"
@@ -190,7 +192,7 @@ public final class SensitiveUtils {
+ "|\\Qverificationcode\\E"
+ "|\\Qwebhookverifytoken\\E"
+ "|\\Qzookeeperpassword\\E"
- // SENSITIVE-PATTERN: END
+ // SENSITIVE-PATTERN: END
;
private SensitiveUtils() {
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/DoclingComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/DoclingComponentBuilderFactory.java
index 0812a96b9ae0..d43015bcd4d1 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/DoclingComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/DoclingComponentBuilderFactory.java
@@ -251,6 +251,23 @@ public interface DoclingComponentBuilderFactory {
return this;
}
+
+ /**
+ * Docling-serve API convert endpoint path.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Default: /v1/convert/source
+ * Group: advanced
+ *
+ * @param convertEndpoint the value to set
+ * @return the dsl builder
+ */
+ default DoclingComponentBuilder convertEndpoint(java.lang.String convertEndpoint) {
+ doSetProperty("convertEndpoint", convertEndpoint);
+ return this;
+ }
+
/**
* Path to Docling Python executable or command.
*
@@ -299,6 +316,56 @@ public interface DoclingComponentBuilderFactory {
}
+ /**
+ * Header name for API key authentication.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Default: X-API-Key
+ * Group: security
+ *
+ * @param apiKeyHeader the value to set
+ * @return the dsl builder
+ */
+ default DoclingComponentBuilder apiKeyHeader(java.lang.String apiKeyHeader) {
+ doSetProperty("apiKeyHeader", apiKeyHeader);
+ return this;
+ }
+
+
+ /**
+ * Authentication scheme (BEARER, API_KEY, NONE).
+ *
+ * The option is a:
+ * <code>org.apache.camel.component.docling.AuthenticationScheme</code> type.
+ *
+ * Default: NONE
+ * Group: security
+ *
+ * @param authenticationScheme the value to set
+ * @return the dsl builder
+ */
+ default DoclingComponentBuilder authenticationScheme(org.apache.camel.component.docling.AuthenticationScheme authenticationScheme) {
+ doSetProperty("authenticationScheme", authenticationScheme);
+ return this;
+ }
+
+ /**
+ * Authentication token for docling-serve API (Bearer token or API key).
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ *
+ * @param authenticationToken the value to set
+ * @return the dsl builder
+ */
+ default DoclingComponentBuilder authenticationToken(java.lang.String authenticationToken) {
+ doSetProperty("authenticationToken", authenticationToken);
+ return this;
+ }
+
+
/**
* Maximum file size in bytes for processing.
*
@@ -346,9 +413,13 @@ public interface DoclingComponentBuilderFactory {
case "outputFormat": getOrCreateConfiguration((DoclingComponent) component).setOutputFormat((java.lang.String) value); return true;
case "useDoclingServe": getOrCreateConfiguration((DoclingComponent) component).setUseDoclingServe((boolean) value); return true;
case "autowiredEnabled": ((DoclingComponent) component).setAutowiredEnabled((boolean) value); return true;
+ case "convertEndpoint": getOrCreateConfiguration((DoclingComponent) component).setConvertEndpoint((java.lang.String) value); return true;
case "doclingCommand": getOrCreateConfiguration((DoclingComponent) component).setDoclingCommand((java.lang.String) value); return true;
case "processTimeout": getOrCreateConfiguration((DoclingComponent) component).setProcessTimeout((long) value); return true;
case "workingDirectory": getOrCreateConfiguration((DoclingComponent) component).setWorkingDirectory((java.lang.String) value); return true;
+ case "apiKeyHeader": getOrCreateConfiguration((DoclingComponent) component).setApiKeyHeader((java.lang.String) value); return true;
+ case "authenticationScheme": getOrCreateConfiguration((DoclingComponent) component).setAuthenticationScheme((org.apache.camel.component.docling.AuthenticationScheme) value); return true;
+ case "authenticationToken": getOrCreateConfiguration((DoclingComponent) component).setAuthenticationToken((java.lang.String) value); return true;
case "maxFileSize": getOrCreateConfiguration((DoclingComponent) component).setMaxFileSize((long) value); return true;
default: return false;
}
diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/DoclingEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/DoclingEndpointBuilderFactory.java
index 40e5ab55a262..1c0a5c8f554c 100644
--- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/DoclingEndpointBuilderFactory.java
+++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/DoclingEndpointBuilderFactory.java
@@ -247,6 +247,69 @@ public interface DoclingEndpointBuilderFactory {
doSetProperty("useDoclingServe", useDoclingServe);
return this;
}
+ /**
+ * Header name for API key authentication.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Default: X-API-Key
+ * Group: security
+ *
+ * @param apiKeyHeader the value to set
+ * @return the dsl builder
+ */
+ default DoclingEndpointBuilder apiKeyHeader(String apiKeyHeader) {
+ doSetProperty("apiKeyHeader", apiKeyHeader);
+ return this;
+ }
+ /**
+ * Authentication scheme (BEARER, API_KEY, NONE).
+ *
+ * The option is a:
+ * <code>org.apache.camel.component.docling.AuthenticationScheme</code>
+ * type.
+ *
+ * Default: NONE
+ * Group: security
+ *
+ * @param authenticationScheme the value to set
+ * @return the dsl builder
+ */
+ default DoclingEndpointBuilder authenticationScheme(org.apache.camel.component.docling.AuthenticationScheme authenticationScheme) {
+ doSetProperty("authenticationScheme", authenticationScheme);
+ return this;
+ }
+ /**
+ * Authentication scheme (BEARER, API_KEY, NONE).
+ *
+ * The option will be converted to a
+ * <code>org.apache.camel.component.docling.AuthenticationScheme</code>
+ * type.
+ *
+ * Default: NONE
+ * Group: security
+ *
+ * @param authenticationScheme the value to set
+ * @return the dsl builder
+ */
+ default DoclingEndpointBuilder authenticationScheme(String authenticationScheme) {
+ doSetProperty("authenticationScheme", authenticationScheme);
+ return this;
+ }
+ /**
+ * Authentication token for docling-serve API (Bearer token or API key).
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ *
+ * @param authenticationToken the value to set
+ * @return the dsl builder
+ */
+ default DoclingEndpointBuilder authenticationToken(String authenticationToken) {
+ doSetProperty("authenticationToken", authenticationToken);
+ return this;
+ }
/**
* Maximum file size in bytes for processing.
*
@@ -335,6 +398,21 @@ public interface DoclingEndpointBuilderFactory {
doSetProperty("lazyStartProducer", lazyStartProducer);
return this;
}
+ /**
+ * Docling-serve API convert endpoint path.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Default: /v1/convert/source
+ * Group: advanced
+ *
+ * @param convertEndpoint the value to set
+ * @return the dsl builder
+ */
+ default AdvancedDoclingEndpointBuilder convertEndpoint(String convertEndpoint) {
+ doSetProperty("convertEndpoint", convertEndpoint);
+ return this;
+ }
/**
* Path to Docling Python executable or command.
*