Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -430,30 +430,16 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Url m_blobUrl;
/** @brief Http Pipeline */
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
/** @brief Customer provided encryption key. */
Azure::Nullable<EncryptionKey> m_customerProvidedKey;
/** @brief Encryption scope. */
Azure::Nullable<std::string> m_encryptionScope;
/** @brief Upload TransferValidationOptions */
Azure::Nullable<TransferValidationOptions> m_uploadValidationOptions;
/** @brief Download TransferValidationOptions */
Azure::Nullable<TransferValidationOptions> m_downloadValidationOptions;
/** @brief Client configuration */
_detail::BlobClientConfiguration m_clientConfiguration;

private:
explicit BlobClient(
Azure::Core::Url blobUrl,
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> pipeline,
Azure::Nullable<EncryptionKey> customerProvidedKey = Azure::Nullable<EncryptionKey>(),
Azure::Nullable<std::string> encryptionScope = Azure::Nullable<std::string>(),
Azure::Nullable<TransferValidationOptions> uploadValidationOptions
= Azure::Nullable<TransferValidationOptions>(),
Azure::Nullable<TransferValidationOptions> downloadValidationOptions
= Azure::Nullable<TransferValidationOptions>())
_detail::BlobClientConfiguration clientConfiguration = _detail::BlobClientConfiguration())
: m_blobUrl(std::move(blobUrl)), m_pipeline(std::move(pipeline)),
m_customerProvidedKey(std::move(customerProvidedKey)),
m_encryptionScope(std::move(encryptionScope)),
m_uploadValidationOptions(std::move(uploadValidationOptions)),
m_downloadValidationOptions(std::move(downloadValidationOptions))
m_clientConfiguration(std::move(clientConfiguration))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,7 @@ namespace Azure { namespace Storage { namespace Blobs {
private:
Azure::Core::Url m_blobContainerUrl;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
Azure::Nullable<EncryptionKey> m_customerProvidedKey;
Azure::Nullable<std::string> m_encryptionScope;
Azure::Nullable<TransferValidationOptions> m_uploadValidationOptions;
Azure::Nullable<TransferValidationOptions> m_downloadValidationOptions;
_detail::BlobClientConfiguration m_clientConfiguration;

std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_batchRequestPipeline;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_batchSubrequestPipeline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,31 @@ namespace Azure { namespace Storage { namespace Blobs {
StorageChecksumAlgorithm Algorithm = StorageChecksumAlgorithm::None;
};

namespace _detail {
struct BlobClientConfiguration
{
/**
* @brief Holds the customer provided key used when making requests.
*/
Azure::Nullable<EncryptionKey> CustomerProvidedKey;

/**
* @brief Holds the encryption scope used when making requests.
*/
Azure::Nullable<std::string> EncryptionScope;

/**
* @brief Upload TransferValidationOptions
*/
Azure::Nullable<TransferValidationOptions> UploadValidationOptions;

/**
* @brief Download TransferValidationOptions
*/
Azure::Nullable<TransferValidationOptions> DownloadValidationOptions;
};
} // namespace _detail

/**
* @brief Client options used to initialize all kinds of blob clients.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ namespace Azure { namespace Storage { namespace Blobs {
private:
Azure::Core::Url m_serviceUrl;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
Azure::Nullable<EncryptionKey> m_customerProvidedKey;
Azure::Nullable<std::string> m_encryptionScope;
Azure::Nullable<TransferValidationOptions> m_uploadValidationOptions;
Azure::Nullable<TransferValidationOptions> m_downloadValidationOptions;
_detail::BlobClientConfiguration m_clientConfiguration;

std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_batchRequestPipeline;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_batchSubrequestPipeline;
Expand Down
38 changes: 22 additions & 16 deletions sdk/storage/azure-storage-blobs/src/append_blob_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
if (m_customerProvidedKey.HasValue())
if (m_clientConfiguration.CustomerProvidedKey.HasValue())
{
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.Value().Algorithm.ToString();
protocolLayerOptions.EncryptionKey = m_clientConfiguration.CustomerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256
= m_clientConfiguration.CustomerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm
= m_clientConfiguration.CustomerProvidedKey.Value().Algorithm.ToString();
}
protocolLayerOptions.EncryptionScope = m_encryptionScope;
protocolLayerOptions.EncryptionScope = m_clientConfiguration.EncryptionScope;
if (options.ImmutabilityPolicy.HasValue())
{
protocolLayerOptions.ImmutabilityPolicyExpiry = options.ImmutabilityPolicy.Value().ExpiresOn;
Expand Down Expand Up @@ -150,13 +152,15 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
if (m_customerProvidedKey.HasValue())
if (m_clientConfiguration.CustomerProvidedKey.HasValue())
{
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.Value().Algorithm.ToString();
protocolLayerOptions.EncryptionKey = m_clientConfiguration.CustomerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256
= m_clientConfiguration.CustomerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm
= m_clientConfiguration.CustomerProvidedKey.Value().Algorithm.ToString();
}
protocolLayerOptions.EncryptionScope = m_encryptionScope;
protocolLayerOptions.EncryptionScope = m_clientConfiguration.EncryptionScope;
Nullable<Azure::Response<Models::AppendBlockResult>> responseNullable;
if (options.TransactionalContentHash.HasValue())
{
Expand All @@ -175,7 +179,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
Azure::Nullable<TransferValidationOptions> validationOptions
= options.ValidationOptions.HasValue() ? options.ValidationOptions
: m_uploadValidationOptions;
: m_clientConfiguration.UploadValidationOptions;
if (validationOptions.HasValue()
&& validationOptions.Value().Algorithm != StorageChecksumAlgorithm::None)
{
Expand Down Expand Up @@ -247,13 +251,15 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
if (m_customerProvidedKey.HasValue())
if (m_clientConfiguration.CustomerProvidedKey.HasValue())
{
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.Value().Algorithm.ToString();
protocolLayerOptions.EncryptionKey = m_clientConfiguration.CustomerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256
= m_clientConfiguration.CustomerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm
= m_clientConfiguration.CustomerProvidedKey.Value().Algorithm.ToString();
}
protocolLayerOptions.EncryptionScope = m_encryptionScope;
protocolLayerOptions.EncryptionScope = m_clientConfiguration.EncryptionScope;
if (!options.SourceAuthorization.empty())
{
protocolLayerOptions.CopySourceAuthorization = options.SourceAuthorization;
Expand Down
58 changes: 34 additions & 24 deletions sdk/storage/azure-storage-blobs/src/blob_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ namespace Azure { namespace Storage { namespace Blobs {
}

BlobClient::BlobClient(const std::string& blobUrl, const BlobClientOptions& options)
: m_blobUrl(blobUrl), m_customerProvidedKey(options.CustomerProvidedKey),
m_encryptionScope(options.EncryptionScope),
m_uploadValidationOptions(options.UploadValidationOptions),
m_downloadValidationOptions(options.DownloadValidationOptions)
: m_blobUrl(blobUrl)
{
m_clientConfiguration.CustomerProvidedKey = options.CustomerProvidedKey;
m_clientConfiguration.EncryptionScope = options.EncryptionScope;
m_clientConfiguration.UploadValidationOptions = options.UploadValidationOptions;
m_clientConfiguration.DownloadValidationOptions = options.DownloadValidationOptions;

_internal::BuildStoragePipelineOptions pipelineOptions;
pipelineOptions.PackageName = _internal::BlobServicePackageName;
pipelineOptions.PackageVersion = _detail::PackageVersion::ToString();
Expand Down Expand Up @@ -181,7 +183,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
Azure::Nullable<TransferValidationOptions> validationOptions
= options.ValidationOptions.HasValue() ? options.ValidationOptions
: m_downloadValidationOptions;
: m_clientConfiguration.DownloadValidationOptions;
if (validationOptions.HasValue()
&& validationOptions.Value().Algorithm != StorageChecksumAlgorithm::None)
{
Expand All @@ -203,11 +205,13 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.UserPrincipalName = includeUserPrincipalName;
}
}
if (m_customerProvidedKey.HasValue())
if (m_clientConfiguration.CustomerProvidedKey.HasValue())
{
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.Value().Algorithm.ToString();
protocolLayerOptions.EncryptionKey = m_clientConfiguration.CustomerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256
= m_clientConfiguration.CustomerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm
= m_clientConfiguration.CustomerProvidedKey.Value().Algorithm.ToString();
}

auto downloadResponse = _detail::BlobClient::Download(
Expand Down Expand Up @@ -591,11 +595,13 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.UserPrincipalName = includeUserPrincipalName;
}
}
if (m_customerProvidedKey.HasValue())
if (m_clientConfiguration.CustomerProvidedKey.HasValue())
{
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.Value().Algorithm.ToString();
protocolLayerOptions.EncryptionKey = m_clientConfiguration.CustomerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256
= m_clientConfiguration.CustomerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm
= m_clientConfiguration.CustomerProvidedKey.Value().Algorithm.ToString();
}
auto response = _detail::BlobClient::GetProperties(
*m_pipeline, m_blobUrl, protocolLayerOptions, _internal::WithReplicaStatus(context));
Expand Down Expand Up @@ -683,13 +689,15 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
if (m_customerProvidedKey.HasValue())
if (m_clientConfiguration.CustomerProvidedKey.HasValue())
{
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.Value().Algorithm.ToString();
protocolLayerOptions.EncryptionKey = m_clientConfiguration.CustomerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256
= m_clientConfiguration.CustomerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm
= m_clientConfiguration.CustomerProvidedKey.Value().Algorithm.ToString();
}
protocolLayerOptions.EncryptionScope = m_encryptionScope;
protocolLayerOptions.EncryptionScope = m_clientConfiguration.EncryptionScope;
return _detail::BlobClient::SetMetadata(*m_pipeline, m_blobUrl, protocolLayerOptions, context);
}

Expand Down Expand Up @@ -744,7 +752,7 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.ImmutabilityPolicyMode = options.ImmutabilityPolicy.Value().PolicyMode;
}
protocolLayerOptions.LegalHold = options.HasLegalHold;
protocolLayerOptions.EncryptionScope = m_encryptionScope;
protocolLayerOptions.EncryptionScope = m_clientConfiguration.EncryptionScope;
protocolLayerOptions.CopySourceTags = options.CopySourceTagsMode;
if (!options.SourceAuthorization.empty())
{
Expand Down Expand Up @@ -820,13 +828,15 @@ namespace Azure { namespace Storage { namespace Blobs {
protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
if (m_customerProvidedKey.HasValue())
if (m_clientConfiguration.CustomerProvidedKey.HasValue())
{
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256 = m_customerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm = m_customerProvidedKey.Value().Algorithm.ToString();
protocolLayerOptions.EncryptionKey = m_clientConfiguration.CustomerProvidedKey.Value().Key;
protocolLayerOptions.EncryptionKeySha256
= m_clientConfiguration.CustomerProvidedKey.Value().KeyHash;
protocolLayerOptions.EncryptionAlgorithm
= m_clientConfiguration.CustomerProvidedKey.Value().Algorithm.ToString();
}
protocolLayerOptions.EncryptionScope = m_encryptionScope;
protocolLayerOptions.EncryptionScope = m_clientConfiguration.EncryptionScope;
return _detail::BlobClient::CreateSnapshot(
*m_pipeline, m_blobUrl, protocolLayerOptions, context);
}
Expand Down
18 changes: 7 additions & 11 deletions sdk/storage/azure-storage-blobs/src/blob_container_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,11 +1319,13 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobContainerClient::BlobContainerClient(
const std::string& blobContainerUrl,
const BlobClientOptions& options)
: m_blobContainerUrl(blobContainerUrl), m_customerProvidedKey(options.CustomerProvidedKey),
m_encryptionScope(options.EncryptionScope),
m_uploadValidationOptions(options.UploadValidationOptions),
m_downloadValidationOptions(options.DownloadValidationOptions)
: m_blobContainerUrl(blobContainerUrl)
{
m_clientConfiguration.CustomerProvidedKey = options.CustomerProvidedKey;
m_clientConfiguration.EncryptionScope = options.EncryptionScope;
m_clientConfiguration.UploadValidationOptions = options.UploadValidationOptions;
m_clientConfiguration.DownloadValidationOptions = options.DownloadValidationOptions;

std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perRetryPolicies;
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perOperationPolicies;
perRetryPolicies.emplace_back(std::make_unique<_internal::StorageSwitchToSecondaryPolicy>(
Expand Down Expand Up @@ -1352,13 +1354,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
auto blobUrl = m_blobContainerUrl;
blobUrl.AppendPath(_internal::UrlEncodePath(blobName));
return BlobClient(
std::move(blobUrl),
m_pipeline,
m_customerProvidedKey,
m_encryptionScope,
m_uploadValidationOptions,
m_downloadValidationOptions);
return BlobClient(std::move(blobUrl), m_pipeline, m_clientConfiguration);
}

BlockBlobClient BlobContainerClient::GetBlockBlobClient(const std::string& blobName) const
Expand Down
15 changes: 7 additions & 8 deletions sdk/storage/azure-storage-blobs/src/blob_service_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobServiceClient::BlobServiceClient(
const std::string& serviceUrl,
const BlobClientOptions& options)
: m_serviceUrl(serviceUrl), m_customerProvidedKey(options.CustomerProvidedKey),
m_encryptionScope(options.EncryptionScope),
m_uploadValidationOptions(options.UploadValidationOptions),
m_downloadValidationOptions(options.DownloadValidationOptions)
: m_serviceUrl(serviceUrl)
{
m_clientConfiguration.CustomerProvidedKey = options.CustomerProvidedKey;
m_clientConfiguration.EncryptionScope = options.EncryptionScope;
m_clientConfiguration.UploadValidationOptions = options.UploadValidationOptions;
m_clientConfiguration.DownloadValidationOptions = options.DownloadValidationOptions;

std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perRetryPolicies;
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perOperationPolicies;
perRetryPolicies.emplace_back(std::make_unique<_internal::StorageSwitchToSecondaryPolicy>(
Expand Down Expand Up @@ -156,10 +158,7 @@ namespace Azure { namespace Storage { namespace Blobs {

BlobContainerClient blobContainerClient(blobContainerUrl.GetAbsoluteUrl());
blobContainerClient.m_pipeline = m_pipeline;
blobContainerClient.m_customerProvidedKey = m_customerProvidedKey;
blobContainerClient.m_encryptionScope = m_encryptionScope;
blobContainerClient.m_uploadValidationOptions = m_uploadValidationOptions;
blobContainerClient.m_downloadValidationOptions = m_downloadValidationOptions;
blobContainerClient.m_clientConfiguration = m_clientConfiguration;
blobContainerClient.m_batchRequestPipeline = m_batchRequestPipeline;
blobContainerClient.m_batchSubrequestPipeline = m_batchSubrequestPipeline;
return blobContainerClient;
Expand Down
Loading
Loading