예제 #1
0
 /// <summary>
 /// Create a new AzureCommands object with default settings
 /// </summary>
 /// <param name="account">The account is generally the first part of the Endpoint.</param>
 /// <param name="endPoint">The Endpoint for Azure Table Storage as defined for your account</param>
 /// <param name="sharedKey">The SharedKey for access</param>
 /// <param name="keyType">Shared</param>
 public AzureBlobStorage(string account, string endPoint, string sharedKey, string keyType)
 {
     client.UserAgent = UserAgent;
       pAuth = new Authentication(account, string.Format(EndpointFormat, account), sharedKey);
       ad.auth = pAuth;
       client.UserAgent = UserAgent;
 }
예제 #2
0
 public ATSSagaProcessor(string account, string endPoint, string sharedKey, string keyType)
 {
     pAuth = new Authentication(account, "", sharedKey);
        ad.auth = pAuth;
        ats.auth = pAuth;
        aqs.auth = pAuth;
        abs.auth = pAuth;
 }
예제 #3
0
        /// <summary>
        /// Create a new AzureCommands object with default settings
        /// </summary>
        /// <param name="account">The account is generally the first part of the Endpoint.</param>
        /// <param name="endPoint">The Endpoint for Azure Table Storage as defined for your account</param>
        /// <param name="sharedKey">The SharedKey for access</param>
        /// <param name="keyType">Shared</param>
        public AzureQueueStorage(string account, string endPoint, string sharedKey, string keyType)
        {
            pAuth = new Authentication(account, string.Format(EndpointFormat, account), sharedKey);

              ad = new azureDirect(pAuth);
        }
예제 #4
0
        private void ProcessMultiPartForStatus(Authentication auth, string MultipartResults, string containerName, string partitionKey, string rowKey, ref int processedCt, ref int ErrorCt, string successString)
        {
            //string results = string.Empty;
               string[] resultSet = null;
               string location = string.Empty;
               string resultStatus = string.Empty;
               StringBuilder sbResultsForStorage = new StringBuilder();
               resultSet = MultipartResults.Split("\n".ToCharArray());

               location = string.Empty;
               resultStatus = string.Empty;
               foreach (string result in resultSet)
               {

            if (result.StartsWith("HTTP/1.1"))
            {
             resultStatus = result.Substring(8).Replace("\r","");
             if (resultStatus.ToLower().Trim() != successString.ToLower().Trim())
              ErrorCt++;
             location = string.Empty;
             processedCt++;
            }
            if (result.StartsWith("Location:"))
             sbResultsForStorage.AppendFormat("{0}: {1}\r\n", resultStatus.Replace("\r", ""), result.Substring(result.IndexOf(":") + 1).Replace("\r", ""));
               }
               AzureTableStorage ats = new AzureTableStorage(auth);

              azureResults ar= ats.Entities(cmdType.post, containerName, partitionKey, rowKey, string.Format(statusUpdateTEmplate, partitionKey, rowKey, sbResultsForStorage.ToString()), "", "");
        }
예제 #5
0
 /// <summary>
 /// Create a new AzureTableStorage object and populate the Authentication information
 /// </summary>
 /// <param name="pAuth">takes an Azure Authentication object</param>
 public AzureTableStorage(Authentication pAuth)
 {
     auth = pAuth;
 }
예제 #6
0
 /// <summary>
 /// Create a new AzureTableStorage object and populate the Authentication information
 /// </summary>
 /// <param name="account">The account is generally the first part of the Endpoint.</param>
 /// <param name="endPoint">The Endpoint for Azure Table Storage as defined for your account</param>
 /// <param name="sharedKey">The SharedKey for access</param>
 /// <param name="keyType">Shared</param>
 public AzureTableStorage(string account, string endPoint, string sharedKey, string keyType)
 {
     pAuth  = new Authentication(account, string.Format(EndpointFormat, account), sharedKey);
        ad.auth = pAuth;
 }
예제 #7
0
        public string CreateSharedKeyAuthLite(string method, string resource, string contentMD5, DateTime requestDate, string contentType, Authentication auth)
        {
            string rtn = string.Empty;
               string fmtHeader = "{0} {1}:{2}";
               string fmtStringToSign = "{0}\n{1}\n{2}\n{3:R}\n{4}";

               string authValue = string.Format(fmtStringToSign, method, contentMD5, contentType, requestDate, resource);
               string sigValue = h.MacSha(authValue, Convert.FromBase64String(auth.SharedKey));
               rtn = string.Format(fmtHeader, auth.KeyType, auth.Account, sigValue);

               return rtn;
        }
예제 #8
0
        public string CreateSharedKeyAuth(string method, string resource, string contentMD5, DateTime requestDate, HttpClient client, string contentType, Authentication auth)
        {
            Hashtable ht = new Hashtable();
               StringBuilder sbHdrs = new StringBuilder();
               StringBuilder sbHeader = new StringBuilder();
               string rtn = string.Empty;
               //string fmtStringToSign = "{0}\n{1}\n{2}\n{3:R}\n{4}{5}";

               //string hdr = CanonicalizeHeaders(client.RequestHeaders);
               //string authValue = string.Format(fmtStringToSign, method, contentMD5, contentType, "", hdr, resource);
             // support for 2009-09-09 version
               string contentEncoding = string.Empty;
               string contentLanguage = string.Empty;
               string dateForSigning = string.Empty;
               string ifModifiedSince = string.Empty;// client.IfModifiedSince.ToString();
               string ifMatch = string.Empty;
               string ifNoneMatch = string.Empty;
               string ifUnmodifiedSince = string.Empty;
               string rangeForSigning = string.Empty;
               string clientContentLength = string.Empty;
               string clientContentType = string.Empty;

               if (client.RequestHeaders["if-match"] != null)// && client.Headers["if-match"] != "*")
             ifMatch = client.RequestHeaders["if-match"].ToString();
               if (client.RequestHeaders["if-none-match"] != null)
             ifNoneMatch = client.RequestHeaders["if-none-match"].ToString();
               if (client.RequestHeaders["if-unmodified-since"] != null)
             ifUnmodifiedSince = client.RequestHeaders["if-unmodified-since"].ToString();
               //if (client.ResponseLength> 0 || method != "GET")
               //  clientContentLength = client.ResponseLength.ToString();

               //if (client.ContentType != null)
               //  clientContentType = client.ContentType.ToString();

               //string fmtStringToSign = "{0}\n{1}\n{2}\n{3:R}\n{4}{5}";
               string fmtStringToSign = "{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n{7}\n{8}\n{9}\n{10}\n{11}\n{12}{13}";
               string hdrs = CanonicalizeHeaders(client.RequestHeaders);
               //string authValue = string.Format(fmtStringToSign, method, contentMD5, client.ContentType, "", hdrs, resource);
               string authValue = string.Format(fmtStringToSign, method, contentEncoding,contentLanguage,clientContentLength, contentMD5, clientContentType,
             dateForSigning, ifModifiedSince, ifMatch,ifNoneMatch,ifUnmodifiedSince,rangeForSigning, hdrs, resource);
               byte[] signatureByteForm = System.Text.Encoding.UTF8.GetBytes(authValue);

               System.Security.Cryptography.HMACSHA256 hasher = new System.Security.Cryptography.HMACSHA256(Convert.FromBase64String(auth.SharedKey));

               // Now build the Authorization header
               String authHeader = String.Format(CultureInfo.InvariantCulture,
                              "{0} {1}:{2}",
                              "SharedKey",
                              auth.Account,
                              System.Convert.ToBase64String(hasher.ComputeHash(signatureByteForm)
                              ));

               rtn = authHeader;

               return rtn;
        }
예제 #9
0
 public string CreateSharedKeyAuth(string method, string resource, string contentMD5, DateTime requestDate, HttpClient client, Authentication auth)
 {
     return CreateSharedKeyAuth(method, resource, contentMD5, requestDate, client, "", auth);
 }
예제 #10
0
 /// <summary>
 /// Create a new AzureCommands object with default settings
 /// </summary>
 /// <param name="pAuth">Azure Authetication Object</param>
 public azureHelper(Authentication  pAuth)
 {
     auth = pAuth;
        client.UserAgent = UserAgent;
 }
예제 #11
0
 /// <summary>
 /// Create a new AzureCommands object with default settings
 /// </summary>
 /// <param name="account">The account is generally the first part of the Endpoint.</param>
 /// <param name="endPoint">The Endpoint for Azure Table Storage as defined for your account</param>
 /// <param name="sharedKey">The SharedKey for access</param>
 /// <param name="keyType">Shared</param>
 public azureHelper(string account, string endPoint, string sharedKey, string keyType)
 {
     auth = new Authentication(account, endPoint, sharedKey);
        client.UserAgent = UserAgent;
 }
예제 #12
0
 /// <summary>
 /// Create a new AzureCommands object with default settings
 /// </summary>
 /// <param name="pAuth">An Azure Authentication Object</param>
 public azureDirect(Authentication pAuth)
 {
     auth = pAuth ;
        client.UserAgent = UserAgent;
 }
예제 #13
0
 /// <summary>
 ///  Create a new AzureCommands object with an auth object
 /// </summary>
 /// <param name="auth">Azure Authetication Object</param>
 public AzureBlobStorage(Authentication auth)
 {
     pAuth = auth;
       ad.auth = pAuth;
 }