private string BuildSignature(bool includeBlob, bool includeSnapshot, string containerName, string blobName, TestConstants constants) { var canonicalName = includeBlob ? $"/blob/{constants.Sas.Account}/{containerName}/{blobName}" : $"/blob/{constants.Sas.Account}/{containerName}"; var resource = Constants.Sas.Resource.Container; if (includeBlob && includeSnapshot) { resource = Constants.Sas.Resource.BlobSnapshot; } else if (includeBlob) { resource = Constants.Sas.Resource.Blob; } var stringToSign = String.Join("\n", Permissions, SasExtensions.FormatTimesForSasSigning(constants.Sas.StartTime), SasExtensions.FormatTimesForSasSigning(constants.Sas.ExpiryTime), canonicalName, constants.Sas.Identifier, constants.Sas.IPRange.ToString(), SasExtensions.ToProtocolString(constants.Sas.Protocol), SasQueryParameters.DefaultSasVersion, resource, includeSnapshot ? Snapshot : null, constants.Sas.CacheControl, constants.Sas.ContentDisposition, constants.Sas.ContentEncoding, constants.Sas.ContentLanguage, constants.Sas.ContentType); return(StorageSharedKeyCredentialInternals.ComputeSasSignature(constants.Sas.SharedKeyCredential, stringToSign)); }
private string BuildSignature(bool includeFilePath, bool includeVersion, TestConstants constants, string shareName, string filePath) { var canonicalName = "/file/" + constants.Sas.Account + "/" + shareName; if (includeFilePath) { canonicalName += "/" + filePath; } var stringToSign = string.Join("\n", Permissions, SasExtensions.FormatTimesForSasSigning(constants.Sas.StartTime), SasExtensions.FormatTimesForSasSigning(constants.Sas.ExpiryTime), canonicalName, constants.Sas.Identifier, constants.Sas.IPRange.ToString(), SasExtensions.ToProtocolString(constants.Sas.Protocol), includeVersion ? constants.Sas.Version : SasQueryParameters.DefaultSasVersion, constants.Sas.CacheControl, constants.Sas.ContentDisposition, constants.Sas.ContentEncoding, constants.Sas.ContentLanguage, constants.Sas.ContentType); return(StorageSharedKeyCredentialInternals.ComputeSasSignature(constants.Sas.SharedKeyCredential, stringToSign)); }
public void AccountSasPermission_Round_Trip() { AccountSasServices services = SasExtensions.ParseAccountServices("bfqt"); Assert.IsTrue(services.HasFlag(AccountSasServices.Blobs)); Assert.IsTrue(services.HasFlag(AccountSasServices.Files)); Assert.IsTrue(services.HasFlag(AccountSasServices.Queues)); Assert.IsTrue(services.HasFlag(AccountSasServices.Tables)); Assert.AreEqual(services.ToPermissionsString(), "bfqt"); }
private string BuildSignature(TestConstants constants, string queueName, bool includeVersion) { var stringToSign = string.Join("\n", Permissions, SasExtensions.FormatTimesForSasSigning(constants.Sas.StartTime), SasExtensions.FormatTimesForSasSigning(constants.Sas.ExpiryTime), "/queue/" + constants.Sas.Account + "/" + queueName, constants.Sas.Identifier, constants.Sas.IPRange.ToString(), SasExtensions.ToProtocolString(SasProtocol.Https), includeVersion ? constants.Sas.Version : SasQueryParameters.DefaultSasVersion); return(StorageSharedKeyCredentialInternals.ComputeSasSignature(constants.Sas.SharedKeyCredential, stringToSign)); }
private string BuildIdentitySignature(bool includeBlob, bool includeSnapshot, string containerName, string blobName, TestConstants constants) { var canonicalName = includeBlob ? $"/blob/{constants.Sas.Account}/{containerName}/{blobName}" : $"/blob/{constants.Sas.Account}/{containerName}"; var resource = Constants.Sas.Resource.Container; if (includeBlob && includeSnapshot) { resource = Constants.Sas.Resource.BlobSnapshot; } else if (includeBlob) { resource = Constants.Sas.Resource.Blob; } var stringToSign = String.Join("\n", Permissions, SasExtensions.FormatTimesForSasSigning(constants.Sas.StartTime), SasExtensions.FormatTimesForSasSigning(constants.Sas.ExpiryTime), canonicalName, constants.Sas.KeyObjectId, constants.Sas.KeyTenantId, SasExtensions.FormatTimesForSasSigning(constants.Sas.KeyStart), SasExtensions.FormatTimesForSasSigning(constants.Sas.KeyExpiry), constants.Sas.KeyService, constants.Sas.KeyVersion, null, null, null, constants.Sas.IPRange.ToString(), SasExtensions.ToProtocolString(constants.Sas.Protocol), SasQueryParametersInternals.DefaultSasVersionInternal, resource, includeSnapshot ? Snapshot : null, constants.Sas.EncryptionScope, constants.Sas.CacheControl, constants.Sas.ContentDisposition, constants.Sas.ContentEncoding, constants.Sas.ContentLanguage, constants.Sas.ContentType); return(ComputeHMACSHA256(constants.Sas.KeyValue, stringToSign)); }