コード例 #1
0
        /// <summary>
        /// Factory method to generate an authorized request URL using query params. (valid up to 15 minutes)
        /// </summary>
        /// <returns>The authorized request.</returns>
        /// <param name="client">StorageServiceClient</param>
        /// <param name="httpMethod">Http method.</param>
        public static StorageRequest CreateAuthorizedStorageRequest(StorageServiceClient client, Method method, string resourcePath = "", Dictionary <string, string> queryParams = null, Dictionary <string, string> headers = null, int contentLength = 0)
        {
//			AuthorizationHeaders authHeaders = new AuthorizationHeaders (client, method, resourcePath, queryParams, headers, contentLength);
//			string stringToSign = authHeaders.ToString ();
            string baseUrl    = client.PrimaryEndpoint();
            string requestUrl = UrlHelper.BuildQuery(baseUrl, queryParams, resourcePath);

            StorageRequest request = new StorageRequest(requestUrl, method);

//			string signature = Sign (client.Key, stringToSign);
//			string authorization = Authorization (client.Account, signature);
//
//			Debug.Log ("Auth request url:" + requestUrl + "\n\nauthorization: \"" + authorization + "\"\nx-ms-date: " + authHeaders.MSDate () + "\nstringToSign:'" + stringToSign + "'");
//
//			request.AddHeader ("Authorization", authorization);
//			request.AddHeader ("x-ms-date", authHeaders.MSDate ());
//			request.AddHeader ("x-ms-version", authHeaders.MSVersion ());
//
//			if (headers != null) {
//				request.AddHeaders (headers);
//			}

            request.AuthorizeRequest(client, method, resourcePath, queryParams, headers, contentLength);

            return(request);
        }
コード例 #2
0
        public AuthorizationHeaders(StorageServiceClient client, Method method, string resourcePath = "", Dictionary <string, string> queryParams = null, Dictionary <string, string> headers = null, int contentLength = 0)
        {
            string path = resourcePath;

            this.method = method.ToString();
            this.canonicalizedHeaders = new CanonicalizedHeaders(client.Version, headers);

            if (queryParams != null)
            {
                path = resourcePath + BuildQueryString(queryParams);
            }

            if (headers != null)
            {
                UpdateHeaderValues(headers);
            }

            if (contentLength > 0)
            {
                authHeaders ["Content-Length"] = contentLength.ToString();
            }

            // account followed by url encoded resource path, and query params
            this.canonicalizedResource = string.Format("/{0}/{1}", client.Account, path);
        }
コード例 #3
0
        /// <summary>
        /// Factory method to generate an authorized request URL using query params. (valid up to 15 minutes)
        /// </summary>
        /// <returns>The authorized request.</returns>
        /// <param name="client">StorageServiceClient</param>
        /// <param name="httpMethod">Http method.</param>
        public static StorageRequest CreateAuthorizedStorageRequest(StorageServiceClient client, Method method, string resourcePath = "", Dictionary <string, string> queryParams = null, Dictionary <string, string> headers = null, int contentLength = 0)
        {
            string         baseUrl    = client.PrimaryEndpoint();
            string         requestUrl = UrlHelper.BuildQuery(baseUrl, queryParams, resourcePath);
            StorageRequest request    = new StorageRequest(requestUrl, method);

            request.AuthorizeRequest(client, method, resourcePath, queryParams, headers, contentLength);
            return(request);
        }
コード例 #4
0
        public void AuthorizeRequest(StorageServiceClient client, Method method, string resourcePath = "", Dictionary <string, string> queryParams = null, Dictionary <string, string> headers = null, int contentLength = 0)
        {
            AuthorizationHeaders authHeaders = new AuthorizationHeaders(client, method, resourcePath, queryParams, headers, contentLength);
            string stringToSign  = authHeaders.ToString();
            string signature     = GetSignature(client.Key, stringToSign);
            string authorization = GetAuthorizationHeader(client.Account, signature);

            this.AddHeader("Authorization", authorization);
            this.AddHeader("x-ms-date", authHeaders.MSDate());
            this.AddHeader("x-ms-version", authHeaders.MSVersion());

            if (headers != null)
            {
                this.AddHeaders(headers);
            }

            Debug.Log("Authorized request url:" + this.request.url + "\n\nauthorization: \"" + authorization + "\"\nx-ms-date: " + authHeaders.MSDate() + "\nstringToSign:'" + stringToSign + "'");
        }
コード例 #5
0
 public BlobService(StorageServiceClient client)
 {
     this.client = client;
 }