rename SharedKeyCredential -> StorageSharedKeyCredential (#1025)

* rename SharedKeyCredential -> StorageSharedKeyCredential

* fix

* rename
This commit is contained in:
JinmingHu 2020-11-26 14:32:58 +08:00 committed by GitHub
parent be601f2cdd
commit 4de5bcff96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 60 additions and 62 deletions

View File

@ -53,7 +53,7 @@ namespace Azure { namespace Storage { namespace Blobs {
*/
explicit AppendBlobClient(
const std::string& blobUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options = BlobClientOptions());
/**

View File

@ -108,7 +108,7 @@ namespace Azure { namespace Storage { namespace Blobs {
*/
explicit BlobBatchClient(
const std::string& serviceUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options = BlobClientOptions());
/**

View File

@ -57,7 +57,7 @@ namespace Azure { namespace Storage { namespace Blobs {
*/
explicit BlobClient(
const std::string& blobUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options = BlobClientOptions());
/**

View File

@ -49,7 +49,7 @@ namespace Azure { namespace Storage { namespace Blobs {
*/
explicit BlobContainerClient(
const std::string& containerUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options = BlobClientOptions());
/**

View File

@ -279,13 +279,13 @@ namespace Azure { namespace Storage { namespace Blobs {
void SetPermissions(BlobSasPermissions permissions);
/**
* @brief Uses the SharedKeyCredential to sign this shared access signature, to produce
* @brief Uses the StorageSharedKeyCredential to sign this shared access signature, to produce
* the proper SAS query parameters for authentication requests.
*
* @param credential The storage account's shared key credential.
* @return The SAS query parameters used for authenticating requests.
*/
std::string GenerateSasToken(const SharedKeyCredential& credential);
std::string GenerateSasToken(const StorageSharedKeyCredential& credential);
/**
* @brief Uses an account's user delegation key to sign this shared access signature, to

View File

@ -43,7 +43,7 @@ namespace Azure { namespace Storage { namespace Blobs {
*/
explicit BlobServiceClient(
const std::string& serviceUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options = BlobClientOptions());
/**

View File

@ -63,7 +63,7 @@ namespace Azure { namespace Storage { namespace Blobs {
*/
explicit BlockBlobClient(
const std::string& blobUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options = BlobClientOptions());
/**

View File

@ -55,7 +55,7 @@ namespace Azure { namespace Storage { namespace Blobs {
*/
explicit PageBlobClient(
const std::string& blobUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options = BlobClientOptions());
/**

View File

@ -21,7 +21,7 @@ namespace Azure { namespace Storage { namespace Blobs {
AppendBlobClient::AppendBlobClient(
const std::string& blobUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options)
: BlobClient(blobUrl, std::move(credential), options)
{
@ -52,8 +52,7 @@ namespace Azure { namespace Storage { namespace Blobs {
else
{
newClient.m_blobUrl.AppendQueryParameter(
Storage::Details::HttpQuerySnapshot,
Storage::Details::UrlEncodeQueryParameter(snapshot));
Storage::Details::HttpQuerySnapshot, Storage::Details::UrlEncodeQueryParameter(snapshot));
}
return newClient;
}

View File

@ -85,7 +85,7 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobBatchClient::BlobBatchClient(
const std::string& serviceUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options)
: m_serviceUrl(serviceUrl)
{

View File

@ -42,7 +42,7 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobClient::BlobClient(
const std::string& blobUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options)
: BlobClient(blobUrl, options)
{

View File

@ -38,7 +38,7 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobContainerClient::BlobContainerClient(
const std::string& containerUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options)
: BlobContainerClient(containerUrl, options)
{

View File

@ -107,7 +107,7 @@ namespace Azure { namespace Storage { namespace Blobs {
}
}
std::string BlobSasBuilder::GenerateSasToken(const SharedKeyCredential& credential)
std::string BlobSasBuilder::GenerateSasToken(const StorageSharedKeyCredential& credential)
{
std::string canonicalName = "/blob/" + credential.AccountName + "/" + ContainerName;
if (Resource == BlobSasResource::Blob || Resource == BlobSasResource::BlobSnapshot

View File

@ -33,7 +33,7 @@ namespace Azure { namespace Storage { namespace Blobs {
BlobServiceClient::BlobServiceClient(
const std::string& serviceUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options)
: m_serviceUrl(serviceUrl)
{

View File

@ -24,7 +24,7 @@ namespace Azure { namespace Storage { namespace Blobs {
BlockBlobClient::BlockBlobClient(
const std::string& blobUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options)
: BlobClient(blobUrl, std::move(credential), options)
{
@ -55,8 +55,7 @@ namespace Azure { namespace Storage { namespace Blobs {
else
{
newClient.m_blobUrl.AppendQueryParameter(
Storage::Details::HttpQuerySnapshot,
Storage::Details::UrlEncodeQueryParameter(snapshot));
Storage::Details::HttpQuerySnapshot, Storage::Details::UrlEncodeQueryParameter(snapshot));
}
return newClient;
}

View File

@ -23,7 +23,7 @@ namespace Azure { namespace Storage { namespace Blobs {
PageBlobClient::PageBlobClient(
const std::string& blobUrl,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const BlobClientOptions& options)
: BlobClient(blobUrl, std::move(credential), options)
{
@ -54,8 +54,7 @@ namespace Azure { namespace Storage { namespace Blobs {
else
{
newClient.m_blobUrl.AppendQueryParameter(
Storage::Details::HttpQuerySnapshot,
Storage::Details::UrlEncodeQueryParameter(snapshot));
Storage::Details::HttpQuerySnapshot, Storage::Details::UrlEncodeQueryParameter(snapshot));
}
return newClient;
}

View File

@ -2,6 +2,8 @@
## 12.0.0-beta.6 (Unreleased)
* Rename `SharedKeyCredential` to `StorageSharedKeyCredential`.
* Rename `StorageSharedKeyCredential::UpdateAccountKey` to `StorageSharedKeyCredential::Update`.
## 12.0.0-beta.5 (2020-11-13)

View File

@ -249,7 +249,7 @@ namespace Azure { namespace Storage {
void SetPermissions(AccountSasPermissions permissions);
/**
* @brief Uses the SharedKeyCredential to sign this shared access signature, to produce
* @brief Uses the StorageSharedKeyCredential to sign this shared access signature, to produce
* the proper SAS query parameters for authentication requests.
*
* @param credential
@ -257,7 +257,7 @@ namespace Azure { namespace Storage {
* @return The SAS query parameters used for
* authenticating requests.
*/
std::string GenerateSasToken(const SharedKeyCredential& credential);
std::string GenerateSasToken(const StorageSharedKeyCredential& credential);
private:
std::string Permissions;

View File

@ -10,7 +10,7 @@ namespace Azure { namespace Storage {
class SharedKeyPolicy : public Core::Http::HttpPolicy {
public:
explicit SharedKeyPolicy(std::shared_ptr<SharedKeyCredential> credential)
explicit SharedKeyPolicy(std::shared_ptr<StorageSharedKeyCredential> credential)
: m_credential(std::move(credential))
{
}
@ -35,7 +35,7 @@ namespace Azure { namespace Storage {
private:
std::string GetSignature(const Core::Http::Request& request) const;
std::shared_ptr<SharedKeyCredential> m_credential;
std::shared_ptr<StorageSharedKeyCredential> m_credential;
};
}} // namespace Azure::Storage

View File

@ -26,19 +26,19 @@ namespace Azure { namespace Storage {
} // namespace Files
/**
* @brief A SharedKeyCredential is a credential backed by a storage account's name and one
* @brief A StorageSharedKeyCredential is a credential backed by a storage account's name and one
* of its access keys.
*/
class SharedKeyCredential {
class StorageSharedKeyCredential {
public:
/**
* @brief Initializes a new instance of the SharedKeyCredential.
* @brief Initializes a new instance of the StorageSharedKeyCredential.
*
* @param accountName Name of the storage account.
* @param accountKey Access key of the storage
* account.
*/
explicit SharedKeyCredential(std::string accountName, std::string accountKey)
explicit StorageSharedKeyCredential(std::string accountName, std::string accountKey)
: AccountName(std::move(accountName)), m_accountKey(std::move(accountKey))
{
}
@ -49,7 +49,7 @@ namespace Azure { namespace Storage {
*
* @param accountKey A storage account access key.
*/
void UpdateAccountKey(std::string accountKey)
void Update(std::string accountKey)
{
std::lock_guard<std::mutex> guard(m_mutex);
m_accountKey = std::move(accountKey);
@ -84,7 +84,7 @@ namespace Azure { namespace Storage {
Azure::Core::Http::Url FileServiceUrl;
Azure::Core::Http::Url QueueServiceUrl;
Azure::Core::Http::Url DataLakeServiceUrl;
std::shared_ptr<SharedKeyCredential> KeyCredential;
std::shared_ptr<StorageSharedKeyCredential> KeyCredential;
};
ConnectionStringParts ParseConnectionString(const std::string& connectionString);

View File

@ -57,7 +57,7 @@ namespace Azure { namespace Storage {
}
}
std::string AccountSasBuilder::GenerateSasToken(const SharedKeyCredential& credential)
std::string AccountSasBuilder::GenerateSasToken(const StorageSharedKeyCredential& credential)
{
std::string protocol;
if (Protocol == SasProtocol::HttpsAndHtttp)

View File

@ -90,7 +90,7 @@ namespace Azure { namespace Storage { namespace Details {
throw std::runtime_error("Cannot find account name in connection string");
}
connectionStringParts.KeyCredential
= std::make_shared<SharedKeyCredential>(accountName, accountKey);
= std::make_shared<StorageSharedKeyCredential>(accountName, accountKey);
}
std::string sas = getWithDefault(connectionStringMap, "SharedAccessSignature");

View File

@ -41,7 +41,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
*/
explicit DirectoryClient(
const std::string& directoryUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options = DataLakeClientOptions());
/**

View File

@ -42,7 +42,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
*/
explicit FileClient(
const std::string& fileUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options = DataLakeClientOptions());
/**

View File

@ -44,7 +44,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
*/
explicit FileSystemClient(
const std::string& fileSystemUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options = DataLakeClientOptions());
/**

View File

@ -42,7 +42,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
*/
explicit PathClient(
const std::string& pathUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options = DataLakeClientOptions());
/**

View File

@ -310,13 +310,13 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
void SetPermissions(DataLakeSasPermissions permissions);
/**
* @brief Uses the SharedKeyCredential to sign this shared access signature, to produce
* @brief Uses the StorageSharedKeyCredential to sign this shared access signature, to produce
* the proper SAS query parameters for authentication requests.
*
* @param credential The storage account's shared key credential.
* @return The SAS query parameters used for authenticating requests.
*/
std::string GenerateSasToken(const SharedKeyCredential& credential);
std::string GenerateSasToken(const StorageSharedKeyCredential& credential);
/**
* @brief Uses an account's user delegation key to sign this shared access signature, to

View File

@ -39,7 +39,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
*/
explicit DataLakeServiceClient(
const std::string& serviceUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options = DataLakeClientOptions());
/**

View File

@ -44,7 +44,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
DirectoryClient::DirectoryClient(
const std::string& directoryUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options)
: PathClient(directoryUri, credential, options)
{

View File

@ -121,7 +121,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
FileClient::FileClient(
const std::string& fileUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options)
: PathClient(fileUri, credential, options),
m_blockBlobClient(m_blobClient.AsBlockBlobClient())

View File

@ -60,7 +60,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
FileSystemClient::FileSystemClient(
const std::string& fileSystemUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options)
: m_dfsUri(Details::GetDfsUriFromUri(fileSystemUri)),
m_blobContainerClient(

View File

@ -105,7 +105,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
PathClient::PathClient(
const std::string& pathUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options)
: m_dfsUri(Details::GetDfsUriFromUri(pathUri)),
m_blobClient(Details::GetBlobUriFromUri(pathUri), credential, GetBlobClientOptions(options))

View File

@ -113,7 +113,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
}
}
std::string DataLakeSasBuilder::GenerateSasToken(const SharedKeyCredential& credential)
std::string DataLakeSasBuilder::GenerateSasToken(const StorageSharedKeyCredential& credential)
{
std::string canonicalName = "/blob/" + credential.AccountName + "/" + FileSystemName;
if (Resource == DataLakeSasResource::File)
@ -126,9 +126,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
std::string stringToSign = Permissions + "\n" + (StartsOn.HasValue() ? StartsOn.GetValue() : "")
+ "\n" + ExpiresOn + "\n" + canonicalName + "\n" + Identifier + "\n"
+ (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n"
+ Storage::Details::DefaultSasVersion + "\n" + resource + "\n" + "\n" + CacheControl
+ "\n" + ContentDisposition + "\n" + ContentEncoding + "\n" + ContentLanguage + "\n"
+ ContentType;
+ Storage::Details::DefaultSasVersion + "\n" + resource + "\n" + "\n" + CacheControl + "\n"
+ ContentDisposition + "\n" + ContentEncoding + "\n" + ContentLanguage + "\n" + ContentType;
std::string signature = Base64Encode(
Storage::Details::HmacSha256(stringToSign, Base64Decode(credential.GetAccountKey())));

View File

@ -71,7 +71,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
DataLakeServiceClient::DataLakeServiceClient(
const std::string& serviceUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const DataLakeClientOptions& options)
: m_dfsUri(Details::GetDfsUriFromUri(serviceUri)), m_blobServiceClient(
Details::GetBlobUriFromUri(serviceUri),

View File

@ -41,7 +41,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
*/
explicit ShareClient(
const std::string& shareUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options = ShareClientOptions());
/**

View File

@ -43,7 +43,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
*/
explicit DirectoryClient(
const std::string& shareDirectoryUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options = ShareClientOptions());
/**

View File

@ -42,7 +42,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
*/
explicit FileClient(
const std::string& shareFileUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options = ShareClientOptions());
/**

View File

@ -218,13 +218,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
void SetPermissions(ShareFileSasPermissions permissions);
/**
* @brief Uses the SharedKeyCredential to sign this shared access signature, to produce
* @brief Uses the StorageSharedKeyCredential to sign this shared access signature, to produce
* the proper SAS query parameters for authentication requests.
*
* @param credential The storage account's shared key credential.
* @return The SAS query parameters used for authenticating requests.
*/
std::string GenerateSasToken(const SharedKeyCredential& credential);
std::string GenerateSasToken(const StorageSharedKeyCredential& credential);
private:
std::string Permissions;

View File

@ -38,7 +38,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
*/
explicit ShareServiceClient(
const std::string& serviceUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options = ShareClientOptions());
/**

View File

@ -38,7 +38,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
ShareClient::ShareClient(
const std::string& shareUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options)
: m_shareUri(shareUri)
{

View File

@ -40,7 +40,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
DirectoryClient::DirectoryClient(
const std::string& shareDirectoryUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options)
: m_shareDirectoryUri(shareDirectoryUri)
{

View File

@ -42,7 +42,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
FileClient::FileClient(
const std::string& shareFileUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options)
: m_shareFileUri(shareFileUri)
{

View File

@ -74,7 +74,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}
}
std::string ShareSasBuilder::GenerateSasToken(const SharedKeyCredential& credential)
std::string ShareSasBuilder::GenerateSasToken(const StorageSharedKeyCredential& credential)
{
std::string canonicalName = "/file/" + credential.AccountName + "/" + ShareName;
if (Resource == ShareSasResource::File)

View File

@ -35,7 +35,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
ShareServiceClient::ShareServiceClient(
const std::string& serviceUri,
std::shared_ptr<SharedKeyCredential> credential,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options)
: m_serviceUri(serviceUri)
{