This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-27749-azure-token-credential in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2f6ee2c5a14c4caf6b4ae03fd946fff080913eb6 Author: Claus Ibsen <[email protected]> AuthorDate: Fri Nov 27 21:28:41 2026 +0100 CAMEL-27749: camel-azure-eventgrid, camel-azure-servicebus, camel-azure-eventhubs - a DefaultAzureCredential set as tokenCredential is not used For a DefaultAzureCredential as tokenCredential, the components choose credentialType AZURE_IDENTITY, and for AZURE_IDENTITY the clients were built with a new DefaultAzureCredential. So a credential built with managedIdentityClientId(...), tenantId(...) or other settings was not used. AZURE_IDENTITY now uses the tokenCredential instance when it is set, and builds a new DefaultAzureCredential only without one (EventGridProducer, ServiceBusClientFactory, EventHubsClientFactory). In eventgrid, an explicit credentialType TOKEN_CREDENTIAL or AZURE_IDENTITY is kept when tokenCredential is set. Option descriptions and the upgrade guide are updated. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../camel/catalog/components/azure-eventgrid.json | 8 +- .../camel/catalog/components/azure-eventhubs.json | 8 +- .../camel/catalog/components/azure-servicebus.json | 8 +- .../component/azure/eventgrid/azure-eventgrid.json | 8 +- .../azure/eventgrid/EventGridComponent.java | 10 ++- .../azure/eventgrid/EventGridConfiguration.java | 11 ++- .../azure/eventgrid/EventGridProducer.java | 5 +- .../eventgrid/EventGridTokenCredentialTest.java | 98 ++++++++++++++++++++++ .../component/azure/eventhubs/azure-eventhubs.json | 8 +- .../azure/eventhubs/EventHubsConfiguration.java | 9 +- .../eventhubs/client/EventHubsClientFactory.java | 16 +++- .../EventHubsClientFactoryCredentialTest.java | 72 ++++++++++++++++ .../azure/servicebus/azure-servicebus.json | 8 +- .../azure/servicebus/ServiceBusConfiguration.java | 9 +- .../servicebus/client/ServiceBusClientFactory.java | 4 +- .../ServiceBusClientFactoryCredentialTest.java | 82 ++++++++++++++++++ .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 9 ++ .../dsl/AzureEventgridComponentBuilderFactory.java | 15 ++-- .../dsl/AzureEventhubsComponentBuilderFactory.java | 13 ++- .../AzureServicebusComponentBuilderFactory.java | 12 ++- .../dsl/EventGridEndpointBuilderFactory.java | 30 ++++--- .../dsl/EventHubsEndpointBuilderFactory.java | 78 +++++++++++++---- .../dsl/ServiceBusEndpointBuilderFactory.java | 72 +++++++++++++--- 23 files changed, 504 insertions(+), 89 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-eventgrid.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-eventgrid.json index 0fd521b8d1f9..b35a0f810f60 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-eventgrid.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-eventgrid.json @@ -30,8 +30,8 @@ "autowiredEnabled": { "index": 3, "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 t [...] "accessKey": { "index": 4, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The access key of the Event Grid topic, for credentialType ACCESS_KEY. The a [...] "azureKeyCredential": { "index": 5, "kind": "property", "displayName": "Azure Key Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.AzureKeyCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The access key of the Event Gr [...] - "credentialType": { "index": 6, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "ACCESS_KEY", "AZURE_IDENTITY", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ACCESS_KEY", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurati [...] - "tokenCredential": { "index": 7, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCrede [...] + "credentialType": { "index": 6, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "ACCESS_KEY", "AZURE_IDENTITY", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ACCESS_KEY", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurati [...] + "tokenCredential": { "index": 7, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCrede [...] }, "headers": { "CamelAzureEventGridEventType": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "autowired": false, "secret": false, "description": "The type of the event, the type attribute of the CloudEvent. If not set, the producer uses Camel.Event.", "constantName": "org.apache.camel.component.azure.eventgrid.EventGridConstants#EVENT_TYPE" }, @@ -49,7 +49,7 @@ "lazyStartProducer": { "index": 2, "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 [...] "accessKey": { "index": 3, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The access key of the Event Grid topic, for credentialType ACCESS_KEY. The [...] "azureKeyCredential": { "index": 4, "kind": "parameter", "displayName": "Azure Key Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.AzureKeyCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The access key of the Event G [...] - "credentialType": { "index": 5, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "ACCESS_KEY", "AZURE_IDENTITY", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ACCESS_KEY", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurat [...] - "tokenCredential": { "index": 6, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCred [...] + "credentialType": { "index": 5, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "ACCESS_KEY", "AZURE_IDENTITY", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ACCESS_KEY", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurat [...] + "tokenCredential": { "index": 6, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCred [...] } } 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 b61c1a6830e3..babe997aa027 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 @@ -45,10 +45,10 @@ "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 [...] "headerFilterStrategy": { "index": 19, "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." }, "connectionString": { "index": 20, "kind": "property", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Instead of supplying namespace, sharedAccessKey, sharedAccess [...] - "credentialType": { "index": 21, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration [...] + "credentialType": { "index": 21, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration [...] "sharedAccessKey": { "index": 22, "kind": "property", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." }, "sharedAccessName": { "index": 23, "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": 24, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Provide custom authentication credentia [...] + "tokenCredential": { "index": 24, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCred [...] }, "headers": { "CamelAzureEventHubsPartitionKey": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "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 publishing the event. I [...] @@ -88,10 +88,10 @@ "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, "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Sets the EventHubProducerAsyncClie [...] "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, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Instead of supplying namespace, sharedAccessKey, sharedAcces [...] - "credentialType": { "index": 22, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguratio [...] + "credentialType": { "index": 22, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguratio [...] "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, "security": "secret", "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": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Provide custom authentication credenti [...] + "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": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCre [...] }, "dstWorlds": { "EventHubsWorld": { "javaType": "org.apache.camel.component.azure.eventhubs.dst.EventHubsWorld", "fake": "a mocked EventHubsClientFactory that delivers the events per partition, and a fake CheckpointStore", "covers": [ "checkpointing by checkpointBatchSize and checkpointBatchTimeout", "one or two partitions with bursts and quiet periods of events", "an asynchronous downstream step" ], "faults": [ "the downstream step answers slowly", "the downstream step fails", "the checkpoint store [...] diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-servicebus.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-servicebus.json index eeaa5708e152..4e059b04ad28 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-servicebus.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-servicebus.json @@ -51,9 +51,9 @@ "sessionId": { "index": 24, "kind": "property", "displayName": "Session Id", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Session ID for session-enabled queues or topics." }, "autowiredEnabled": { "index": 25, "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": 26, "kind": "property", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Sets the connection string for a Service Bus namespace or a [...] - "credentialType": { "index": 27, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfigurati [...] + "credentialType": { "index": 27, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfigurati [...] "fullyQualifiedNamespace": { "index": 28, "kind": "property", "displayName": "Fully Qualified Namespace", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Fully Qualified Namespace of the service bus" }, - "tokenCredential": { "index": 29, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "A TokenCredential for Azure AD authen [...] + "tokenCredential": { "index": 29, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCr [...] }, "headers": { "CamelAzureServiceBusApplicationProperties": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "common", "required": false, "javaType": "Map<String, Object>", "deprecated": false, "autowired": false, "secret": false, "description": "The application properties (also known as custom properties) on messages sent and received by the producer and consumer, respectively.", "constantName": "org.apache.camel.component.azure.servicebus.ServiceBusConstants#APPLICAT [...] @@ -117,9 +117,9 @@ "sessionId": { "index": 25, "kind": "parameter", "displayName": "Session Id", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Session ID for session-enabled queues or topics." }, "lazyStartProducer": { "index": 26, "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": 27, "kind": "parameter", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Sets the connection string for a Service Bus namespace or [...] - "credentialType": { "index": 28, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfigurat [...] + "credentialType": { "index": 28, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfigurat [...] "fullyQualifiedNamespace": { "index": 29, "kind": "parameter", "displayName": "Fully Qualified Namespace", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Fully Qualified Namespace of the service bus" }, - "tokenCredential": { "index": 30, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "A TokenCredential for Azure AD authe [...] + "tokenCredential": { "index": 30, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenC [...] }, "dstWorlds": { "ServiceBusWorld": { "javaType": "org.apache.camel.component.azure.servicebus.dst.ServiceBusWorld", "fake": "FakeServiceBus: a queue in peek-lock mode (lock duration, delivery count, dead-letter queue) behind the processor and receiver clients of ServiceBusClientFactory", "covers": [ "the lock renewer of the consumer (PEEK_LOCK, maxAutoLockRenewDuration) with an asynchronous route", "processing that takes longer than the lock duration", "complete, abandon and dead-letter, also after [...] diff --git a/components/camel-azure/camel-azure-eventgrid/src/generated/resources/META-INF/org/apache/camel/component/azure/eventgrid/azure-eventgrid.json b/components/camel-azure/camel-azure-eventgrid/src/generated/resources/META-INF/org/apache/camel/component/azure/eventgrid/azure-eventgrid.json index 0fd521b8d1f9..b35a0f810f60 100644 --- a/components/camel-azure/camel-azure-eventgrid/src/generated/resources/META-INF/org/apache/camel/component/azure/eventgrid/azure-eventgrid.json +++ b/components/camel-azure/camel-azure-eventgrid/src/generated/resources/META-INF/org/apache/camel/component/azure/eventgrid/azure-eventgrid.json @@ -30,8 +30,8 @@ "autowiredEnabled": { "index": 3, "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 t [...] "accessKey": { "index": 4, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The access key of the Event Grid topic, for credentialType ACCESS_KEY. The a [...] "azureKeyCredential": { "index": 5, "kind": "property", "displayName": "Azure Key Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.AzureKeyCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The access key of the Event Gr [...] - "credentialType": { "index": 6, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "ACCESS_KEY", "AZURE_IDENTITY", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ACCESS_KEY", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurati [...] - "tokenCredential": { "index": 7, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCrede [...] + "credentialType": { "index": 6, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "ACCESS_KEY", "AZURE_IDENTITY", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ACCESS_KEY", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurati [...] + "tokenCredential": { "index": 7, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCrede [...] }, "headers": { "CamelAzureEventGridEventType": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "autowired": false, "secret": false, "description": "The type of the event, the type attribute of the CloudEvent. If not set, the producer uses Camel.Event.", "constantName": "org.apache.camel.component.azure.eventgrid.EventGridConstants#EVENT_TYPE" }, @@ -49,7 +49,7 @@ "lazyStartProducer": { "index": 2, "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 [...] "accessKey": { "index": 3, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The access key of the Event Grid topic, for credentialType ACCESS_KEY. The [...] "azureKeyCredential": { "index": 4, "kind": "parameter", "displayName": "Azure Key Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.AzureKeyCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The access key of the Event G [...] - "credentialType": { "index": 5, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "ACCESS_KEY", "AZURE_IDENTITY", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ACCESS_KEY", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurat [...] - "tokenCredential": { "index": 6, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCred [...] + "credentialType": { "index": 5, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "ACCESS_KEY", "AZURE_IDENTITY", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "ACCESS_KEY", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurat [...] + "tokenCredential": { "index": 6, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventgrid.EventGridConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCred [...] } } diff --git a/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridComponent.java b/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridComponent.java index 5bed97d3138f..be542e3908ff 100644 --- a/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridComponent.java +++ b/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridComponent.java @@ -63,9 +63,13 @@ public class EventGridComponent extends DefaultComponent { endpoint.getConfiguration().setCredentialType(CredentialType.AZURE_IDENTITY); } } else if (endpoint.getConfiguration().getTokenCredential() != null) { - boolean azure = endpoint.getConfiguration().getTokenCredential() instanceof DefaultAzureCredential; - endpoint.getConfiguration() - .setCredentialType(azure ? CredentialType.AZURE_IDENTITY : CredentialType.TOKEN_CREDENTIAL); + // keep an explicit TOKEN_CREDENTIAL or AZURE_IDENTITY: both use the configured tokenCredential + CredentialType type = endpoint.getConfiguration().getCredentialType(); + if (type != CredentialType.TOKEN_CREDENTIAL && type != CredentialType.AZURE_IDENTITY) { + boolean azure = endpoint.getConfiguration().getTokenCredential() instanceof DefaultAzureCredential; + endpoint.getConfiguration() + .setCredentialType(azure ? CredentialType.AZURE_IDENTITY : CredentialType.TOKEN_CREDENTIAL); + } } else if (endpoint.getConfiguration().getAzureKeyCredential() != null || endpoint.getConfiguration().getAccessKey() != null) { endpoint.getConfiguration().setCredentialType(CredentialType.ACCESS_KEY); diff --git a/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridConfiguration.java b/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridConfiguration.java index d305a0ad154d..325a9739d154 100644 --- a/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridConfiguration.java +++ b/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridConfiguration.java @@ -50,15 +50,20 @@ public class EventGridConfiguration implements Cloneable { @UriParam(label = "security", security = "secret", description = "The com.azure.core.credential.TokenCredential that authenticates the producer with Microsoft" - + " Entra ID. When it is set, the accessKey and azureKeyCredential options are not used.") + + " Entra ID, such as a DefaultAzureCredential built with a managed identity client id or a" + + " tenant id; this instance is used as it is, also with credentialType AZURE_IDENTITY. When it" + + " is set, the accessKey and azureKeyCredential options are not used.") @Metadata(autowired = true) private TokenCredential tokenCredential; @UriParam(label = "security", enums = "ACCESS_KEY,AZURE_IDENTITY,TOKEN_CREDENTIAL", defaultValue = "ACCESS_KEY", description = "How the producer authenticates: ACCESS_KEY with the azureKeyCredential or accessKey option," + " TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY with a" - + " DefaultAzureCredential of the Azure Identity library. When one of these credential options is" - + " set, the component chooses the type from it, so set this option only for AZURE_IDENTITY.") + + " DefaultAzureCredential of the Azure Identity library (the tokenCredential option when it is" + + " set, else a new one). When tokenCredential is set, an explicit TOKEN_CREDENTIAL or" + + " AZURE_IDENTITY is kept, else the type is AZURE_IDENTITY for a DefaultAzureCredential and" + + " TOKEN_CREDENTIAL for another credential; when accessKey or azureKeyCredential is set, it is" + + " ACCESS_KEY.") private CredentialType credentialType = CredentialType.ACCESS_KEY; @UriParam(label = "producer", diff --git a/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridProducer.java b/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridProducer.java index 51ef52f6d8c9..0e0b711ba8b5 100644 --- a/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridProducer.java +++ b/components/camel-azure/camel-azure-eventgrid/src/main/java/org/apache/camel/component/azure/eventgrid/EventGridProducer.java @@ -209,7 +209,10 @@ public class EventGridProducer extends DefaultProducer { builder.credential(configuration.getTokenCredential()); break; case AZURE_IDENTITY: - builder.credential(new DefaultAzureCredentialBuilder().build()); + // a DefaultAzureCredential set as tokenCredential (with a managed identity client id, a tenant id, ...) + // is used as is + builder.credential(configuration.getTokenCredential() != null + ? configuration.getTokenCredential() : new DefaultAzureCredentialBuilder().build()); break; default: throw new IllegalArgumentException("Unknown credential type: " + configuration.getCredentialType()); diff --git a/components/camel-azure/camel-azure-eventgrid/src/test/java/org/apache/camel/component/azure/eventgrid/EventGridTokenCredentialTest.java b/components/camel-azure/camel-azure-eventgrid/src/test/java/org/apache/camel/component/azure/eventgrid/EventGridTokenCredentialTest.java new file mode 100644 index 000000000000..707ae60d286d --- /dev/null +++ b/components/camel-azure/camel-azure-eventgrid/src/test/java/org/apache/camel/component/azure/eventgrid/EventGridTokenCredentialTest.java @@ -0,0 +1,98 @@ +/* + * 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.eventgrid; + +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.credential.TokenCredential; +import com.azure.identity.DefaultAzureCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.messaging.eventgrid.EventGridPublisherClientBuilder; +import org.apache.camel.Producer; +import org.apache.camel.component.azure.common.CredentialType; +import org.apache.camel.test.junit6.CamelTestSupport; +import org.junit.jupiter.api.Test; +import org.mockito.MockedConstruction; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.same; +import static org.mockito.Mockito.RETURNS_SELF; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.withSettings; + +/** + * A DefaultAzureCredential set as tokenCredential is the credential of the publisher client. + */ +class EventGridTokenCredentialTest extends CamelTestSupport { + + private static final String TOPIC = "azure-eventgrid:https://mytopic.eventgrid.azure.net/api/events"; + + @Test + void defaultAzureCredentialIsUsed() throws Exception { + DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().managedIdentityClientId("my-id").build(); + context.getRegistry().bind("cred", credential); + + EventGridEndpoint endpoint = context.getEndpoint(TOPIC + "?tokenCredential=#cred", EventGridEndpoint.class); + assertEquals(CredentialType.AZURE_IDENTITY, endpoint.getConfiguration().getCredentialType()); + + assertCredentialOfClient(endpoint, credential); + } + + @Test + void explicitTokenCredentialTypeIsKept() throws Exception { + DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().tenantId("my-tenant").build(); + context.getRegistry().bind("cred", credential); + + EventGridEndpoint endpoint = context.getEndpoint(TOPIC + "?tokenCredential=#cred&credentialType=TOKEN_CREDENTIAL", + EventGridEndpoint.class); + assertEquals(CredentialType.TOKEN_CREDENTIAL, endpoint.getConfiguration().getCredentialType()); + + assertCredentialOfClient(endpoint, credential); + } + + @Test + void azureIdentityWithoutTokenCredentialBuildsOne() throws Exception { + EventGridEndpoint endpoint = context.getEndpoint(TOPIC + "?credentialType=AZURE_IDENTITY", EventGridEndpoint.class); + + try (MockedConstruction<EventGridPublisherClientBuilder> builders + = mockConstruction(EventGridPublisherClientBuilder.class, withSettings().defaultAnswer(RETURNS_SELF))) { + Producer producer = endpoint.createProducer(); + producer.start(); + producer.stop(); + + verify(builders.constructed().get(0)).credential(any(DefaultAzureCredential.class)); + } + } + + private static void assertCredentialOfClient(EventGridEndpoint endpoint, TokenCredential credential) throws Exception { + try (MockedConstruction<EventGridPublisherClientBuilder> builders + = mockConstruction(EventGridPublisherClientBuilder.class, withSettings().defaultAnswer(RETURNS_SELF))) { + Producer producer = endpoint.createProducer(); + producer.start(); + producer.stop(); + + assertEquals(1, builders.constructed().size()); + EventGridPublisherClientBuilder builder = builders.constructed().get(0); + verify(builder).credential(same(credential)); + verify(builder, never()).credential(any(AzureKeyCredential.class)); + } + assertSame(credential, endpoint.getConfiguration().getTokenCredential()); + } +} diff --git a/components/camel-azure/camel-azure-eventhubs/src/generated/resources/META-INF/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json b/components/camel-azure/camel-azure-eventhubs/src/generated/resources/META-INF/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json index b61c1a6830e3..babe997aa027 100644 --- a/components/camel-azure/camel-azure-eventhubs/src/generated/resources/META-INF/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json +++ b/components/camel-azure/camel-azure-eventhubs/src/generated/resources/META-INF/org/apache/camel/component/azure/eventhubs/azure-eventhubs.json @@ -45,10 +45,10 @@ "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 [...] "headerFilterStrategy": { "index": 19, "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." }, "connectionString": { "index": 20, "kind": "property", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Instead of supplying namespace, sharedAccessKey, sharedAccess [...] - "credentialType": { "index": 21, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration [...] + "credentialType": { "index": 21, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration [...] "sharedAccessKey": { "index": 22, "kind": "property", "displayName": "Shared Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The generated value for the SharedAccessName." }, "sharedAccessName": { "index": 23, "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": 24, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Provide custom authentication credentia [...] + "tokenCredential": { "index": 24, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCred [...] }, "headers": { "CamelAzureEventHubsPartitionKey": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "", "required": false, "javaType": "String", "deprecated": false, "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 publishing the event. I [...] @@ -88,10 +88,10 @@ "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, "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Sets the EventHubProducerAsyncClie [...] "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, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Instead of supplying namespace, sharedAccessKey, sharedAcces [...] - "credentialType": { "index": 22, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguratio [...] + "credentialType": { "index": 22, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguratio [...] "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, "security": "secret", "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": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "Provide custom authentication credenti [...] + "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": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCre [...] }, "dstWorlds": { "EventHubsWorld": { "javaType": "org.apache.camel.component.azure.eventhubs.dst.EventHubsWorld", "fake": "a mocked EventHubsClientFactory that delivers the events per partition, and a fake CheckpointStore", "covers": [ "checkpointing by checkpointBatchSize and checkpointBatchTimeout", "one or two partitions with bursts and quiet periods of events", "an asynchronous downstream step" ], "faults": [ "the downstream step answers slowly", "the downstream step fails", "the checkpoint store [...] 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 62a35d360487..de75bc9ce101 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 @@ -145,7 +145,9 @@ public class EventHubsConfiguration implements Cloneable { } /** - * Provide custom authentication credentials using an implementation of {@link TokenCredential}. + * The com.azure.core.credential.TokenCredential to authenticate with Microsoft Entra ID, for credentialType + * TOKEN_CREDENTIAL or AZURE_IDENTITY. A DefaultAzureCredential built with a managed identity client id or a tenant + * id is used as it is. */ public TokenCredential getTokenCredential() { return tokenCredential; @@ -359,7 +361,10 @@ public class EventHubsConfiguration implements Cloneable { } /** - * Determines the credential strategy to adopt + * Determines the credential strategy to adopt: CONNECTION_STRING, TOKEN_CREDENTIAL with the tokenCredential option, + * or AZURE_IDENTITY with a DefaultAzureCredential: the tokenCredential option when it is set, otherwise a new one. + * When not set, it is TOKEN_CREDENTIAL (or AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. */ public void setCredentialType(CredentialType credentialType) { this.credentialType = credentialType; 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 6f1b49a26356..7941b19e9976 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.core.credential.TokenCredential; import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.messaging.eventhubs.CheckpointStore; import com.azure.messaging.eventhubs.EventHubClientBuilder; @@ -70,7 +71,7 @@ public final class EventHubsClientFactory { return eventHubClientBuilder .fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration)) .eventHubName(configuration.getEventHubName()) - .credential(new DefaultAzureCredentialBuilder().build()) + .credential(azureIdentityCredential(configuration)) .buildAsyncProducerClient(); } @@ -101,7 +102,7 @@ public final class EventHubsClientFactory { return eventHubClientBuilder .fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration)) .eventHubName(configuration.getEventHubName()) - .credential(new DefaultAzureCredentialBuilder().build()) + .credential(azureIdentityCredential(configuration)) .buildAsyncConsumerClient(); } @@ -150,10 +151,19 @@ public final class EventHubsClientFactory { return eventProcessorClientBuilder .fullyQualifiedNamespace(getFullyQualifiedNamespace(configuration)) .eventHubName(configuration.getEventHubName()) - .credential(new DefaultAzureCredentialBuilder().build()) + .credential(azureIdentityCredential(configuration)) .buildEventProcessorClient(); } + /** + * The credential for AZURE_IDENTITY: the tokenCredential when it is set (such as a DefaultAzureCredential with a + * managed identity client id or a tenant id), otherwise a new DefaultAzureCredential. + */ + static TokenCredential azureIdentityCredential(final EventHubsConfiguration configuration) { + TokenCredential credential = configuration.getTokenCredential(); + return credential != null ? credential : new DefaultAzureCredentialBuilder().build(); + } + // public for testing purposes public static BlobContainerAsyncClient createBlobContainerClient(final EventHubsConfiguration configuration) { return new BlobContainerClientBuilder() diff --git a/components/camel-azure/camel-azure-eventhubs/src/test/java/org/apache/camel/component/azure/eventhubs/client/EventHubsClientFactoryCredentialTest.java b/components/camel-azure/camel-azure-eventhubs/src/test/java/org/apache/camel/component/azure/eventhubs/client/EventHubsClientFactoryCredentialTest.java new file mode 100644 index 000000000000..8b5e935eb16a --- /dev/null +++ b/components/camel-azure/camel-azure-eventhubs/src/test/java/org/apache/camel/component/azure/eventhubs/client/EventHubsClientFactoryCredentialTest.java @@ -0,0 +1,72 @@ +/* + * 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.client; + +import com.azure.identity.DefaultAzureCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.messaging.eventhubs.EventHubClientBuilder; +import org.apache.camel.component.azure.common.CredentialType; +import org.apache.camel.component.azure.eventhubs.EventHubsConfiguration; +import org.junit.jupiter.api.Test; +import org.mockito.MockedConstruction; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.mockito.ArgumentMatchers.same; +import static org.mockito.Mockito.RETURNS_SELF; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.withSettings; + +/** + * A DefaultAzureCredential set as tokenCredential is the credential of the clients with AZURE_IDENTITY. + */ +class EventHubsClientFactoryCredentialTest { + + @Test + void azureIdentityUsesTheTokenCredential() { + DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().managedIdentityClientId("my-id").build(); + EventHubsConfiguration configuration = configuration(); + configuration.setTokenCredential(credential); + + assertSame(credential, EventHubsClientFactory.azureIdentityCredential(configuration)); + + try (MockedConstruction<EventHubClientBuilder> builders + = mockConstruction(EventHubClientBuilder.class, withSettings().defaultAnswer(RETURNS_SELF))) { + EventHubsClientFactory.createEventHubProducerAsyncClient(configuration); + EventHubsClientFactory.createEventHubConsumerAsyncClient(configuration); + + assertEquals(2, builders.constructed().size()); + verify(builders.constructed().get(0)).credential(same(credential)); + verify(builders.constructed().get(1)).credential(same(credential)); + } + } + + @Test + void azureIdentityWithoutTokenCredentialBuildsOne() { + assertNotNull(EventHubsClientFactory.azureIdentityCredential(configuration())); + } + + private static EventHubsConfiguration configuration() { + EventHubsConfiguration configuration = new EventHubsConfiguration(); + configuration.setCredentialType(CredentialType.AZURE_IDENTITY); + configuration.setNamespace("mynamespace"); + configuration.setEventHubName("myhub"); + return configuration; + } +} diff --git a/components/camel-azure/camel-azure-servicebus/src/generated/resources/META-INF/org/apache/camel/component/azure/servicebus/azure-servicebus.json b/components/camel-azure/camel-azure-servicebus/src/generated/resources/META-INF/org/apache/camel/component/azure/servicebus/azure-servicebus.json index eeaa5708e152..4e059b04ad28 100644 --- a/components/camel-azure/camel-azure-servicebus/src/generated/resources/META-INF/org/apache/camel/component/azure/servicebus/azure-servicebus.json +++ b/components/camel-azure/camel-azure-servicebus/src/generated/resources/META-INF/org/apache/camel/component/azure/servicebus/azure-servicebus.json @@ -51,9 +51,9 @@ "sessionId": { "index": 24, "kind": "property", "displayName": "Session Id", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Session ID for session-enabled queues or topics." }, "autowiredEnabled": { "index": 25, "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": 26, "kind": "property", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Sets the connection string for a Service Bus namespace or a [...] - "credentialType": { "index": 27, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfigurati [...] + "credentialType": { "index": 27, "kind": "property", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfigurati [...] "fullyQualifiedNamespace": { "index": 28, "kind": "property", "displayName": "Fully Qualified Namespace", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Fully Qualified Namespace of the service bus" }, - "tokenCredential": { "index": 29, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "A TokenCredential for Azure AD authen [...] + "tokenCredential": { "index": 29, "kind": "property", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenCr [...] }, "headers": { "CamelAzureServiceBusApplicationProperties": { "index": 0, "kind": "header", "displayName": "", "group": "common", "label": "common", "required": false, "javaType": "Map<String, Object>", "deprecated": false, "autowired": false, "secret": false, "description": "The application properties (also known as custom properties) on messages sent and received by the producer and consumer, respectively.", "constantName": "org.apache.camel.component.azure.servicebus.ServiceBusConstants#APPLICAT [...] @@ -117,9 +117,9 @@ "sessionId": { "index": 25, "kind": "parameter", "displayName": "Session Id", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Session ID for session-enabled queues or topics." }, "lazyStartProducer": { "index": 26, "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": 27, "kind": "parameter", "displayName": "Connection String", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Sets the connection string for a Service Bus namespace or [...] - "credentialType": { "index": 28, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfigurat [...] + "credentialType": { "index": 28, "kind": "parameter", "displayName": "Credential Type", "group": "security", "label": "security", "required": false, "type": "enum", "javaType": "org.apache.camel.component.azure.common.CredentialType", "enum": [ "AZURE_IDENTITY", "CONNECTION_STRING", "TOKEN_CREDENTIAL" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "CONNECTION_STRING", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfigurat [...] "fullyQualifiedNamespace": { "index": 29, "kind": "parameter", "displayName": "Fully Qualified Namespace", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "Fully Qualified Namespace of the service bus" }, - "tokenCredential": { "index": 30, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "A TokenCredential for Azure AD authe [...] + "tokenCredential": { "index": 30, "kind": "parameter", "displayName": "Token Credential", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "com.azure.core.credential.TokenCredential", "deprecated": false, "autowired": true, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", "configurationField": "configuration", "description": "The com.azure.core.credential.TokenC [...] }, "dstWorlds": { "ServiceBusWorld": { "javaType": "org.apache.camel.component.azure.servicebus.dst.ServiceBusWorld", "fake": "FakeServiceBus: a queue in peek-lock mode (lock duration, delivery count, dead-letter queue) behind the processor and receiver clients of ServiceBusClientFactory", "covers": [ "the lock renewer of the consumer (PEEK_LOCK, maxAutoLockRenewDuration) with an asynchronous route", "processing that takes longer than the lock duration", "complete, abandon and dead-letter, also after [...] diff --git a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java index 7ec8d4a457b7..80ffb3044724 100644 --- a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java +++ b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java @@ -348,7 +348,9 @@ public class ServiceBusConfiguration implements Cloneable, HeaderFilterStrategyA } /** - * A TokenCredential for Azure AD authentication. + * The com.azure.core.credential.TokenCredential to authenticate with Microsoft Entra ID, for credentialType + * TOKEN_CREDENTIAL or AZURE_IDENTITY. A DefaultAzureCredential built with a managed identity client id or a tenant + * id is used as it is. */ public TokenCredential getTokenCredential() { return tokenCredential; @@ -409,7 +411,10 @@ public class ServiceBusConfiguration implements Cloneable, HeaderFilterStrategyA } /** - * Determines the credential strategy to adopt + * Determines the credential strategy to adopt: CONNECTION_STRING, TOKEN_CREDENTIAL with the tokenCredential option, + * or AZURE_IDENTITY with a DefaultAzureCredential: the tokenCredential option when it is set, otherwise a new one. + * When not set, it is TOKEN_CREDENTIAL (or AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. */ public void setCredentialType(CredentialType credentialType) { this.credentialType = credentialType; diff --git a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java index c0a410329743..f86da90a30f0 100644 --- a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java +++ b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java @@ -45,7 +45,9 @@ public final class ServiceBusClientFactory { switch (type) { case CONNECTION_STRING -> builder.connectionString(configuration.getConnectionString()); case TOKEN_CREDENTIAL -> builder.credential(fullyQualifiedNamespace, credential); - case AZURE_IDENTITY -> builder.credential(fullyQualifiedNamespace, new DefaultAzureCredentialBuilder().build()); + // a DefaultAzureCredential set as tokenCredential (with a managed identity client id, a tenant id, ...) is used as is + case AZURE_IDENTITY -> builder.credential(fullyQualifiedNamespace, + credential != null ? credential : new DefaultAzureCredentialBuilder().build()); } return builder; diff --git a/components/camel-azure/camel-azure-servicebus/src/test/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactoryCredentialTest.java b/components/camel-azure/camel-azure-servicebus/src/test/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactoryCredentialTest.java new file mode 100644 index 000000000000..53d46cb2d18d --- /dev/null +++ b/components/camel-azure/camel-azure-servicebus/src/test/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactoryCredentialTest.java @@ -0,0 +1,82 @@ +/* + * 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.servicebus.client; + +import com.azure.identity.DefaultAzureCredential; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.messaging.servicebus.ServiceBusClientBuilder; +import org.apache.camel.component.azure.common.CredentialType; +import org.apache.camel.component.azure.servicebus.ServiceBusConfiguration; +import org.junit.jupiter.api.Test; +import org.mockito.MockedConstruction; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.same; +import static org.mockito.Mockito.RETURNS_SELF; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; + +/** + * A DefaultAzureCredential set as tokenCredential is the credential of the client with AZURE_IDENTITY. + */ +class ServiceBusClientFactoryCredentialTest { + + private static final String NAMESPACE = "mynamespace.servicebus.windows.net"; + + @Test + void azureIdentityUsesTheTokenCredential() { + DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().managedIdentityClientId("my-id").build(); + ServiceBusConfiguration configuration = configuration(); + configuration.setTokenCredential(credential); + + ServiceBusClientBuilder builder = buildSenderClient(configuration); + + verify(builder).credential(eq(NAMESPACE), same(credential)); + } + + @Test + void azureIdentityWithoutTokenCredentialBuildsOne() { + ServiceBusClientBuilder builder = buildSenderClient(configuration()); + + verify(builder).credential(eq(NAMESPACE), any(DefaultAzureCredential.class)); + } + + private static ServiceBusConfiguration configuration() { + ServiceBusConfiguration configuration = new ServiceBusConfiguration(); + configuration.setCredentialType(CredentialType.AZURE_IDENTITY); + configuration.setFullyQualifiedNamespace(NAMESPACE); + configuration.setTopicOrQueueName("myqueue"); + return configuration; + } + + private static ServiceBusClientBuilder buildSenderClient(ServiceBusConfiguration configuration) { + ServiceBusClientBuilder.ServiceBusSenderClientBuilder sender + = mock(ServiceBusClientBuilder.ServiceBusSenderClientBuilder.class, RETURNS_SELF); + try (MockedConstruction<ServiceBusClientBuilder> builders = mockConstruction(ServiceBusClientBuilder.class, + withSettings().defaultAnswer(RETURNS_SELF), (mock, context) -> when(mock.sender()).thenReturn(sender))) { + new ServiceBusClientFactory().createServiceBusSenderClient(configuration); + + assertEquals(1, builders.constructed().size()); + return builders.constructed().get(0); + } + } +} diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc index 17af91664876..332f9a9724ac 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc @@ -12664,6 +12664,15 @@ ignored without a message. An endpoint with `sslContextParameters`, or with `use global `SSLContextParameters`, now fails to start. Remove the option, and configure the trust store (and the key store for a client certificate) with the `javax.net.ssl.*` system properties of the JVM. +=== camel-azure-eventgrid, camel-azure-servicebus, camel-azure-eventhubs - a DefaultAzureCredential set as tokenCredential is used + +With `credentialType` `AZURE_IDENTITY`, which these components also choose when the `tokenCredential` option is a +`DefaultAzureCredential`, the clients now authenticate with the configured `tokenCredential` instance. Before, they +built a new `DefaultAzureCredential` with the default settings, so a credential built with +`managedIdentityClientId(...)`, `tenantId(...)` or other settings was not used. Without `tokenCredential`, +`AZURE_IDENTITY` still builds a new `DefaultAzureCredential`. In camel-azure-eventgrid, an explicit `credentialType` +`TOKEN_CREDENTIAL` or `AZURE_IDENTITY` is no longer replaced when `tokenCredential` is set. + === Kamelets - removed Kamelets The Kamelet catalog (camel-kamelets 4.24) removes Kamelets that could not work on Camel 4.23 or 4.24: diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureEventgridComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureEventgridComponentBuilderFactory.java index 01344e04686e..b035697936f6 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureEventgridComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureEventgridComponentBuilderFactory.java @@ -176,9 +176,12 @@ public interface AzureEventgridComponentBuilderFactory { * How the producer authenticates: ACCESS_KEY with the * azureKeyCredential or accessKey option, TOKEN_CREDENTIAL with the * tokenCredential option, or AZURE_IDENTITY with a - * DefaultAzureCredential of the Azure Identity library. When one of - * these credential options is set, the component chooses the type from - * it, so set this option only for AZURE_IDENTITY. + * DefaultAzureCredential of the Azure Identity library (the + * tokenCredential option when it is set, else a new one). When + * tokenCredential is set, an explicit TOKEN_CREDENTIAL or + * AZURE_IDENTITY is kept, else the type is AZURE_IDENTITY for a + * DefaultAzureCredential and TOKEN_CREDENTIAL for another credential; + * when accessKey or azureKeyCredential is set, it is ACCESS_KEY. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> type. @@ -196,8 +199,10 @@ public interface AzureEventgridComponentBuilderFactory { /** * The com.azure.core.credential.TokenCredential that authenticates the - * producer with Microsoft Entra ID. When it is set, the accessKey and - * azureKeyCredential options are not used. + * producer with Microsoft Entra ID, such as a DefaultAzureCredential + * built with a managed identity client id or a tenant id; this instance + * is used as it is, also with credentialType AZURE_IDENTITY. When it is + * set, the accessKey and azureKeyCredential options are not used. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureEventhubsComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureEventhubsComponentBuilderFactory.java index 8a94c1beec7e..f01c39315127 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureEventhubsComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureEventhubsComponentBuilderFactory.java @@ -469,7 +469,12 @@ public interface AzureEventhubsComponentBuilderFactory { /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> type. @@ -516,8 +521,10 @@ public interface AzureEventhubsComponentBuilderFactory { } /** - * Provide custom authentication credentials using an implementation of - * TokenCredential. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureServicebusComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureServicebusComponentBuilderFactory.java index dbc9a59ab3af..64b0ced73175 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureServicebusComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureServicebusComponentBuilderFactory.java @@ -559,7 +559,12 @@ public interface AzureServicebusComponentBuilderFactory { /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> type. @@ -591,7 +596,10 @@ public interface AzureServicebusComponentBuilderFactory { } /** - * A TokenCredential for Azure AD authentication. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/EventGridEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/EventGridEndpointBuilderFactory.java index ef12c9242e1d..dfb5b7938623 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/EventGridEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/EventGridEndpointBuilderFactory.java @@ -136,9 +136,12 @@ public interface EventGridEndpointBuilderFactory { * How the producer authenticates: ACCESS_KEY with the * azureKeyCredential or accessKey option, TOKEN_CREDENTIAL with the * tokenCredential option, or AZURE_IDENTITY with a - * DefaultAzureCredential of the Azure Identity library. When one of - * these credential options is set, the component chooses the type from - * it, so set this option only for AZURE_IDENTITY. + * DefaultAzureCredential of the Azure Identity library (the + * tokenCredential option when it is set, else a new one). When + * tokenCredential is set, an explicit TOKEN_CREDENTIAL or + * AZURE_IDENTITY is kept, else the type is AZURE_IDENTITY for a + * DefaultAzureCredential and TOKEN_CREDENTIAL for another credential; + * when accessKey or azureKeyCredential is set, it is ACCESS_KEY. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -158,9 +161,12 @@ public interface EventGridEndpointBuilderFactory { * How the producer authenticates: ACCESS_KEY with the * azureKeyCredential or accessKey option, TOKEN_CREDENTIAL with the * tokenCredential option, or AZURE_IDENTITY with a - * DefaultAzureCredential of the Azure Identity library. When one of - * these credential options is set, the component chooses the type from - * it, so set this option only for AZURE_IDENTITY. + * DefaultAzureCredential of the Azure Identity library (the + * tokenCredential option when it is set, else a new one). When + * tokenCredential is set, an explicit TOKEN_CREDENTIAL or + * AZURE_IDENTITY is kept, else the type is AZURE_IDENTITY for a + * DefaultAzureCredential and TOKEN_CREDENTIAL for another credential; + * when accessKey or azureKeyCredential is set, it is ACCESS_KEY. * * The option will be converted to a * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -178,8 +184,10 @@ public interface EventGridEndpointBuilderFactory { } /** * The com.azure.core.credential.TokenCredential that authenticates the - * producer with Microsoft Entra ID. When it is set, the accessKey and - * azureKeyCredential options are not used. + * producer with Microsoft Entra ID, such as a DefaultAzureCredential + * built with a managed identity client id or a tenant id; this instance + * is used as it is, also with credentialType AZURE_IDENTITY. When it is + * set, the accessKey and azureKeyCredential options are not used. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> type. @@ -195,8 +203,10 @@ public interface EventGridEndpointBuilderFactory { } /** * The com.azure.core.credential.TokenCredential that authenticates the - * producer with Microsoft Entra ID. When it is set, the accessKey and - * azureKeyCredential options are not used. + * producer with Microsoft Entra ID, such as a DefaultAzureCredential + * built with a managed identity client id or a tenant id; this instance + * is used as it is, also with credentialType AZURE_IDENTITY. When it is + * set, the accessKey and azureKeyCredential options are not used. * * The option will be converted to a * <code>com.azure.core.credential.TokenCredential</code> type. diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/EventHubsEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/EventHubsEndpointBuilderFactory.java index e42ffefe28cf..8a7e32c5fdac 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/EventHubsEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/EventHubsEndpointBuilderFactory.java @@ -408,7 +408,12 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -425,7 +430,12 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option will be converted to a * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -470,8 +480,10 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Provide custom authentication credentials using an implementation of - * TokenCredential. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> type. @@ -486,8 +498,10 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Provide custom authentication credentials using an implementation of - * TokenCredential. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option will be converted to a * <code>com.azure.core.credential.TokenCredential</code> type. @@ -814,7 +828,12 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -831,7 +850,12 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option will be converted to a * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -876,8 +900,10 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Provide custom authentication credentials using an implementation of - * TokenCredential. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> type. @@ -892,8 +918,10 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Provide custom authentication credentials using an implementation of - * TokenCredential. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option will be converted to a * <code>com.azure.core.credential.TokenCredential</code> type. @@ -1062,7 +1090,12 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -1079,7 +1112,12 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option will be converted to a * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -1124,8 +1162,10 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Provide custom authentication credentials using an implementation of - * TokenCredential. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> type. @@ -1140,8 +1180,10 @@ public interface EventHubsEndpointBuilderFactory { return this; } /** - * Provide custom authentication credentials using an implementation of - * TokenCredential. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option will be converted to a * <code>com.azure.core.credential.TokenCredential</code> type. diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ServiceBusEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ServiceBusEndpointBuilderFactory.java index 9abd5a6da7e6..09ee617774d8 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ServiceBusEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ServiceBusEndpointBuilderFactory.java @@ -582,7 +582,12 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -599,7 +604,12 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option will be converted to a * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -630,7 +640,10 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * A TokenCredential for Azure AD authentication. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> type. @@ -645,7 +658,10 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * A TokenCredential for Azure AD authentication. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option will be converted to a * <code>com.azure.core.credential.TokenCredential</code> type. @@ -1198,7 +1214,12 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -1215,7 +1236,12 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option will be converted to a * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -1246,7 +1272,10 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * A TokenCredential for Azure AD authentication. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> type. @@ -1261,7 +1290,10 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * A TokenCredential for Azure AD authentication. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option will be converted to a * <code>com.azure.core.credential.TokenCredential</code> type. @@ -1564,7 +1596,12 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option is a: * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -1581,7 +1618,12 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * Determines the credential strategy to adopt. + * Determines the credential strategy to adopt: CONNECTION_STRING, + * TOKEN_CREDENTIAL with the tokenCredential option, or AZURE_IDENTITY + * with a DefaultAzureCredential: the tokenCredential option when it is + * set, otherwise a new one. When not set, it is TOKEN_CREDENTIAL (or + * AZURE_IDENTITY for a DefaultAzureCredential) when tokenCredential is + * set, else CONNECTION_STRING. * * The option will be converted to a * <code>org.apache.camel.component.azure.common.CredentialType</code> @@ -1612,7 +1654,10 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * A TokenCredential for Azure AD authentication. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option is a: * <code>com.azure.core.credential.TokenCredential</code> type. @@ -1627,7 +1672,10 @@ public interface ServiceBusEndpointBuilderFactory { return this; } /** - * A TokenCredential for Azure AD authentication. + * The com.azure.core.credential.TokenCredential to authenticate with + * Microsoft Entra ID, for credentialType TOKEN_CREDENTIAL or + * AZURE_IDENTITY. A DefaultAzureCredential built with a managed + * identity client id or a tenant id is used as it is. * * The option will be converted to a * <code>com.azure.core.credential.TokenCredential</code> type.
