public string GetSharedAccessSignature(SharedAccessAccountPolicy policy)
        {
            if (!Credentials.IsSharedKey)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Cannot create Shared Access Signature unless Account Key credentials are used."));
            }
            string hash = SharedAccessSignatureHelper.GetHash(policy, Credentials.AccountName, "2018-03-28", Credentials.Key);

            return(SharedAccessSignatureHelper.GetSignature(policy, hash, Credentials.KeyName, "2018-03-28").ToString());
        }
Exemple #2
0
        public string GetSharedAccessSignature(SharedAccessTablePolicy policy, string accessPolicyIdentifier, string startPartitionKey, string startRowKey, string endPartitionKey, string endRowKey, SharedAccessProtocol?protocols, IPAddressOrRange ipAddressOrRange)
        {
            if (!ServiceClient.Credentials.IsSharedKey)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Cannot create Shared Access Signature unless Account Key credentials are used."));
            }
            string             canonicalName = GetCanonicalName();
            StorageCredentials credentials   = ServiceClient.Credentials;
            string             hash          = SharedAccessSignatureHelper.GetHash(policy, accessPolicyIdentifier, startPartitionKey, startRowKey, endPartitionKey, endRowKey, canonicalName, "2018-03-28", protocols, ipAddressOrRange, credentials.Key);

            return(SharedAccessSignatureHelper.GetSignature(policy, Name, accessPolicyIdentifier, startPartitionKey, startRowKey, endPartitionKey, endRowKey, hash, credentials.KeyName, "2018-03-28", protocols, ipAddressOrRange).ToString());
        }
Exemple #3
0
        private static Uri ParseTableQueryAndVerify(Uri address, out StorageCredentials parsedCredentials)
        {
            parsedCredentials = null;
            if (address == null)
            {
                return(null);
            }
            if (!address.IsAbsoluteUri)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Address '{0}' is a relative address. Only absolute addresses are permitted.", new object[1]
                {
                    address.ToString()
                }), "address");
            }
            IDictionary <string, string> queryParameters = HttpWebUtility.ParseQueryString(address.Query);

            parsedCredentials = SharedAccessSignatureHelper.ParseQuery(queryParameters);
            return(new Uri(address.GetComponents(UriComponents.Scheme | UriComponents.Host | UriComponents.Port | UriComponents.Path, UriFormat.UriEscaped)));
        }