/// <summary> /// Returns a shared access signature for the queue. /// </summary> /// <param name="policy">The access policy for the shared access signature.</param> /// <param name="accessPolicyIdentifier">A queue-level access policy.</param> /// <returns>A shared access signature.</returns> public string GetSharedAccessSignature(SharedAccessQueuePolicy policy, string accessPolicyIdentifier) { if (!this.ServiceClient.Credentials.IsSharedKey) { string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASWithoutAccountKey); throw new InvalidOperationException(errorMessage); } string resourceName = this.GetCanonicalName(); string signature = SharedAccessSignatureHelper.GetSharedAccessSignatureHashImpl( policy, accessPolicyIdentifier, resourceName, this.ServiceClient.Credentials); string accountKeyName = this.ServiceClient.Credentials.IsSharedKey ? this.ServiceClient.Credentials.KeyName : null; UriQueryBuilder builder = SharedAccessSignatureHelper.GetSharedAccessSignatureImpl( policy, accessPolicyIdentifier, signature, accountKeyName); return(builder.ToString()); }
/// <summary> /// Returns a shared access signature for the container. /// </summary> /// <param name="policy">The access policy for the shared access signature.</param> /// <param name="groupPolicyIdentifier">A container-level access policy.</param> /// <returns>A shared access signature.</returns> public string GetSharedAccessSignature(SharedAccessBlobPolicy policy, string groupPolicyIdentifier) { if (!this.ServiceClient.Credentials.IsSharedKey) { string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASWithoutAccountKey); throw new InvalidOperationException(errorMessage); } string resourceName = this.GetSharedAccessCanonicalName(); string signature = SharedAccessSignatureHelper.GetSharedAccessSignatureHashImpl(policy, groupPolicyIdentifier, resourceName, this.ServiceClient.Credentials); string accountKeyName = this.ServiceClient.Credentials.KeyName; // Future resource type changes from "c" => "container" UriQueryBuilder builder = SharedAccessSignatureHelper.GetSharedAccessSignatureImpl(policy, groupPolicyIdentifier, "c", signature, accountKeyName); return(builder.ToString()); }
/// <summary> /// Returns a shared access signature for the table. /// </summary> /// <param name="policy">The access policy for the shared access signature.</param> /// <param name="accessPolicyIdentifier">An access policy identifier.</param> /// <param name="startPartitionKey">The start partition key, or null.</param> /// <param name="startRowKey">The start row key, or null.</param> /// <param name="endPartitionKey">The end partition key, or null.</param> /// <param name="endRowKey">The end row key, or null.</param> /// <returns>A shared access signature, as a URI query string.</returns> /// <remarks>The query string returned includes the leading question mark.</remarks> /// <exception cref="InvalidOperationException">Thrown if the current credentials don't support creating a shared access signature.</exception> public string GetSharedAccessSignature( SharedAccessTablePolicy policy, string accessPolicyIdentifier, string startPartitionKey, string startRowKey, string endPartitionKey, string endRowKey) { if (!this.ServiceClient.Credentials.IsSharedKey) { string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.CannotCreateSASWithoutAccountKey); throw new InvalidOperationException(errorMessage); } string resourceName = this.GetCanonicalName(); StorageAccountKey accountKey = this.ServiceClient.Credentials.Key; string signature = SharedAccessSignatureHelper.GetSharedAccessSignatureHashImpl( policy, accessPolicyIdentifier, startPartitionKey, startRowKey, endPartitionKey, endRowKey, resourceName, accountKey.KeyValue); UriQueryBuilder builder = SharedAccessSignatureHelper.GetSharedAccessSignatureImpl( policy, this.Name, accessPolicyIdentifier, startPartitionKey, startRowKey, endPartitionKey, endRowKey, signature, accountKey.KeyName); return(builder.ToString()); }