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 2023/12/13 12:49:19 UTC
(camel) 01/04: CAMEL-18590 - Camel-Azure components: Define a unique configuration for authentication - Azure Eventhubs
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch CAMEL-18590-eventhubs
in repository https://gitbox.apache.org/repos/asf/camel.git
commit cd0f4ba97620a275f21e35da9f49243a02da9667
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Dec 13 13:26:05 2023 +0100
CAMEL-18590 - Camel-Azure components: Define a unique configuration for authentication - Azure Eventhubs
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../camel/catalog/components/azure-eventhubs.json | 14 ++++---
.../eventhubs/EventHubsComponentConfigurer.java | 6 +++
.../eventhubs/EventHubsEndpointConfigurer.java | 6 +++
.../eventhubs/EventHubsEndpointUriFactory.java | 3 +-
.../component/azure/eventhubs/azure-eventhubs.json | 14 ++++---
.../component/azure/eventhubs/CredentialType.java | 39 +++++++++++++++++++
.../azure/eventhubs/EventHubsConfiguration.java | 16 ++++++++
.../eventhubs/client/EventHubsClientFactory.java | 44 ++++++++++++++++------
.../azure/eventhubs/EventProcessorTest.java | 1 +
9 files changed, 118 insertions(+), 25 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-eventhubs.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-eventhubs.json
index 6a599499281..8cfe7eba98a 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-eventhubs.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-eventhubs.json
@@ -42,9 +42,10 @@
"producerAsyncClient": { "index": 17, "kind": "property", "displayName": "Producer Async Client", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "com.azure.messaging.eventhubs.EventHubProducerAsyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Sets the Eve [...]
"autowiredEnabled": { "index": 18, "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 [...]
"connectionString": { "index": 19, "kind": "property", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Instead of supplying namespace, sharedAccessKey, sharedAccessName ... etc, you can [...]
- "sharedAccessKey": { "index": 20, "kind": "property", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." },
- "sharedAccessName": { "index": 21, "kind": "property", "displayName": "Shared Access Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The name you chose for your EventHubs SAS keys." },
- "tokenCredential": { "index": 22, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Still another way of authentication (beside supplying namesp [...]
+ "credentialType": { "index": 20, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.eventhubs.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfigur [...]
+ "sharedAccessKey": { "index": 21, "kind": "property", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." },
+ "sharedAccessName": { "index": 22, "kind": "property", "displayName": "Shared Access Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The name you chose for your EventHubs SAS keys." },
+ "tokenCredential": { "index": 23, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Still another way of authentication (beside supplying namesp [...]
},
"headers": {
"CamelAzureEventHubsPartitionKey": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "(producer) Overrides the hashing key to be provided for the batch of events, which instructs the Event Hubs service to map this key to a specific partition. (consumer) It sets the partition hashing key if it was set when originally [...]
@@ -79,8 +80,9 @@
"producerAsyncClient": { "index": 19, "kind": "parameter", "displayName": "Producer Async Client", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "com.azure.messaging.eventhubs.EventHubProducerAsyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Sets the Ev [...]
"lazyStartProducer": { "index": 20, "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 produ [...]
"connectionString": { "index": 21, "kind": "parameter", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Instead of supplying namespace, sharedAccessKey, sharedAccessName ... etc, you can [...]
- "sharedAccessKey": { "index": 22, "kind": "parameter", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." },
- "sharedAccessName": { "index": 23, "kind": "parameter", "displayName": "Shared Access Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The name you chose for your EventHubs SAS keys." },
- "tokenCredential": { "index": 24, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Still another way of authentication (beside supplying names [...]
+ "credentialType": { "index": 22, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.eventhubs.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfigu [...]
+ "sharedAccessKey": { "index": 23, "kind": "parameter", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." },
+ "sharedAccessName": { "index": 24, "kind": "parameter", "displayName": "Shared Access Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The name you chose for your EventHubs SAS keys." },
+ "tokenCredential": { "index": 25, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Still another way of authentication (beside supplying names [...]
}
}
diff --git a/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsComponentConfigurer.java b/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsComponentConfigurer.java
index 28297cca101..33cffaf6d17 100644
--- a/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsComponentConfigurer.java
+++ b/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsComponentConfigurer.java
@@ -55,6 +55,8 @@ public class EventHubsComponentConfigurer extends PropertyConfigurerSupport impl
case "connectionString": getOrCreateConfiguration(target).setConnectionString(property(camelContext, java.lang.String.class, value)); return true;
case "consumergroupname":
case "consumerGroupName": getOrCreateConfiguration(target).setConsumerGroupName(property(camelContext, java.lang.String.class, value)); return true;
+ case "credentialtype":
+ case "credentialType": getOrCreateConfiguration(target).setCredentialType(property(camelContext, org.apache.camel.component.azure.eventhubs.CredentialType.class, value)); return true;
case "eventposition":
case "eventPosition": getOrCreateConfiguration(target).setEventPosition(property(camelContext, java.util.Map.class, value)); return true;
case "lazystartproducer":
@@ -112,6 +114,8 @@ public class EventHubsComponentConfigurer extends PropertyConfigurerSupport impl
case "connectionString": return java.lang.String.class;
case "consumergroupname":
case "consumerGroupName": return java.lang.String.class;
+ case "credentialtype":
+ case "credentialType": return org.apache.camel.component.azure.eventhubs.CredentialType.class;
case "eventposition":
case "eventPosition": return java.util.Map.class;
case "lazystartproducer":
@@ -165,6 +169,8 @@ public class EventHubsComponentConfigurer extends PropertyConfigurerSupport impl
case "connectionString": return getOrCreateConfiguration(target).getConnectionString();
case "consumergroupname":
case "consumerGroupName": return getOrCreateConfiguration(target).getConsumerGroupName();
+ case "credentialtype":
+ case "credentialType": return getOrCreateConfiguration(target).getCredentialType();
case "eventposition":
case "eventPosition": return getOrCreateConfiguration(target).getEventPosition();
case "lazystartproducer":
diff --git a/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpointConfigurer.java b/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpointConfigurer.java
index 84bb8959606..53b4bcde182 100644
--- a/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpointConfigurer.java
+++ b/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpointConfigurer.java
@@ -45,6 +45,8 @@ public class EventHubsEndpointConfigurer extends PropertyConfigurerSupport imple
case "connectionString": target.getConfiguration().setConnectionString(property(camelContext, java.lang.String.class, value)); return true;
case "consumergroupname":
case "consumerGroupName": target.getConfiguration().setConsumerGroupName(property(camelContext, java.lang.String.class, value)); return true;
+ case "credentialtype":
+ case "credentialType": target.getConfiguration().setCredentialType(property(camelContext, org.apache.camel.component.azure.eventhubs.CredentialType.class, value)); return true;
case "eventposition":
case "eventPosition": target.getConfiguration().setEventPosition(property(camelContext, java.util.Map.class, value)); return true;
case "exceptionhandler":
@@ -103,6 +105,8 @@ public class EventHubsEndpointConfigurer extends PropertyConfigurerSupport imple
case "connectionString": return java.lang.String.class;
case "consumergroupname":
case "consumerGroupName": return java.lang.String.class;
+ case "credentialtype":
+ case "credentialType": return org.apache.camel.component.azure.eventhubs.CredentialType.class;
case "eventposition":
case "eventPosition": return java.util.Map.class;
case "exceptionhandler":
@@ -157,6 +161,8 @@ public class EventHubsEndpointConfigurer extends PropertyConfigurerSupport imple
case "connectionString": return target.getConfiguration().getConnectionString();
case "consumergroupname":
case "consumerGroupName": return target.getConfiguration().getConsumerGroupName();
+ case "credentialtype":
+ case "credentialType": return target.getConfiguration().getCredentialType();
case "eventposition":
case "eventPosition": return target.getConfiguration().getEventPosition();
case "exceptionhandler":
diff --git a/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpointUriFactory.java b/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpointUriFactory.java
index 40facb71afa..3c03c4d1878 100644
--- a/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpointUriFactory.java
+++ b/components/camel-azure/camel-azure-eventhubs/src/generated/java/org/apache/camel/component/azure/eventhubs/EventHubsEndpointUriFactory.java
@@ -21,7 +21,7 @@ public class EventHubsEndpointUriFactory extends org.apache.camel.support.compon
private static final Set<String> SECRET_PROPERTY_NAMES;
private static final Set<String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(25);
+ Set<String> props = new HashSet<>(26);
props.add("amqpRetryOptions");
props.add("amqpTransportType");
props.add("blobAccessKey");
@@ -34,6 +34,7 @@ public class EventHubsEndpointUriFactory extends org.apache.camel.support.compon
props.add("checkpointStore");
props.add("connectionString");
props.add("consumerGroupName");
+ props.add("credentialType");
props.add("eventHubName");
props.add("eventPosition");
props.add("exceptionHandler");
diff --git a/components/camel-azure/camel-azure-eventhubs/src/generated/resources/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json b/components/camel-azure/camel-azure-eventhubs/src/generated/resources/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json
index 6a599499281..8cfe7eba98a 100644
--- a/components/camel-azure/camel-azure-eventhubs/src/generated/resources/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json
+++ b/components/camel-azure/camel-azure-eventhubs/src/generated/resources/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json
@@ -42,9 +42,10 @@
"producerAsyncClient": { "index": 17, "kind": "property", "displayName": "Producer Async Client", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "com.azure.messaging.eventhubs.EventHubProducerAsyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Sets the Eve [...]
"autowiredEnabled": { "index": 18, "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 [...]
"connectionString": { "index": 19, "kind": "property", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Instead of supplying namespace, sharedAccessKey, sharedAccessName ... etc, you can [...]
- "sharedAccessKey": { "index": 20, "kind": "property", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." },
- "sharedAccessName": { "index": 21, "kind": "property", "displayName": "Shared Access Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The name you chose for your EventHubs SAS keys." },
- "tokenCredential": { "index": 22, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Still another way of authentication (beside supplying namesp [...]
+ "credentialType": { "index": 20, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.eventhubs.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfigur [...]
+ "sharedAccessKey": { "index": 21, "kind": "property", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." },
+ "sharedAccessName": { "index": 22, "kind": "property", "displayName": "Shared Access Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The name you chose for your EventHubs SAS keys." },
+ "tokenCredential": { "index": 23, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Still another way of authentication (beside supplying namesp [...]
},
"headers": {
"CamelAzureEventHubsPartitionKey": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "(producer) Overrides the hashing key to be provided for the batch of events, which instructs the Event Hubs service to map this key to a specific partition. (consumer) It sets the partition hashing key if it was set when originally [...]
@@ -79,8 +80,9 @@
"producerAsyncClient": { "index": 19, "kind": "parameter", "displayName": "Producer Async Client", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "com.azure.messaging.eventhubs.EventHubProducerAsyncClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Sets the Ev [...]
"lazyStartProducer": { "index": 20, "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 produ [...]
"connectionString": { "index": 21, "kind": "parameter", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Instead of supplying namespace, sharedAccessKey, sharedAccessName ... etc, you can [...]
- "sharedAccessKey": { "index": 22, "kind": "parameter", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." },
- "sharedAccessName": { "index": 23, "kind": "parameter", "displayName": "Shared Access Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The name you chose for your EventHubs SAS keys." },
- "tokenCredential": { "index": 24, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Still another way of authentication (beside supplying names [...]
+ "credentialType": { "index": 22, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.eventhubs.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfigu [...]
+ "sharedAccessKey": { "index": 23, "kind": "parameter", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." },
+ "sharedAccessName": { "index": 24, "kind": "parameter", "displayName": "Shared Access Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The name you chose for your EventHubs SAS keys." },
+ "tokenCredential": { "index": 25, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Still another way of authentication (beside supplying names [...]
}
}
diff --git a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/CredentialType.java b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/CredentialType.java
new file mode 100644
index 00000000000..f3d9bff9b58
--- /dev/null
+++ b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/CredentialType.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.azure.eventhubs;
+
+public enum CredentialType {
+ /**
+ * Eventhubs Connection String
+ */
+ CONNECTION_STRING,
+ /**
+ * Includes:
+ * <uL>
+ * <li>Service principal with secret</li>
+ * <li>Service principal with certificate</li>
+ * <li>username and password</li>
+ * </uL>
+ *
+ * @see com.azure.identity.DefaultAzureCredentialBuilder
+ */
+ AZURE_IDENTITY,
+ /**
+ * Eventhubs Token Credential
+ */
+ TOKEN_CREDENTIAL,
+}
diff --git a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConfiguration.java b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConfiguration.java
index e320685bcc8..f6786f09b31 100644
--- a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConfiguration.java
+++ b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/EventHubsConfiguration.java
@@ -34,6 +34,8 @@ import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
+import static org.apache.camel.component.azure.eventhubs.CredentialType.CONNECTION_STRING;
+
@UriParams
public class EventHubsConfiguration implements Cloneable {
@@ -80,6 +82,9 @@ public class EventHubsConfiguration implements Cloneable {
private String partitionKey;
@UriParam(label = "producer")
private String partitionId;
+ @UriParam(label = "security", enums = "AZURE_IDENTITY,CONNECTION_STRING,TOKEN_CREDENTIAL",
+ defaultValue = "CONNECTION_STRING")
+ private CredentialType credentialType = CONNECTION_STRING;
/**
* EventHubs namespace created in Azure Portal.
@@ -351,6 +356,17 @@ public class EventHubsConfiguration implements Cloneable {
this.checkpointBatchTimeout = checkpointBatchTimeout;
}
+ public CredentialType getCredentialType() {
+ return credentialType;
+ }
+
+ /**
+ * Determines the credential strategy to adopt
+ */
+ public void setCredentialType(CredentialType credentialType) {
+ this.credentialType = credentialType;
+ }
+
public EventHubsConfiguration copy() {
try {
return (EventHubsConfiguration) super.clone();
diff --git a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/client/EventHubsClientFactory.java b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/client/EventHubsClientFactory.java
index a448f113040..48543642ab3 100644
--- a/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/client/EventHubsClientFactory.java
+++ b/components/camel-azure/camel-azure-eventhubs/src/main/java/org/apache/camel/component/azure/eventhubs/client/EventHubsClientFactory.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.azure.eventhubs.client;
import java.util.Locale;
import java.util.function.Consumer;
+import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.messaging.eventhubs.CheckpointStore;
import com.azure.messaging.eventhubs.EventHubClientBuilder;
import com.azure.messaging.eventhubs.EventHubConsumerAsyncClient;
@@ -31,6 +32,7 @@ import com.azure.messaging.eventhubs.models.EventContext;
import com.azure.storage.blob.BlobContainerAsyncClient;
import com.azure.storage.blob.BlobContainerClientBuilder;
import com.azure.storage.common.StorageSharedKeyCredential;
+import org.apache.camel.component.azure.eventhubs.CredentialType;
import org.apache.camel.component.azure.eventhubs.EventHubsConfiguration;
import org.apache.camel.util.ObjectHelper;
@@ -47,17 +49,23 @@ public final class EventHubsClientFactory {
.transportType(configuration.getAmqpTransportType())
.retryOptions(configuration.getAmqpRetryOptions());
- if (ObjectHelper.isEmpty(configuration.getTokenCredential())) {
+ if (configuration.getCredentialType().equals(CredentialType.CONNECTION_STRING)) {
return eventHubClientBuilder
.connectionString(buildConnectionString(configuration))
.buildAsyncProducerClient();
- }
+ } else if (configuration.getCredentialType().equals(CredentialType.TOKEN_CREDENTIAL)) {
- checkTokenCredentialConfiguration(configuration);
+ checkTokenCredentialConfiguration(configuration);
+ return eventHubClientBuilder
+ .fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration))
+ .eventHubName(configuration.getEventHubName())
+ .credential(configuration.getTokenCredential())
+ .buildAsyncProducerClient();
+ }
return eventHubClientBuilder
.fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration))
.eventHubName(configuration.getEventHubName())
- .credential(configuration.getTokenCredential())
+ .credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncProducerClient();
}
@@ -68,17 +76,23 @@ public final class EventHubsClientFactory {
.transportType(configuration.getAmqpTransportType())
.retryOptions(configuration.getAmqpRetryOptions());
- if (ObjectHelper.isEmpty(configuration.getTokenCredential())) {
+ if (configuration.getCredentialType().equals(CredentialType.CONNECTION_STRING)) {
return eventHubClientBuilder
.connectionString(buildConnectionString(configuration))
.buildAsyncConsumerClient();
- }
+ } else if (configuration.getCredentialType().equals(CredentialType.TOKEN_CREDENTIAL)) {
- checkTokenCredentialConfiguration(configuration);
+ checkTokenCredentialConfiguration(configuration);
+ return eventHubClientBuilder
+ .fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration))
+ .eventHubName(configuration.getEventHubName())
+ .credential(configuration.getTokenCredential())
+ .buildAsyncConsumerClient();
+ }
return eventHubClientBuilder
.fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration))
.eventHubName(configuration.getEventHubName())
- .credential(configuration.getTokenCredential())
+ .credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncConsumerClient();
}
@@ -94,17 +108,23 @@ public final class EventHubsClientFactory {
.processError(processError)
.processEvent(processEvent);
- if (ObjectHelper.isEmpty(configuration.getTokenCredential())) {
+ if (configuration.getCredentialType().equals(CredentialType.CONNECTION_STRING)) {
return eventProcessorClientBuilder
.connectionString(buildConnectionString(configuration))
.buildEventProcessorClient();
- }
+ } else if (configuration.getCredentialType().equals(CredentialType.TOKEN_CREDENTIAL)) {
- checkTokenCredentialConfiguration(configuration);
+ checkTokenCredentialConfiguration(configuration);
+ return eventProcessorClientBuilder
+ .fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration))
+ .eventHubName(configuration.getEventHubName())
+ .credential(configuration.getTokenCredential())
+ .buildEventProcessorClient();
+ }
return eventProcessorClientBuilder
.fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration))
.eventHubName(configuration.getEventHubName())
- .credential(configuration.getTokenCredential())
+ .credential(new DefaultAzureCredentialBuilder().build())
.buildEventProcessorClient();
}
diff --git a/components/camel-azure/camel-azure-eventhubs/src/test/java/org/apache/camel/component/azure/eventhubs/EventProcessorTest.java b/components/camel-azure/camel-azure-eventhubs/src/test/java/org/apache/camel/component/azure/eventhubs/EventProcessorTest.java
index 03c875d2325..64fbee96dbf 100644
--- a/components/camel-azure/camel-azure-eventhubs/src/test/java/org/apache/camel/component/azure/eventhubs/EventProcessorTest.java
+++ b/components/camel-azure/camel-azure-eventhubs/src/test/java/org/apache/camel/component/azure/eventhubs/EventProcessorTest.java
@@ -70,6 +70,7 @@ public class EventProcessorTest {
assertNotNull(EventHubsClientFactory.createEventProcessorClient(configuration, onEvent, onError));
configuration.setTokenCredential(new IntelliJCredentialBuilder().tenantId("tenantId").build());
+ configuration.setCredentialType(CredentialType.TOKEN_CREDENTIAL);
assertThrows(IllegalArgumentException.class,
() -> EventHubsClientFactory.createEventProcessorClient(configuration, onEvent, onError));