This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 14da3fc CAMEL-14646: [camel-azure] Add the possibility to set credentials as query parameters (#3613) 14da3fc is described below commit 14da3fc8af5f0a9e4982a8c2ad035691ba1043c4 Author: Luigi De Masi <5583341+luigidem...@users.noreply.github.com> AuthorDate: Sat Mar 7 16:37:29 2020 +0100 CAMEL-14646: [camel-azure] Add the possibility to set credentials as query parameters (#3613) --- .../azure/blob/BlobServiceComponentConfigurer.java | 4 + .../azure/blob/BlobServiceEndpointConfigurer.java | 4 + .../queue/QueueServiceComponentConfigurer.java | 4 + .../queue/QueueServiceEndpointConfigurer.java | 4 + .../camel/component/azure/blob/azure-blob.json | 8 +- .../camel/component/azure/queue/azure-queue.json | 8 +- .../src/main/docs/azure-blob-component.adoc | 8 +- .../src/main/docs/azure-queue-component.adoc | 8 +- .../component/azure/blob/BlobServiceComponent.java | 11 +- .../component/azure/blob/BlobServiceUtil.java | 12 +- .../azure/common/AbstractConfiguration.java | 41 ++++ .../azure/queue/QueueServiceComponent.java | 8 +- .../component/azure/queue/QueueServiceUtil.java | 8 +- ...lobServiceComponentConfigurationClientTest.java | 52 +---- .../BlobServiceComponentConfigurationTest.java | 33 +-- .../component/azure/blob/BlobServiceUtilTest.java | 14 +- .../azure/common/AzureCredentialsTest.java | 224 +++++++++++++++++++++ .../azure/common/AzureServiceCommonTestUtil.java | 108 ++++++++++ .../azure/common/MissingCredentialsTest.java | 176 ++++++++++++++++ ...eueServiceComponentClientConfigurationTest.java | 15 +- .../QueueServiceComponentConfigurationTest.java | 15 +- .../azure/queue/QueueServiceUtilTest.java | 16 +- .../dsl/AzureBlobComponentBuilderFactory.java | 26 +++ .../dsl/AzureQueueComponentBuilderFactory.java | 26 +++ .../dsl/BlobServiceEndpointBuilderFactory.java | 72 +++++++ .../dsl/QueueServiceEndpointBuilderFactory.java | 72 +++++++ .../modules/ROOT/pages/azure-blob-component.adoc | 8 +- .../modules/ROOT/pages/azure-queue-component.adoc | 8 +- 28 files changed, 838 insertions(+), 155 deletions(-) diff --git a/components/camel-azure/src/generated/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurer.java b/components/camel-azure/src/generated/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurer.java index d4e7168..644f644 100644 --- a/components/camel-azure/src/generated/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurer.java +++ b/components/camel-azure/src/generated/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurer.java @@ -42,6 +42,10 @@ public class BlobServiceComponentConfigurer extends PropertyConfigurerSupport im case "closeStreamAfterWrite": getOrCreateConfiguration(target).setCloseStreamAfterWrite(property(camelContext, boolean.class, value)); return true; case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.azure.blob.BlobServiceConfiguration.class, value)); return true; case "credentials": getOrCreateConfiguration(target).setCredentials(property(camelContext, com.microsoft.azure.storage.StorageCredentials.class, value)); return true; + case "credentialsaccountkey": + case "credentialsAccountKey": getOrCreateConfiguration(target).setCredentialsAccountKey(property(camelContext, java.lang.String.class, value)); return true; + case "credentialsaccountname": + case "credentialsAccountName": getOrCreateConfiguration(target).setCredentialsAccountName(property(camelContext, java.lang.String.class, value)); return true; case "datalength": case "dataLength": getOrCreateConfiguration(target).setDataLength(property(camelContext, java.lang.Long.class, value)); return true; case "filedir": diff --git a/components/camel-azure/src/generated/java/org/apache/camel/component/azure/blob/BlobServiceEndpointConfigurer.java b/components/camel-azure/src/generated/java/org/apache/camel/component/azure/blob/BlobServiceEndpointConfigurer.java index 396e891..da97c8d 100644 --- a/components/camel-azure/src/generated/java/org/apache/camel/component/azure/blob/BlobServiceEndpointConfigurer.java +++ b/components/camel-azure/src/generated/java/org/apache/camel/component/azure/blob/BlobServiceEndpointConfigurer.java @@ -34,6 +34,10 @@ public class BlobServiceEndpointConfigurer extends PropertyConfigurerSupport imp case "closestreamafterwrite": case "closeStreamAfterWrite": target.getConfiguration().setCloseStreamAfterWrite(property(camelContext, boolean.class, value)); return true; case "credentials": target.getConfiguration().setCredentials(property(camelContext, com.microsoft.azure.storage.StorageCredentials.class, value)); return true; + case "credentialsaccountkey": + case "credentialsAccountKey": target.getConfiguration().setCredentialsAccountKey(property(camelContext, java.lang.String.class, value)); return true; + case "credentialsaccountname": + case "credentialsAccountName": target.getConfiguration().setCredentialsAccountName(property(camelContext, java.lang.String.class, value)); return true; case "datalength": case "dataLength": target.getConfiguration().setDataLength(property(camelContext, java.lang.Long.class, value)); return true; case "exceptionhandler": diff --git a/components/camel-azure/src/generated/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurer.java b/components/camel-azure/src/generated/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurer.java index 1ee4745..36ed4df 100644 --- a/components/camel-azure/src/generated/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurer.java +++ b/components/camel-azure/src/generated/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurer.java @@ -30,6 +30,10 @@ public class QueueServiceComponentConfigurer extends PropertyConfigurerSupport i case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.azure.queue.QueueServiceConfiguration.class, value)); return true; case "credentials": getOrCreateConfiguration(target).setCredentials(property(camelContext, com.microsoft.azure.storage.StorageCredentials.class, value)); return true; + case "credentialsaccountkey": + case "credentialsAccountKey": getOrCreateConfiguration(target).setCredentialsAccountKey(property(camelContext, java.lang.String.class, value)); return true; + case "credentialsaccountname": + case "credentialsAccountName": getOrCreateConfiguration(target).setCredentialsAccountName(property(camelContext, java.lang.String.class, value)); return true; case "lazystartproducer": case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; case "messagetimetolive": diff --git a/components/camel-azure/src/generated/java/org/apache/camel/component/azure/queue/QueueServiceEndpointConfigurer.java b/components/camel-azure/src/generated/java/org/apache/camel/component/azure/queue/QueueServiceEndpointConfigurer.java index 5c8242b..f4b78d1 100644 --- a/components/camel-azure/src/generated/java/org/apache/camel/component/azure/queue/QueueServiceEndpointConfigurer.java +++ b/components/camel-azure/src/generated/java/org/apache/camel/component/azure/queue/QueueServiceEndpointConfigurer.java @@ -22,6 +22,10 @@ public class QueueServiceEndpointConfigurer extends PropertyConfigurerSupport im case "bridgeerrorhandler": case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; case "credentials": target.getConfiguration().setCredentials(property(camelContext, com.microsoft.azure.storage.StorageCredentials.class, value)); return true; + case "credentialsaccountkey": + case "credentialsAccountKey": target.getConfiguration().setCredentialsAccountKey(property(camelContext, java.lang.String.class, value)); return true; + case "credentialsaccountname": + case "credentialsAccountName": target.getConfiguration().setCredentialsAccountName(property(camelContext, java.lang.String.class, value)); return true; case "exceptionhandler": case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true; case "exchangepattern": diff --git a/components/camel-azure/src/generated/resources/org/apache/camel/component/azure/blob/azure-blob.json b/components/camel-azure/src/generated/resources/org/apache/camel/component/azure/blob/azure-blob.json index 690e4b3..ff042b5 100644 --- a/components/camel-azure/src/generated/resources/org/apache/camel/component/azure/blob/azure-blob.json +++ b/components/camel-azure/src/generated/resources/org/apache/camel/component/azure/blob/azure-blob.json @@ -37,7 +37,9 @@ "streamWriteSize": { "kind": "property", "displayName": "Stream Write Size", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "configurationField": "configuration", "description": "Set the size of the buffer for writing block and page blocks" }, "useFlatListing": { "kind": "property", "displayName": "Use Flat Listing", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "true", "configurationClass": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "configurationField": "configuration", "description": "Specify if the flat or hierarchical blob listing should be used" }, "basicPropertyBinding": { "kind": "property", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" }, - "configuration": { "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "deprecated": false, "secret": false, "description": "The Blob Service configuration" } + "configuration": { "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "deprecated": false, "secret": false, "description": "The Blob Service configuration" }, + "credentialsAccountKey": { "kind": "property", "displayName": "Credentials Account Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "configurationField": "configuration", "description": "Set the storage account key used during authentication phase" }, + "credentialsAccountName": { "kind": "property", "displayName": "Credentials Account Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "configurationField": "configuration", "description": "Set the storage account name used during authentication phase" } }, "properties": { "containerOrBlobUri": { "kind": "path", "displayName": "Container Or Blob Uri", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "description": "Container or Blob compact Uri" }, @@ -61,6 +63,8 @@ "streamWriteSize": { "kind": "parameter", "displayName": "Stream Write Size", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "configurationField": "configuration", "description": "Set the size of the buffer for writing block and page blocks" }, "useFlatListing": { "kind": "parameter", "displayName": "Use Flat Listing", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "true", "configurationClass": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "configurationField": "configuration", "description": "Specify if the flat or hierarchical blob listing should be used" }, "basicPropertyBinding": { "kind": "parameter", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" }, - "synchronous": { "kind": "parameter", "displayName": "Synchronous", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "description": "Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported)." } + "synchronous": { "kind": "parameter", "displayName": "Synchronous", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "description": "Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported)." }, + "credentialsAccountKey": { "kind": "parameter", "displayName": "Credentials Account Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "configurationField": "configuration", "description": "Set the storage account key used during authentication phase" }, + "credentialsAccountName": { "kind": "parameter", "displayName": "Credentials Account Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.blob.BlobServiceConfiguration", "configurationField": "configuration", "description": "Set the storage account name used during authentication phase" } } } diff --git a/components/camel-azure/src/generated/resources/org/apache/camel/component/azure/queue/azure-queue.json b/components/camel-azure/src/generated/resources/org/apache/camel/component/azure/queue/azure-queue.json index 3e2876d..96bd49f 100644 --- a/components/camel-azure/src/generated/resources/org/apache/camel/component/azure/queue/azure-queue.json +++ b/components/camel-azure/src/generated/resources/org/apache/camel/component/azure/queue/azure-queue.json @@ -28,7 +28,9 @@ "operation": { "kind": "property", "displayName": "Operation", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.queue.QueueServiceOperations", "enum": [ "listQueues", "createQueue", "deleteQueue", "addMessage", "retrieveMessage", "peekMessage", "updateMessage", "deleteMessage" ], "deprecated": false, "secret": false, "defaultValue": "listQueues", "configurationClass": "org.apache.camel.component.azure.queue.Q [...] "queuePrefix": { "kind": "property", "displayName": "Queue Prefix", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.queue.QueueServiceConfiguration", "configurationField": "configuration", "description": "Set a prefix which can be used for listing the queues" }, "basicPropertyBinding": { "kind": "property", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" }, - "configuration": { "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.queue.QueueServiceConfiguration", "deprecated": false, "secret": false, "description": "The Queue Service configuration" } + "configuration": { "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.queue.QueueServiceConfiguration", "deprecated": false, "secret": false, "description": "The Queue Service configuration" }, + "credentialsAccountKey": { "kind": "property", "displayName": "Credentials Account Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.queue.QueueServiceConfiguration", "configurationField": "configuration", "description": "Set the storage account key used during authentication phase" }, + "credentialsAccountName": { "kind": "property", "displayName": "Credentials Account Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.queue.QueueServiceConfiguration", "configurationField": "configuration", "description": "Set the storage account name used during authentication phase" } }, "properties": { "containerAndQueueUri": { "kind": "path", "displayName": "Container And Queue Uri", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "description": "Container Queue compact Uri" }, @@ -43,6 +45,8 @@ "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.azure.queue.QueueServiceOperations", "enum": [ "listQueues", "createQueue", "deleteQueue", "addMessage", "retrieveMessage", "peekMessage", "updateMessage", "deleteMessage" ], "deprecated": false, "secret": false, "defaultValue": "listQueues", "configurationClass": "org.apache.camel.component.azure.queue. [...] "queuePrefix": { "kind": "parameter", "displayName": "Queue Prefix", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.azure.queue.QueueServiceConfiguration", "configurationField": "configuration", "description": "Set a prefix which can be used for listing the queues" }, "basicPropertyBinding": { "kind": "parameter", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" }, - "synchronous": { "kind": "parameter", "displayName": "Synchronous", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "description": "Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported)." } + "synchronous": { "kind": "parameter", "displayName": "Synchronous", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "description": "Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported)." }, + "credentialsAccountKey": { "kind": "parameter", "displayName": "Credentials Account Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.queue.QueueServiceConfiguration", "configurationField": "configuration", "description": "Set the storage account key used during authentication phase" }, + "credentialsAccountName": { "kind": "parameter", "displayName": "Credentials Account Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.azure.queue.QueueServiceConfiguration", "configurationField": "configuration", "description": "Set the storage account name used during authentication phase" } } } diff --git a/components/camel-azure/src/main/docs/azure-blob-component.adoc b/components/camel-azure/src/main/docs/azure-blob-component.adoc index bbdd31a..5d7c81c 100644 --- a/components/camel-azure/src/main/docs/azure-blob-component.adoc +++ b/components/camel-azure/src/main/docs/azure-blob-component.adoc @@ -39,7 +39,7 @@ to("file://blobdirectory"); // component options: START -The Azure Storage Blob Service component supports 19 options, which are listed below. +The Azure Storage Blob Service component supports 21 options, which are listed below. @@ -65,6 +65,8 @@ The Azure Storage Blob Service component supports 19 options, which are listed b | *useFlatListing* (producer) | Specify if the flat or hierarchical blob listing should be used | true | boolean | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *configuration* (advanced) | The Blob Service configuration | | BlobServiceConfiguration +| *credentialsAccountKey* (security) | Set the storage account key used during authentication phase | | String +| *credentialsAccountName* (security) | Set the storage account name used during authentication phase | | String |=== // component options: END @@ -97,7 +99,7 @@ with the following path and query parameters: |=== -=== Query Parameters (21 parameters): +=== Query Parameters (23 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -124,6 +126,8 @@ with the following path and query parameters: | *useFlatListing* (producer) | Specify if the flat or hierarchical blob listing should be used | true | boolean | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean +| *credentialsAccountKey* (security) | Set the storage account key used during authentication phase | | String +| *credentialsAccountName* (security) | Set the storage account name used during authentication phase | | String |=== // endpoint options: END diff --git a/components/camel-azure/src/main/docs/azure-queue-component.adoc b/components/camel-azure/src/main/docs/azure-queue-component.adoc index 483cead..e353310 100644 --- a/components/camel-azure/src/main/docs/azure-queue-component.adoc +++ b/components/camel-azure/src/main/docs/azure-queue-component.adoc @@ -39,7 +39,7 @@ to("file://queuedirectory"); // component options: START -The Azure Storage Queue Service component supports 10 options, which are listed below. +The Azure Storage Queue Service component supports 12 options, which are listed below. @@ -56,6 +56,8 @@ The Azure Storage Queue Service component supports 10 options, which are listed | *queuePrefix* (producer) | Set a prefix which can be used for listing the queues | | String | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *configuration* (advanced) | The Queue Service configuration | | QueueServiceConfiguration +| *credentialsAccountKey* (security) | Set the storage account key used during authentication phase | | String +| *credentialsAccountName* (security) | Set the storage account name used during authentication phase | | String |=== // component options: END @@ -88,7 +90,7 @@ with the following path and query parameters: |=== -=== Query Parameters (12 parameters): +=== Query Parameters (14 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -106,6 +108,8 @@ with the following path and query parameters: | *queuePrefix* (producer) | Set a prefix which can be used for listing the queues | | String | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean +| *credentialsAccountKey* (security) | Set the storage account key used during authentication phase | | String +| *credentialsAccountName* (security) | Set the storage account name used during authentication phase | | String |=== // endpoint options: END diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java index d9d449c..8918845 100644 --- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java +++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java @@ -28,9 +28,13 @@ import org.apache.camel.spi.Metadata; import org.apache.camel.spi.annotations.Component; import org.apache.camel.support.DefaultComponent; + @Component("azure-blob") public class BlobServiceComponent extends DefaultComponent { + public static final String MISSING_BLOB_CREDNTIALS_EXCEPTION_MESSAGE = + "One of azureBlobClient, credentials or both credentialsAccountName and credentialsAccountKey must be specified"; + @Metadata(label = "advanced") private BlobServiceConfiguration configuration; @@ -91,9 +95,12 @@ public class BlobServiceComponent extends DefaultComponent { private void checkCredentials(BlobServiceConfiguration cfg) { CloudBlob client = cfg.getAzureBlobClient(); - StorageCredentials creds = client == null ? cfg.getCredentials() : client.getServiceClient().getCredentials(); + + //if no azureBlobClient is provided fallback to credentials + StorageCredentials creds = client == null ? cfg.getAccountCredentials() + : client.getServiceClient().getCredentials(); if ((creds == null || creds instanceof StorageCredentialsAnonymous) && !cfg.isPublicForRead()) { - throw new IllegalArgumentException("Credentials must be specified."); + throw new IllegalArgumentException(MISSING_BLOB_CREDNTIALS_EXCEPTION_MESSAGE); } } diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java index 43726da..c4084e9 100644 --- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java +++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceUtil.java @@ -124,7 +124,7 @@ public final class BlobServiceUtil { public static CloudBlobContainer createBlobContainerClient(BlobServiceConfiguration cfg) throws Exception { URI uri = prepareStorageBlobUri(cfg, false); - StorageCredentials creds = getAccountCredentials(cfg); + StorageCredentials creds = cfg.getAccountCredentials(); return new CloudBlobContainer(uri, creds); } @@ -133,7 +133,7 @@ public final class BlobServiceUtil { CloudBlockBlob client = (CloudBlockBlob) getConfiguredClient(cfg); if (client == null) { URI uri = prepareStorageBlobUri(cfg); - StorageCredentials creds = getAccountCredentials(cfg); + StorageCredentials creds = cfg.getAccountCredentials(); client = new CloudBlockBlob(uri, creds); } return client; @@ -144,7 +144,7 @@ public final class BlobServiceUtil { CloudAppendBlob client = (CloudAppendBlob) getConfiguredClient(cfg); if (client == null) { URI uri = prepareStorageBlobUri(cfg); - StorageCredentials creds = getAccountCredentials(cfg); + StorageCredentials creds = cfg.getAccountCredentials(); client = new CloudAppendBlob(uri, creds); } return client; @@ -155,7 +155,7 @@ public final class BlobServiceUtil { CloudPageBlob client = (CloudPageBlob) getConfiguredClient(cfg); if (client == null) { URI uri = prepareStorageBlobUri(cfg); - StorageCredentials creds = getAccountCredentials(cfg); + StorageCredentials creds = cfg.getAccountCredentials(); client = new CloudPageBlob(uri, creds); } return client; @@ -182,10 +182,6 @@ public final class BlobServiceUtil { return client; } - public static StorageCredentials getAccountCredentials(BlobServiceConfiguration cfg) { - return cfg.getCredentials(); - } - public static void configureCloudBlobForRead(CloudBlob client, BlobServiceConfiguration cfg) { if (cfg.getStreamReadSize() > 0) { client.setStreamMinimumReadSizeInBytes(cfg.getStreamReadSize()); diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java index 4be7429..d3361b6 100644 --- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java +++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java @@ -17,12 +17,19 @@ package org.apache.camel.component.azure.common; import com.microsoft.azure.storage.StorageCredentials; +import com.microsoft.azure.storage.StorageCredentialsAccountAndKey; import org.apache.camel.spi.UriParam; public abstract class AbstractConfiguration implements Cloneable { @UriParam private StorageCredentials credentials; + + @UriParam(label = "security", secret = true) + private String credentialsAccountKey; + + @UriParam(label = "security", secret = true) + private String credentialsAccountName; private String accountName; @@ -48,4 +55,38 @@ public abstract class AbstractConfiguration implements Cloneable { public void setCredentials(StorageCredentials credentials) { this.credentials = credentials; } + + public String getCredentialsAccountKey() { + return credentialsAccountKey; + } + + /** + * Set the storage account key used during authentication phase + */ + public void setCredentialsAccountKey(String credentialsAccountKey) { + this.credentialsAccountKey = credentialsAccountKey; + } + + public String getCredentialsAccountName() { + return credentialsAccountName; + } + + /** + * Set the storage account name used during authentication phase + */ + public void setCredentialsAccountName(String credentialsAccountName) { + this.credentialsAccountName = credentialsAccountName; + } + + public StorageCredentials getAccountCredentials() { + StorageCredentials creds = credentials; + //if credentials is null, fallback to credentialsAccountKey and credentialsAccountName + if (creds == null) { + if (credentialsAccountKey != null && credentialsAccountName != null) { + creds = new StorageCredentialsAccountAndKey(credentialsAccountName, credentialsAccountKey); + } + } + return creds; + + } } diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceComponent.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceComponent.java index d0a2493..70972dc 100644 --- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceComponent.java +++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceComponent.java @@ -26,8 +26,12 @@ import org.apache.camel.spi.Metadata; import org.apache.camel.spi.annotations.Component; import org.apache.camel.support.DefaultComponent; + @Component("azure-queue") public class QueueServiceComponent extends DefaultComponent { + + public static final String MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE = + "One of azureQueueClient, credentials or both credentialsAccountName and credentialsAccountKey must be specified"; @Metadata(label = "advanced") private QueueServiceConfiguration configuration; @@ -76,9 +80,9 @@ public class QueueServiceComponent extends DefaultComponent { private void checkCredentials(QueueServiceConfiguration cfg) { CloudQueue client = cfg.getAzureQueueClient(); - StorageCredentials creds = client == null ? cfg.getCredentials() : client.getServiceClient().getCredentials(); + StorageCredentials creds = client == null ? cfg.getAccountCredentials() : client.getServiceClient().getCredentials(); if (creds == null) { - throw new IllegalArgumentException("Credentials must be specified."); + throw new IllegalArgumentException(MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE); } } diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceUtil.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceUtil.java index 7bde9d5..6032779 100644 --- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceUtil.java +++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceUtil.java @@ -45,7 +45,7 @@ public final class QueueServiceUtil { CloudQueue client = getConfiguredClient(cfg); if (client == null) { URI uri = prepareStorageQueueUri(cfg); - StorageCredentials creds = getAccountCredentials(cfg); + StorageCredentials creds = cfg.getAccountCredentials(); client = new CloudQueue(uri, creds); } return client; @@ -58,11 +58,7 @@ public final class QueueServiceUtil { } return client; } - - public static StorageCredentials getAccountCredentials(QueueServiceConfiguration cfg) { - return cfg.getCredentials(); - } - + public static void retrieveMessage(Exchange exchange, QueueServiceConfiguration cfg) throws Exception { CloudQueue client = createQueueClient(cfg); QueueServiceRequestOptions opts = getRequestOptions(exchange); diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationClientTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationClientTest.java index bed9cb9..948c283 100644 --- a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationClientTest.java +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationClientTest.java @@ -119,60 +119,14 @@ public class BlobServiceComponentConfigurationClientTest extends CamelTestSuppor assertTrue(endpoint.getConfiguration().isPublicForRead()); assertFalse(endpoint.getConfiguration().isUseFlatListing()); } - - @Test - public void testNoClientAndCredentials() throws Exception { - try { - context.getEndpoint("azure-blob://camelazure/container/blob"); - fail(); - } catch (Exception ex) { - assertEquals("Credentials must be specified.", ex.getCause().getMessage()); - } - } + @Test public void testNoClientAndCredentialsPublicForRead() throws Exception { BlobServiceEndpoint endpoint = - (BlobServiceEndpoint) context.getEndpoint("azure-blob://camelazure/container/blob?publicForRead=true"); + (BlobServiceEndpoint) context.getEndpoint("azure-blob://camelazure/container/blob?publicForRead=true"); assertTrue(endpoint.getConfiguration().isPublicForRead()); } - - @Test - public void testClientWithoutCredentials() throws Exception { - CloudBlockBlob client = - new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob")); - - doTestClientWithoutCredentials(client); - } - @Test - public void testClientWithoutAnonymousCredentials() throws Exception { - CloudBlockBlob client = - new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"), - StorageCredentialsAnonymous.ANONYMOUS); - - doTestClientWithoutCredentials(client); - } - @Test - public void testClientWithoutCredentialsPublicRead() throws Exception { - CloudBlockBlob client = - new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob")); - - context.getRegistry().bind("azureBlobClient", client); - - BlobServiceEndpoint endpoint = - (BlobServiceEndpoint) context.getEndpoint("azure-blob://camelazure/container/blob?publicForRead=true"); - assertTrue(endpoint.getConfiguration().isPublicForRead()); - } - private void doTestClientWithoutCredentials(CloudBlob client) throws Exception { - context.getRegistry().bind("azureBlobClient", client); - - try { - context.getEndpoint("azure-blob://camelazure/container/blob"); - fail(); - } catch (Exception ex) { - assertEquals("Credentials must be specified.", ex.getCause().getMessage()); - } - } - + @Test public void testNoBlobNameProducerWithOp() throws Exception { registerCredentials(); diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java index eb988ce..fbc5b77 100644 --- a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java @@ -119,38 +119,7 @@ public class BlobServiceComponentConfigurationTest extends CamelTestSupport { assertTrue(endpoint.getConfiguration().isPublicForRead()); assertFalse(endpoint.getConfiguration().isUseFlatListing()); } - - @Test - public void testNoClientAndCredentials() throws Exception { - try { - context.getEndpoint("azure-blob://camelazure/container/blob"); - fail(); - } catch (Exception ex) { - assertEquals("Credentials must be specified.", ex.getCause().getMessage()); - } - } - @Test - public void testNoClientAndCredentialsPublicForRead() throws Exception { - BlobServiceEndpoint endpoint = - (BlobServiceEndpoint) context.getEndpoint("azure-blob://camelazure/container/blob?publicForRead=true"); - assertTrue(endpoint.getConfiguration().isPublicForRead()); - } - - @Test - public void testClientWithoutCredentials() throws Exception { - CloudBlockBlob client = - new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob")); - - doTestClientWithoutCredentials(client); - } - @Test - public void testClientWithoutAnonymousCredentials() throws Exception { - CloudBlockBlob client = - new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"), - StorageCredentialsAnonymous.ANONYMOUS); - - doTestClientWithoutCredentials(client); - } + @Test public void testClientWithoutCredentialsPublicRead() throws Exception { CloudBlockBlob client = diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceUtilTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceUtilTest.java index 630cfb6..f163c7c 100644 --- a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceUtilTest.java +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceUtilTest.java @@ -18,19 +18,18 @@ package org.apache.camel.component.azure.blob; import java.net.URI; -import com.microsoft.azure.storage.StorageCredentials; -import com.microsoft.azure.storage.StorageCredentialsAccountAndKey; import com.microsoft.azure.storage.blob.CloudAppendBlob; import com.microsoft.azure.storage.blob.CloudBlockBlob; -import com.microsoft.azure.storage.core.Base64; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.registerCredentials; + public class BlobServiceUtilTest extends CamelTestSupport { @Test public void testPrepareUri() throws Exception { - registerCredentials(); + registerCredentials(context); BlobServiceEndpoint endpoint = (BlobServiceEndpoint) context.getEndpoint("azure-blob://camelazure/container/blob?credentials=#creds"); @@ -84,11 +83,4 @@ public class BlobServiceUtilTest extends CamelTestSupport { assertEquals("Invalid Client URI", ex.getMessage()); } } - - private void registerCredentials() { - StorageCredentials creds = new StorageCredentialsAccountAndKey("camelazure", - Base64.encode("key".getBytes())); - context.getRegistry().bind("creds", creds); - } - } diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/AzureCredentialsTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/AzureCredentialsTest.java new file mode 100644 index 0000000..9ee0d98 --- /dev/null +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/AzureCredentialsTest.java @@ -0,0 +1,224 @@ +/* + * 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.common; + +import com.microsoft.azure.storage.StorageCredentials; +import com.microsoft.azure.storage.StorageCredentialsAccountAndKey; +import com.microsoft.azure.storage.blob.CloudBlob; +import com.microsoft.azure.storage.blob.CloudBlockBlob; +import com.microsoft.azure.storage.core.Base64; +import com.microsoft.azure.storage.queue.CloudQueue; +import org.apache.camel.ResolveEndpointFailedException; +import org.apache.camel.component.azure.blob.BlobServiceConfiguration; +import org.apache.camel.component.azure.blob.BlobServiceEndpoint; +import org.apache.camel.component.azure.blob.BlobServiceUtil; +import org.apache.camel.component.azure.queue.QueueServiceConfiguration; +import org.apache.camel.component.azure.queue.QueueServiceEndpoint; +import org.apache.camel.component.azure.queue.QueueServiceUtil; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.newAccountKeyCredentials; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.registerCredentials; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.registerBlockBlobClient; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.registerQueueClient; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.ACCOUNT_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.CONTAINER_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.BLOB_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.QUEUE_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.INLINE_CREDENTIALS_ACCOUNT_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.INLINE_CREDENTIALS_ACCOUNT_KEY; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.CREDENTIALS_ACCOUNT_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.CREDENTIALS_ACCOUNT_KEY; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.CLIENT_CREDENTIALS_ACCOUNT_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.CLIENT_CREDENTIALS_ACCOUNT_KEY; + +public class AzureCredentialsTest extends CamelTestSupport { + + // URI with credentials + + private String inlineCredentialBlobURIEndpoint = new StringBuilder() + .append("azure-blob://") + .append(ACCOUNT_NAME) + .append("/").append(CONTAINER_NAME) + .append("/").append(BLOB_NAME) + .append("?") + .append("credentialsAccountName=").append(INLINE_CREDENTIALS_ACCOUNT_NAME) + .append("&credentialsAccountKey=RAW(").append(INLINE_CREDENTIALS_ACCOUNT_KEY).append(")") + .toString(); + + private String inlineCredentialBlobURIAndCredentialRefEndpoint = new StringBuilder() + .append("azure-blob://") + .append(ACCOUNT_NAME) + .append("/").append(CONTAINER_NAME) + .append("/").append(BLOB_NAME) + .append("?") + .append("credentialsAccountName=").append(INLINE_CREDENTIALS_ACCOUNT_NAME) + .append("&credentialsAccountKey=RAW(").append(INLINE_CREDENTIALS_ACCOUNT_KEY).append(")") + .append("&credentials=#creds") + .toString(); + + private String inlineCredentialBlobURIAndCredentialRefEndpointAndAzureClient = new StringBuilder() + .append("azure-blob://") + .append(ACCOUNT_NAME) + .append("/").append(CONTAINER_NAME) + .append("/").append(BLOB_NAME) + .append("?") + .append("credentialsAccountName=").append(INLINE_CREDENTIALS_ACCOUNT_NAME) + .append("&credentialsAccountKey=RAW(").append(INLINE_CREDENTIALS_ACCOUNT_KEY).append(")") + .append("&credentials=#creds") + .append("&azureBlobClient=#blobClient") + .toString(); + + private String inlineCredentialQueueURIEndpoint = new StringBuilder() + .append("azure-queue://") + .append(ACCOUNT_NAME) + .append("/").append(QUEUE_NAME) + .append("?") + .append("credentialsAccountName=").append(INLINE_CREDENTIALS_ACCOUNT_NAME) + .append("&credentialsAccountKey=RAW(").append(INLINE_CREDENTIALS_ACCOUNT_KEY).append(")") + .toString(); + + private String inlineCredentialQueueURIAndCredentialRefEndpoint = new StringBuilder() + .append("azure-queue://") + .append(ACCOUNT_NAME) + .append("/").append(QUEUE_NAME).append("?") + .append("credentialsAccountName=").append(INLINE_CREDENTIALS_ACCOUNT_NAME) + .append("&credentialsAccountKey=RAW(").append(INLINE_CREDENTIALS_ACCOUNT_KEY).append(")") + .append("&credentials=#creds") + .toString(); + + private String inlineCredentialQueueURIAndCredentialRefEndpointAndAzureClient = new StringBuilder() + .append("azure-queue://") + .append(ACCOUNT_NAME) + .append("/").append(QUEUE_NAME).append("?") + .append("credentialsAccountName=").append(INLINE_CREDENTIALS_ACCOUNT_NAME) + .append("&credentialsAccountKey=RAW(").append(INLINE_CREDENTIALS_ACCOUNT_KEY).append(")") + .append("&credentials=#creds") + .append("&azureQueueClient=#queueClient") + .toString(); + + // Tests + + //Blob Tests + + @Test + public void createBlobEndpointWithAccountCredentials() throws Exception { + executeBlobAssertions(inlineCredentialBlobURIEndpoint, INLINE_CREDENTIALS_ACCOUNT_NAME, INLINE_CREDENTIALS_ACCOUNT_KEY); + } + + @Test + public void createBlobEndpointWithAccountCredentialsAndCredentialsRef() throws Exception { + registerCredentials(context, CREDENTIALS_ACCOUNT_NAME, CREDENTIALS_ACCOUNT_KEY); + executeBlobAssertions(inlineCredentialBlobURIAndCredentialRefEndpoint, CREDENTIALS_ACCOUNT_NAME, CREDENTIALS_ACCOUNT_KEY); + } + + @Test + public void createBlobEndpointWithAccountCredentialsAndCredentialsRefAndAzureClient() throws Exception { + registerCredentials(context, CREDENTIALS_ACCOUNT_NAME, CREDENTIALS_ACCOUNT_KEY); + registerBlockBlobClient(context, CLIENT_CREDENTIALS_ACCOUNT_NAME, CLIENT_CREDENTIALS_ACCOUNT_KEY); + + BlobServiceEndpoint endpoint = (BlobServiceEndpoint) + context.getEndpoint(inlineCredentialBlobURIAndCredentialRefEndpointAndAzureClient); + CloudBlob client = context.getRegistry().lookupByNameAndType("blobClient", CloudBlockBlob.class); + executeBlobAccountCredentialsAssertion(client, endpoint.getConfiguration()); + executeBlobCredentialsAssertion(client, CLIENT_CREDENTIALS_ACCOUNT_NAME, CLIENT_CREDENTIALS_ACCOUNT_KEY); + } + + // Queue Tests + + @Test + public void createQueueEndpointWithAccountCredentials() throws Exception { + executeQueueAssertions(inlineCredentialQueueURIEndpoint, INLINE_CREDENTIALS_ACCOUNT_NAME, INLINE_CREDENTIALS_ACCOUNT_KEY); + } + + @Test + public void createQueueEndpointWithAccountCredentialsAndCredentialsRef() throws Exception { + registerCredentials(context, CREDENTIALS_ACCOUNT_NAME, CREDENTIALS_ACCOUNT_KEY); + executeQueueAssertions(inlineCredentialQueueURIAndCredentialRefEndpoint, CREDENTIALS_ACCOUNT_NAME, CREDENTIALS_ACCOUNT_KEY); + } + + @Test + public void createQueueEndpointWithAccountCredentialsAndCredentialsRefAndAzureClient() throws Exception { + registerCredentials(context, CREDENTIALS_ACCOUNT_NAME, CREDENTIALS_ACCOUNT_KEY); + registerQueueClient(context, CLIENT_CREDENTIALS_ACCOUNT_NAME, CLIENT_CREDENTIALS_ACCOUNT_KEY); + + QueueServiceEndpoint endpoint = (QueueServiceEndpoint) context.getEndpoint(inlineCredentialQueueURIAndCredentialRefEndpointAndAzureClient); + CloudQueue client = context.getRegistry().lookupByNameAndType("queueClient", CloudQueue.class); + executeQueueAccountCredentialsAssertion(client, endpoint.getConfiguration()); + executeQueueCredentialsAssertion(client, CLIENT_CREDENTIALS_ACCOUNT_NAME, CLIENT_CREDENTIALS_ACCOUNT_KEY); + } + + + private void executeQueueAssertions(String uriString, String expectedAccountName, String expectedAccountKey) throws Exception { + QueueServiceEndpoint endpoint = (QueueServiceEndpoint) context.getEndpoint(uriString); + CloudQueue queueClient = QueueServiceUtil.createQueueClient(endpoint.getConfiguration()); + executeQueueAccountCredentialsAssertion(queueClient, endpoint.getConfiguration()); + executeQueueCredentialsAssertion(queueClient, expectedAccountName, expectedAccountKey); + } + + private void executeQueueAccountCredentialsAssertion(CloudQueue client, QueueServiceConfiguration configuration) { + assertNotNull(client); + assertEquals(ACCOUNT_NAME, configuration.getAccountName()); + assertEquals(INLINE_CREDENTIALS_ACCOUNT_NAME, configuration.getCredentialsAccountName()); + assertEquals(INLINE_CREDENTIALS_ACCOUNT_KEY, configuration.getCredentialsAccountKey()); + } + + private void executeQueueCredentialsAssertion(CloudQueue client, String expectedAccountName, String expectedAccountKey) { + StorageCredentialsAccountAndKey credentials = + (StorageCredentialsAccountAndKey) client.getServiceClient().getCredentials(); + + assertNotNull(client.getServiceClient().getCredentials()); + assertEquals(expectedAccountName, credentials.getAccountName()); + assertEquals(expectedAccountKey, credentials.exportBase64EncodedKey()); + } + + private void executeBlobAssertions(String uriString, String expectedAccountName, String expectedAccountKey) throws Exception { + BlobServiceEndpoint endpoint = (BlobServiceEndpoint) context.getEndpoint(uriString); + + CloudBlob pageBlobClient = BlobServiceUtil.createPageBlobClient(endpoint.getConfiguration()); + executeBlobAccountCredentialsAssertion(pageBlobClient, endpoint.getConfiguration()); + executeBlobCredentialsAssertion(pageBlobClient, expectedAccountName, expectedAccountKey); + + CloudBlob blockBlobClient = BlobServiceUtil.createBlockBlobClient(endpoint.getConfiguration()); + executeBlobAccountCredentialsAssertion(blockBlobClient, endpoint.getConfiguration()); + executeBlobCredentialsAssertion(blockBlobClient, expectedAccountName, expectedAccountKey); + + CloudBlob appendBlobClient = BlobServiceUtil.createAppendBlobClient(endpoint.getConfiguration()); + executeBlobAccountCredentialsAssertion(appendBlobClient, endpoint.getConfiguration()); + executeBlobCredentialsAssertion(appendBlobClient, expectedAccountName, expectedAccountKey); + } + + private void executeBlobAccountCredentialsAssertion(CloudBlob client, BlobServiceConfiguration configuration) { + assertNotNull(client); + assertEquals(ACCOUNT_NAME, configuration.getAccountName()); + assertEquals(CONTAINER_NAME, configuration.getContainerName()); + assertEquals(BLOB_NAME, configuration.getBlobName()); + assertEquals(INLINE_CREDENTIALS_ACCOUNT_NAME, configuration.getCredentialsAccountName()); + assertEquals(INLINE_CREDENTIALS_ACCOUNT_KEY, configuration.getCredentialsAccountKey()); + } + + private void executeBlobCredentialsAssertion(CloudBlob client, String expectedAccountName, String expectedAccountKey) { + StorageCredentialsAccountAndKey credentials = (StorageCredentialsAccountAndKey) + client.getServiceClient().getCredentials(); + assertNotNull(client.getServiceClient().getCredentials()); + assertEquals(expectedAccountName, credentials.getAccountName()); + assertEquals(expectedAccountKey, credentials.exportBase64EncodedKey()); + } +} diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/AzureServiceCommonTestUtil.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/AzureServiceCommonTestUtil.java new file mode 100644 index 0000000..6ca38e8 --- /dev/null +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/AzureServiceCommonTestUtil.java @@ -0,0 +1,108 @@ +/* + * 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.common; + +import java.net.URI; + +import com.microsoft.azure.storage.StorageCredentials; +import com.microsoft.azure.storage.StorageCredentialsAccountAndKey; +import com.microsoft.azure.storage.blob.CloudBlockBlob; +import com.microsoft.azure.storage.core.Base64; +import com.microsoft.azure.storage.queue.CloudQueue; +import org.apache.camel.CamelContext; + + +public final class AzureServiceCommonTestUtil { + + public static final String ACCOUNT_NAME = "camelazure"; + public static final String CONTAINER_NAME = "container1"; + public static final String BLOB_NAME = "blobBlock"; + public static final String INLINE_CREDENTIALS_ACCOUNT_NAME = "xxxx"; + public static final String INLINE_CREDENTIALS_ACCOUNT_KEY = Base64.encode("yyyy".getBytes()); + public static final String CREDENTIALS_ACCOUNT_NAME = "aaaa"; + public static final String CREDENTIALS_ACCOUNT_KEY = Base64.encode("bbbb".getBytes()); + public static final String CLIENT_CREDENTIALS_ACCOUNT_NAME = "cccc"; + public static final String CLIENT_CREDENTIALS_ACCOUNT_KEY = Base64.encode("dddd".getBytes()); + public static final String QUEUE_NAME = "myQueue"; + + private static final String DEFAULT_ACCOUNT_NAME = "camelazure"; + private static final String DEFAULT_ACCOUNT_KEY = Base64.encode("camelazure".getBytes()); + + + private AzureServiceCommonTestUtil() { } + + // Credentials + + public static void registerCredentials(CamelContext context, String accountName, String accountKey) { + context.getRegistry().bind("creds", newAccountKeyCredentials(accountName, accountKey)); + } + + public static void registerCredentials(CamelContext context) { + context.getRegistry().bind("creds", newAccountKeyCredentials(DEFAULT_ACCOUNT_NAME, DEFAULT_ACCOUNT_KEY)); + } + + // BlobClient + + public static void registerBlockBlobClient(CamelContext context) throws Exception { + context.getRegistry().bind("blobClient", createBlockBlobClient()); + } + + public static void registerBlockBlobClient(CamelContext context, String accountName, String accountKey) throws Exception { + context.getRegistry().bind("blobClient", createBlockBlobClient(accountName, accountKey)); + } + + public static CloudBlockBlob createBlockBlobClient(String accountName, String accountKey) throws Exception { + URI uri = new URI("https://camelazure.blob.core.windows.net/container1/blobBlock"); + CloudBlockBlob client = new CloudBlockBlob(uri, newAccountKeyCredentials(accountName, accountKey)); + return client; + } + + public static CloudBlockBlob createBlockBlobClient() throws Exception { + return createBlockBlobClient(DEFAULT_ACCOUNT_NAME, DEFAULT_ACCOUNT_KEY); + } + + //Queue Client + + public static void registerQueueClient(CamelContext context, String accountName, String accountKey) throws Exception { + context.getRegistry().bind("queueClient", createQueueClient(accountName, accountKey)); + } + + public static void registerQueueClient(CamelContext context) throws Exception { + registerQueueClient(context, DEFAULT_ACCOUNT_NAME, DEFAULT_ACCOUNT_KEY); + } + + public static CloudQueue createQueueClient(String accountName, String accountKey) throws Exception { + URI uri = new URI("https://camelazure.queue.core.windows.net/testqueue/"); + CloudQueue client = new CloudQueue(uri, newAccountKeyCredentials(accountName, accountKey)); + return client; + } + + public static CloudQueue createQueueClient() throws Exception { + return createQueueClient(DEFAULT_ACCOUNT_NAME, DEFAULT_ACCOUNT_KEY); + } + + + // AccountCredentials + + public static StorageCredentials newAccountKeyCredentials(String accountName, String accountKey) { + return new StorageCredentialsAccountAndKey(accountName, accountKey); + } + + public static StorageCredentials newAccountKeyCredentials() { + return newAccountKeyCredentials(DEFAULT_ACCOUNT_NAME, DEFAULT_ACCOUNT_KEY); + } +} diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/MissingCredentialsTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/MissingCredentialsTest.java new file mode 100644 index 0000000..7038fd4 --- /dev/null +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/common/MissingCredentialsTest.java @@ -0,0 +1,176 @@ +/* + * 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.common; + +import java.net.URI; + +import com.microsoft.azure.storage.StorageCredentialsAnonymous; +import com.microsoft.azure.storage.blob.CloudBlockBlob; +import org.apache.camel.ResolveEndpointFailedException; +import org.apache.camel.component.azure.blob.BlobServiceEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.ACCOUNT_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.CONTAINER_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.BLOB_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.QUEUE_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.INLINE_CREDENTIALS_ACCOUNT_NAME; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.INLINE_CREDENTIALS_ACCOUNT_KEY; +import static org.apache.camel.component.azure.blob.BlobServiceComponent.MISSING_BLOB_CREDNTIALS_EXCEPTION_MESSAGE; +import static org.apache.camel.component.azure.queue.QueueServiceComponent.MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE; + + +public class MissingCredentialsTest extends CamelTestSupport { + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + //Missing credentials + private String missingCredentialsBlobUriEndoint = new StringBuilder() + .append("azure-blob://") + .append(ACCOUNT_NAME) + .append("/").append(CONTAINER_NAME) + .append("/").append(BLOB_NAME) + .toString(); + + private String missingCredentialsAccountNameBlobUriEndoint = new StringBuilder() + .append("azure-blob://") + .append(ACCOUNT_NAME) + .append("/").append(CONTAINER_NAME) + .append("/").append(BLOB_NAME) + .append("?") + .append("credentialsAccountKey=RAW(").append(INLINE_CREDENTIALS_ACCOUNT_KEY).append(")") + .toString(); + + private String missingCredentialsAccountKeyBlobUriEndoint = new StringBuilder() + .append("azure-blob://") + .append(ACCOUNT_NAME) + .append("/").append(CONTAINER_NAME) + .append("/").append(BLOB_NAME) + .append("?") + .append("credentialsAccountName=").append(INLINE_CREDENTIALS_ACCOUNT_NAME) + .toString(); + + private String missingCredentialsQueueUriEndoint = new StringBuilder() + .append("azure-queue://") + .append(ACCOUNT_NAME) + .append("/").append(QUEUE_NAME) + .toString(); + + private String missingCredentialsAccountNameQueueUriEndoint = new StringBuilder() + .append("azure-queue://") + .append(ACCOUNT_NAME) + .append("/").append(QUEUE_NAME) + .append("?") + .append("credentialsAccountKey=RAW(").append(INLINE_CREDENTIALS_ACCOUNT_KEY).append(")") + .toString(); + + private String missingCredentialsAccountKeyQueueUriEndoint = new StringBuilder() + .append("azure-queue://") + .append(ACCOUNT_NAME) + .append("/").append(QUEUE_NAME) + .append("?") + .append("credentialsAccountName=").append(INLINE_CREDENTIALS_ACCOUNT_NAME) + .toString(); + + + // Missing Credentials Blob Tests + @Test + public void createBlobEndpointWithoutCredentials() { + createEndpointWithoutCredentials(missingCredentialsBlobUriEndoint, MISSING_BLOB_CREDNTIALS_EXCEPTION_MESSAGE); + } + + @Test + public void testNoClientAndCredentialsPublicForRead() throws Exception { + BlobServiceEndpoint endpoint = + (BlobServiceEndpoint) context.getEndpoint("azure-blob://camelazure/container/blob?publicForRead=true"); + assertTrue(endpoint.getConfiguration().isPublicForRead()); + } + + @Test + public void createBlobEndpointWithoutCredentialsAccountName() { + createEndpointWithoutCredentials(missingCredentialsAccountNameBlobUriEndoint, MISSING_BLOB_CREDNTIALS_EXCEPTION_MESSAGE); + } + + @Test + public void createBlobEndpointWithoutCredentialsAccountKey() { + createEndpointWithoutCredentials(missingCredentialsAccountKeyBlobUriEndoint, MISSING_BLOB_CREDNTIALS_EXCEPTION_MESSAGE); + } + + // Missing Credentials Queue Tests + @Test + public void createQueueEndpointWithoutCredentials() { + createEndpointWithoutCredentials(missingCredentialsQueueUriEndoint, MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE); + } + + @Test + public void createQueueEndpointWithoutCredentialsAccountName() { + createEndpointWithoutCredentials(missingCredentialsAccountNameQueueUriEndoint, MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE); + } + + @Test + public void createQueueEndpointWithoutCredentialsAccountKey() { + createEndpointWithoutCredentials(missingCredentialsAccountKeyQueueUriEndoint, MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE); + } + + + // Client Tests + + @Test + public void testBlobClientWithoutCredentialsPublicRead() throws Exception { + CloudBlockBlob client = + new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob")); + + context.getRegistry().bind("azureBlobClient", client); + + BlobServiceEndpoint endpoint = + (BlobServiceEndpoint) context.getEndpoint("azure-blob://camelazure/container/blob?publicForRead=true"); + assertTrue(endpoint.getConfiguration().isPublicForRead()); + } + + @Test + public void testBlobClientWithoutAnonymousCredentials() throws Exception { + exceptionRule.expect(ResolveEndpointFailedException.class); + exceptionRule.expectMessage(MISSING_BLOB_CREDNTIALS_EXCEPTION_MESSAGE); + CloudBlockBlob client = + new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"), + StorageCredentialsAnonymous.ANONYMOUS); + context.getRegistry().bind("azureBlobClient", client); + context.getEndpoint("azure-blob://camelazure/container/blob"); + } + + @Test + public void testBlobClientWithoutCredentials() throws Exception { + exceptionRule.expect(ResolveEndpointFailedException.class); + exceptionRule.expectMessage(MISSING_BLOB_CREDNTIALS_EXCEPTION_MESSAGE); + CloudBlockBlob client = + new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob")); + context.getRegistry().bind("azureBlobClient", client); + context.getEndpoint("azure-blob://camelazure/container/blob"); + + } + + + private void createEndpointWithoutCredentials(String uri, String errorMessage) { + exceptionRule.expect(ResolveEndpointFailedException.class); + exceptionRule.expectMessage(errorMessage); + context.getEndpoint(uri); + } +} diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentClientConfigurationTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentClientConfigurationTest.java index ee64a3e..8ef0fdc 100644 --- a/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentClientConfigurationTest.java +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentClientConfigurationTest.java @@ -28,6 +28,8 @@ import org.apache.camel.Processor; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; +import static org.apache.camel.component.azure.queue.QueueServiceComponent.MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE; + public class QueueServiceComponentClientConfigurationTest extends CamelTestSupport { @Test @@ -103,16 +105,7 @@ public class QueueServiceComponentClientConfigurationTest extends CamelTestSuppo createConsumer(endpoint); } - - @Test - public void testNoCredentials() throws Exception { - try { - context.getEndpoint("azure-queue://camelazure/testqueue"); - fail(); - } catch (Exception ex) { - assertEquals("Credentials must be specified.", ex.getCause().getMessage()); - } - } + @Test public void testTooManyPathSegments() throws Exception { @@ -130,7 +123,7 @@ public class QueueServiceComponentClientConfigurationTest extends CamelTestSuppo context.getEndpoint("azure-queue://camelazure?operation=addMessage"); fail(); } catch (Exception ex) { - assertEquals("Credentials must be specified.", ex.getCause().getMessage()); + assertEquals(MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE, ex.getCause().getMessage()); } } diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurationTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurationTest.java index 4ce823a..8176972 100644 --- a/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurationTest.java +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurationTest.java @@ -28,6 +28,8 @@ import org.apache.camel.Processor; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; +import static org.apache.camel.component.azure.queue.QueueServiceComponent.MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE; + public class QueueServiceComponentConfigurationTest extends CamelTestSupport { @Test @@ -103,16 +105,7 @@ public class QueueServiceComponentConfigurationTest extends CamelTestSupport { createConsumer(endpoint); } - - @Test - public void testNoCredentials() throws Exception { - try { - context.getEndpoint("azure-queue://camelazure/testqueue"); - fail(); - } catch (Exception ex) { - assertEquals("Credentials must be specified.", ex.getCause().getMessage()); - } - } + @Test public void testTooManyPathSegments() throws Exception { @@ -130,7 +123,7 @@ public class QueueServiceComponentConfigurationTest extends CamelTestSupport { context.getEndpoint("azure-queue://camelazure?operation=addMessage"); fail(); } catch (Exception ex) { - assertEquals("Credentials must be specified.", ex.getCause().getMessage()); + assertEquals(MISSING_QUEUE_CREDNTIALS_EXCEPTION_MESSAGE, ex.getCause().getMessage()); } } diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceUtilTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceUtilTest.java index 516117c..52be8af 100644 --- a/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceUtilTest.java +++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceUtilTest.java @@ -18,18 +18,19 @@ package org.apache.camel.component.azure.queue; import java.net.URI; -import com.microsoft.azure.storage.StorageCredentials; -import com.microsoft.azure.storage.StorageCredentialsAccountAndKey; -import com.microsoft.azure.storage.core.Base64; import com.microsoft.azure.storage.queue.CloudQueue; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.newAccountKeyCredentials; +import static org.apache.camel.component.azure.common.AzureServiceCommonTestUtil.registerCredentials; + + public class QueueServiceUtilTest extends CamelTestSupport { @Test public void testPrepareUri() throws Exception { - registerCredentials(); + registerCredentials(context); QueueServiceEndpoint endpoint = (QueueServiceEndpoint) context.getEndpoint("azure-queue://camelazure/testqueue?credentials=#creds"); URI uri = QueueServiceUtil.prepareStorageQueueUri(endpoint.getConfiguration()); @@ -61,11 +62,4 @@ public class QueueServiceUtilTest extends CamelTestSupport { } } - private void registerCredentials() { - context.getRegistry().bind("creds", newAccountKeyCredentials()); - } - - private StorageCredentials newAccountKeyCredentials() { - return new StorageCredentialsAccountAndKey("camelazure", Base64.encode("key".getBytes())); - } } diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureBlobComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureBlobComponentBuilderFactory.java index 933a596..2f9161a 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureBlobComponentBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureBlobComponentBuilderFactory.java @@ -303,6 +303,30 @@ public interface AzureBlobComponentBuilderFactory { doSetProperty("configuration", configuration); return this; } + /** + * Set the storage account key used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default AzureBlobComponentBuilder credentialsAccountKey( + java.lang.String credentialsAccountKey) { + doSetProperty("credentialsAccountKey", credentialsAccountKey); + return this; + } + /** + * Set the storage account name used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default AzureBlobComponentBuilder credentialsAccountName( + java.lang.String credentialsAccountName) { + doSetProperty("credentialsAccountName", credentialsAccountName); + return this; + } } class AzureBlobComponentBuilderImpl @@ -346,6 +370,8 @@ public interface AzureBlobComponentBuilderFactory { case "useFlatListing": getOrCreateConfiguration((BlobServiceComponent) component).setUseFlatListing((boolean) value); return true; case "basicPropertyBinding": ((BlobServiceComponent) component).setBasicPropertyBinding((boolean) value); return true; case "configuration": ((BlobServiceComponent) component).setConfiguration((org.apache.camel.component.azure.blob.BlobServiceConfiguration) value); return true; + case "credentialsAccountKey": getOrCreateConfiguration((BlobServiceComponent) component).setCredentialsAccountKey((java.lang.String) value); return true; + case "credentialsAccountName": getOrCreateConfiguration((BlobServiceComponent) component).setCredentialsAccountName((java.lang.String) value); return true; default: return false; } } diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureQueueComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureQueueComponentBuilderFactory.java index 7df5017..a9dfa34 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureQueueComponentBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureQueueComponentBuilderFactory.java @@ -193,6 +193,30 @@ public interface AzureQueueComponentBuilderFactory { doSetProperty("configuration", configuration); return this; } + /** + * Set the storage account key used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default AzureQueueComponentBuilder credentialsAccountKey( + java.lang.String credentialsAccountKey) { + doSetProperty("credentialsAccountKey", credentialsAccountKey); + return this; + } + /** + * Set the storage account name used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default AzureQueueComponentBuilder credentialsAccountName( + java.lang.String credentialsAccountName) { + doSetProperty("credentialsAccountName", credentialsAccountName); + return this; + } } class AzureQueueComponentBuilderImpl @@ -227,6 +251,8 @@ public interface AzureQueueComponentBuilderFactory { case "queuePrefix": getOrCreateConfiguration((QueueServiceComponent) component).setQueuePrefix((java.lang.String) value); return true; case "basicPropertyBinding": ((QueueServiceComponent) component).setBasicPropertyBinding((boolean) value); return true; case "configuration": ((QueueServiceComponent) component).setConfiguration((org.apache.camel.component.azure.queue.QueueServiceConfiguration) value); return true; + case "credentialsAccountKey": getOrCreateConfiguration((QueueServiceComponent) component).setCredentialsAccountKey((java.lang.String) value); return true; + case "credentialsAccountName": getOrCreateConfiguration((QueueServiceComponent) component).setCredentialsAccountName((java.lang.String) value); return true; default: return false; } } diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BlobServiceEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BlobServiceEndpointBuilderFactory.java index 01892c4..8cfcba7 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BlobServiceEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BlobServiceEndpointBuilderFactory.java @@ -297,6 +297,30 @@ public interface BlobServiceEndpointBuilderFactory { doSetProperty("bridgeErrorHandler", bridgeErrorHandler); return this; } + /** + * Set the storage account key used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default BlobServiceEndpointConsumerBuilder credentialsAccountKey( + String credentialsAccountKey) { + doSetProperty("credentialsAccountKey", credentialsAccountKey); + return this; + } + /** + * Set the storage account name used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default BlobServiceEndpointConsumerBuilder credentialsAccountName( + String credentialsAccountName) { + doSetProperty("credentialsAccountName", credentialsAccountName); + return this; + } } /** @@ -832,6 +856,30 @@ public interface BlobServiceEndpointBuilderFactory { doSetProperty("useFlatListing", useFlatListing); return this; } + /** + * Set the storage account key used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default BlobServiceEndpointProducerBuilder credentialsAccountKey( + String credentialsAccountKey) { + doSetProperty("credentialsAccountKey", credentialsAccountKey); + return this; + } + /** + * Set the storage account name used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default BlobServiceEndpointProducerBuilder credentialsAccountName( + String credentialsAccountName) { + doSetProperty("credentialsAccountName", credentialsAccountName); + return this; + } } /** @@ -1121,6 +1169,30 @@ public interface BlobServiceEndpointBuilderFactory { doSetProperty("streamReadSize", streamReadSize); return this; } + /** + * Set the storage account key used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default BlobServiceEndpointBuilder credentialsAccountKey( + String credentialsAccountKey) { + doSetProperty("credentialsAccountKey", credentialsAccountKey); + return this; + } + /** + * Set the storage account name used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default BlobServiceEndpointBuilder credentialsAccountName( + String credentialsAccountName) { + doSetProperty("credentialsAccountName", credentialsAccountName); + return this; + } } /** diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/QueueServiceEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/QueueServiceEndpointBuilderFactory.java index 5dbad883..521afb0 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/QueueServiceEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/QueueServiceEndpointBuilderFactory.java @@ -133,6 +133,30 @@ public interface QueueServiceEndpointBuilderFactory { doSetProperty("bridgeErrorHandler", bridgeErrorHandler); return this; } + /** + * Set the storage account key used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default QueueServiceEndpointConsumerBuilder credentialsAccountKey( + String credentialsAccountKey) { + doSetProperty("credentialsAccountKey", credentialsAccountKey); + return this; + } + /** + * Set the storage account name used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default QueueServiceEndpointConsumerBuilder credentialsAccountName( + String credentialsAccountName) { + doSetProperty("credentialsAccountName", credentialsAccountName); + return this; + } } /** @@ -451,6 +475,30 @@ public interface QueueServiceEndpointBuilderFactory { doSetProperty("queuePrefix", queuePrefix); return this; } + /** + * Set the storage account key used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default QueueServiceEndpointProducerBuilder credentialsAccountKey( + String credentialsAccountKey) { + doSetProperty("credentialsAccountKey", credentialsAccountKey); + return this; + } + /** + * Set the storage account name used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default QueueServiceEndpointProducerBuilder credentialsAccountName( + String credentialsAccountName) { + doSetProperty("credentialsAccountName", credentialsAccountName); + return this; + } } /** @@ -581,6 +629,30 @@ public interface QueueServiceEndpointBuilderFactory { doSetProperty("credentials", credentials); return this; } + /** + * Set the storage account key used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default QueueServiceEndpointBuilder credentialsAccountKey( + String credentialsAccountKey) { + doSetProperty("credentialsAccountKey", credentialsAccountKey); + return this; + } + /** + * Set the storage account name used during authentication phase. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: security + */ + default QueueServiceEndpointBuilder credentialsAccountName( + String credentialsAccountName) { + doSetProperty("credentialsAccountName", credentialsAccountName); + return this; + } } /** diff --git a/docs/components/modules/ROOT/pages/azure-blob-component.adoc b/docs/components/modules/ROOT/pages/azure-blob-component.adoc index 536fe3e..7a63242 100644 --- a/docs/components/modules/ROOT/pages/azure-blob-component.adoc +++ b/docs/components/modules/ROOT/pages/azure-blob-component.adoc @@ -40,7 +40,7 @@ to("file://blobdirectory"); // component options: START -The Azure Storage Blob Service component supports 19 options, which are listed below. +The Azure Storage Blob Service component supports 21 options, which are listed below. @@ -66,6 +66,8 @@ The Azure Storage Blob Service component supports 19 options, which are listed b | *useFlatListing* (producer) | Specify if the flat or hierarchical blob listing should be used | true | boolean | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *configuration* (advanced) | The Blob Service configuration | | BlobServiceConfiguration +| *credentialsAccountKey* (security) | Set the storage account key used during authentication phase | | String +| *credentialsAccountName* (security) | Set the storage account name used during authentication phase | | String |=== // component options: END @@ -98,7 +100,7 @@ with the following path and query parameters: |=== -=== Query Parameters (21 parameters): +=== Query Parameters (23 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -125,6 +127,8 @@ with the following path and query parameters: | *useFlatListing* (producer) | Specify if the flat or hierarchical blob listing should be used | true | boolean | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean +| *credentialsAccountKey* (security) | Set the storage account key used during authentication phase | | String +| *credentialsAccountName* (security) | Set the storage account name used during authentication phase | | String |=== // endpoint options: END diff --git a/docs/components/modules/ROOT/pages/azure-queue-component.adoc b/docs/components/modules/ROOT/pages/azure-queue-component.adoc index 60130aa..498161d 100644 --- a/docs/components/modules/ROOT/pages/azure-queue-component.adoc +++ b/docs/components/modules/ROOT/pages/azure-queue-component.adoc @@ -40,7 +40,7 @@ to("file://queuedirectory"); // component options: START -The Azure Storage Queue Service component supports 10 options, which are listed below. +The Azure Storage Queue Service component supports 12 options, which are listed below. @@ -57,6 +57,8 @@ The Azure Storage Queue Service component supports 10 options, which are listed | *queuePrefix* (producer) | Set a prefix which can be used for listing the queues | | String | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *configuration* (advanced) | The Queue Service configuration | | QueueServiceConfiguration +| *credentialsAccountKey* (security) | Set the storage account key used during authentication phase | | String +| *credentialsAccountName* (security) | Set the storage account name used during authentication phase | | String |=== // component options: END @@ -89,7 +91,7 @@ with the following path and query parameters: |=== -=== Query Parameters (12 parameters): +=== Query Parameters (14 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -107,6 +109,8 @@ with the following path and query parameters: | *queuePrefix* (producer) | Set a prefix which can be used for listing the queues | | String | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean +| *credentialsAccountKey* (security) | Set the storage account key used during authentication phase | | String +| *credentialsAccountName* (security) | Set the storage account name used during authentication phase | | String |=== // endpoint options: END