コード例 #1
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);
        }
コード例 #2
0
        public static StorageRequest GetAuthorizedStorageRequestAssetBundle(StorageServiceClient client, string resourcePath = "", Dictionary <string, string> queryParams = null, Dictionary <string, string> headers = null, int contentLength = 0)
        {
            string         requestUrl = RequestUrl(client, queryParams, resourcePath);
            StorageRequest request    = new StorageRequest(UnityWebRequest.GetAssetBundle(requestUrl));

            request.AuthorizeRequest(client, Method.GET, resourcePath, queryParams, headers, contentLength);
            return(request);
        }
コード例 #3
0
        public static StorageRequest GetAuthorizedStorageRequestAudioClip(StorageServiceClient client, string resourcePath = "", Dictionary <string, string> queryParams = null, Dictionary <string, string> headers = null, int contentLength = 0, AudioType audioType = AudioType.WAV)
        {
            string         requestUrl = RequestUrl(client, queryParams, resourcePath);
            StorageRequest request    = new StorageRequest(UnityWebRequestMultimedia.GetAudioClip(requestUrl, audioType));

            request.AuthorizeRequest(client, Method.GET, resourcePath, queryParams, headers, contentLength);
            return(request);
        }
コード例 #4
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         requestUrl = RequestUrl(client, queryParams, resourcePath);
            StorageRequest request    = new StorageRequest(requestUrl, method);

            request.AuthorizeRequest(client, method, resourcePath, queryParams, headers, contentLength);
            return(request);
        }
コード例 #5
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);
        }
コード例 #6
0
 // Use this for initialization
 void Awake()
 {
     if (string.IsNullOrEmpty(azureAccount) ||
         string.IsNullOrEmpty(azureAppKey))
     {
         Debug.LogError("Azure account and key required");
         return;
     }
     // setup blob service
     client  = new StorageServiceClient(azureAccount, azureAppKey);
     Service = new BlobService(client);
     ready   = true;
 }
コード例 #7
0
ファイル: Auth.cs プロジェクト: waleedzaf94/FYP
        public static StorageRequest CreateAuthorizedStorageRequest(StorageServiceClient client, Method method, byte[] data, string resourcePath = "", Dictionary <string, string> queryParams = null, Dictionary <string, string> headers = null, int contentLength = 0)
        {
            if (data == null)
            {
                throw new ArgumentNullException();
            }

            string         requestUrl = RequestUrl(client, queryParams, resourcePath);
            StorageRequest request    = new StorageRequest(requestUrl, method, data);

            request.AuthorizeRequest(client, method, resourcePath, queryParams, headers, contentLength);
            return(request);
        }
コード例 #8
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 + "'");
        }
コード例 #9
0
        private static string RequestUrl(StorageServiceClient client, Dictionary <string, string> queryParams = null, string resourcePath = "")
        {
            string baseUrl = client.PrimaryEndpoint();

            return(UrlHelper.BuildQuery(baseUrl, queryParams, resourcePath));
        }
コード例 #10
0
 public static StorageRequest GetAuthorizedStorageRequest(StorageServiceClient client, string resourcePath = "", Dictionary <string, string> queryParams = null, Dictionary <string, string> headers = null, int contentLength = 0)
 {
     return(CreateAuthorizedStorageRequest(client, Method.GET, resourcePath, queryParams, headers, contentLength));
 }
コード例 #11
0
 public BlobService(StorageServiceClient client)
 {
     this.client = client;
 }