/// <summary> /// Use an account's <see cref="TableSharedKeyCredential"/> to sign this /// shared access signature values to produce the proper SAS query /// parameters for authenticating requests. /// </summary> /// <param name="sharedKeyCredential"> /// The storage account's <see cref="TableSharedKeyCredential"/>. /// </param> /// <returns> /// An instance of <see cref="TableSasQueryParameters"/>. /// </returns> public TableSasQueryParameters ToSasQueryParameters(TableSharedKeyCredential sharedKeyCredential) { sharedKeyCredential = sharedKeyCredential ?? throw Errors.ArgumentNull(nameof(sharedKeyCredential)); EnsureState(); var startTime = TableSasExtensions.FormatTimesForSasSigning(StartsOn); var expiryTime = TableSasExtensions.FormatTimesForSasSigning(ExpiresOn); // String to sign: http://msdn.microsoft.com/en-us/library/azure/dn140255.aspx var stringToSign = string.Join("\n", Permissions, startTime, expiryTime, GetCanonicalName(sharedKeyCredential.AccountName, TableName), Identifier, IPRange.ToString(), TableSasExtensions.ToProtocolString(Protocol), Version, PartitionKeyStart, RowKeyStart, PartitionKeyEnd, RowKeyEnd); var signature = TableSharedKeyCredential.ComputeSasSignature(sharedKeyCredential, stringToSign); var p = new TableSasQueryParameters( version: Version, resourceTypes: default,
/// <summary> /// Use an account's <see cref="TableSharedKeyCredential"/> to sign this /// shared access signature values to produce the proper SAS query /// parameters for authenticating requests. /// </summary> /// <param name="sharedKeyCredential"> /// The storage account's <see cref="TableSharedKeyCredential"/>. /// </param> /// <returns> /// An instance of <see cref="TableAccountSasQueryParameters"/>. /// </returns> public TableAccountSasQueryParameters ToSasQueryParameters(TableSharedKeyCredential sharedKeyCredential) { sharedKeyCredential = sharedKeyCredential ?? throw Errors.ArgumentNull(nameof(sharedKeyCredential)); EnsureState(); var startTime = TableSasExtensions.FormatTimesForSasSigning(StartsOn); var expiryTime = TableSasExtensions.FormatTimesForSasSigning(ExpiresOn); // String to sign: https://docs.microsoft.com/en-us/rest/api/storageservices/create-account-sas#constructing-the-signature-string var stringToSign = string.Join("\n", sharedKeyCredential.AccountName, Permissions, TableConstants.Sas.TableAccountServices.Table, ResourceTypes.ToPermissionsString(), startTime, expiryTime, IPRange.ToString(), Protocol.ToProtocolString(), Version, ""); var signature = TableSharedKeyCredential.ComputeSasSignature(sharedKeyCredential, stringToSign); var p = new TableAccountSasQueryParameters( version: Version, resourceTypes: ResourceTypes, protocol: Protocol, startsOn: StartsOn, expiresOn: ExpiresOn, ipRange: IPRange, identifier: Identifier, resource: null, permissions: Permissions, signature: signature); return(p); }