コード例 #1
0
        static string DetermineBucketRegionCode(ClientConfig config)
        {
            if (config.RegionEndpoint != null && string.IsNullOrEmpty(config.ServiceURL))
            {
                return(config.RegionEndpoint.SystemName);
            }

            return(AWSSDKUtils.DetermineRegion(config.DetermineServiceURL()));
        }
コード例 #2
0
 private static string DetermineService(ClientConfig clientConfig)
 {
     if (!string.IsNullOrEmpty(clientConfig.AuthenticationServiceName))
     {
         return(clientConfig.AuthenticationServiceName.ToLower());
     }
     else
     {
         return(AWSSDKUtils.DetermineService(clientConfig.DetermineServiceURL()).ToLower());
     }
 }
コード例 #3
0
        /// <summary>
        /// Signs the specified request with the AWS2 signing protocol by using the
        /// AWS account credentials given in the method parameters.
        /// </summary>
        /// <param name="awsAccessKeyId">The AWS public key</param>
        /// <param name="awsSecretAccessKey">The AWS secret key used to sign the request in clear text</param>
        /// <param name="clientConfig">The configuration that specifies which hashing algorithm to use</param>
        /// <param name="request">The request to have the signature compute for</param>
        /// <param name="secureKey">The AWS secret key stored in a secure string</param>
        /// <exception cref="Amazon.Runtime.SignatureException">If any problems are encountered while signing the request</exception>
        public override void Sign(IRequest request, ClientConfig clientConfig, string awsAccessKeyId, string awsSecretAccessKey, SecureString secureKey)
        {
            if (String.IsNullOrEmpty(awsAccessKeyId))
            {
                throw new Exception("The AWS Access Key ID cannot be NULL or a Zero length string");
            }

            request.Parameters["AWSAccessKeyId"] = awsAccessKeyId;
            request.Parameters["SignatureVersion"] = clientConfig.SignatureVersion;
            request.Parameters["SignatureMethod"] = clientConfig.SignatureMethod.ToString();
            request.Parameters["Timestamp"] = AWSSDKUtils.FormattedCurrentTimestampISO8601;

            string toSign = AWSSDKUtils.CalculateStringToSignV2(request.Parameters, clientConfig.DetermineServiceURL());
            string auth = ComputeHash(toSign, awsSecretAccessKey, secureKey, clientConfig.SignatureMethod);
            request.Parameters["Signature"] = auth;
        }
コード例 #4
0
        /// <summary>
        /// Signs the specified request with the AWS2 signing protocol by using the
        /// AWS account credentials given in the method parameters.
        /// </summary>
        /// <param name="awsAccessKeyId">The AWS public key</param>
        /// <param name="awsSecretAccessKey">The AWS secret key used to sign the request in clear text</param>
        /// <param name="clientConfig">The configuration that specifies which hashing algorithm to use</param>
        /// <param name="request">The request to have the signature compute for</param>
        /// <param name="secureKey">The AWS secret key stored in a secure string</param>
        /// <exception cref="Amazon.Runtime.SignatureException">If any problems are encountered while signing the request</exception>
        public override void Sign(IRequest request, ClientConfig clientConfig, string awsAccessKeyId, string awsSecretAccessKey, SecureString secureKey)
        {
            if (String.IsNullOrEmpty(awsAccessKeyId))
            {
                throw new Exception("The AWS Access Key ID cannot be NULL or a Zero length string");
            }

            request.Parameters["AWSAccessKeyId"]   = awsAccessKeyId;
            request.Parameters["SignatureVersion"] = clientConfig.SignatureVersion;
            request.Parameters["SignatureMethod"]  = clientConfig.SignatureMethod.ToString();
            request.Parameters["Timestamp"]        = AWSSDKUtils.FormattedCurrentTimestampISO8601;

            string toSign = AWSSDKUtils.CalculateStringToSignV2(request.Parameters, clientConfig.DetermineServiceURL());
            string auth   = ComputeHash(toSign, awsSecretAccessKey, secureKey, clientConfig.SignatureMethod);

            request.Parameters["Signature"] = auth;
        }
コード例 #5
0
 public static Uri DetermineEndpoint(ClientConfig config, IRequest request)
 {
     return(request.AlternateEndpoint != null
          ? new Uri(ClientConfig.GetUrl(request.AlternateEndpoint, config.RegionEndpointServiceName, config.UseHttp))
          : new Uri(config.DetermineServiceURL()));
 }
コード例 #6
0
 internal static string DetermineService(ClientConfig clientConfig)
 {
     return !string.IsNullOrEmpty(clientConfig.AuthenticationServiceName) 
         ? clientConfig.AuthenticationServiceName 
         : AWSSDKUtils.DetermineService(clientConfig.DetermineServiceURL());
 }
コード例 #7
0
 internal static string DetermineService(ClientConfig clientConfig)
 {
     return !string.IsNullOrEmpty(clientConfig.AuthenticationServiceName) 
         ? clientConfig.AuthenticationServiceName.ToLower(CultureInfo.InvariantCulture) 
         : AWSSDKUtils.DetermineService(clientConfig.DetermineServiceURL()).ToLower(CultureInfo.InvariantCulture);
 }
コード例 #8
0
 internal static string DetermineService(ClientConfig clientConfig)
 {
     return(!string.IsNullOrEmpty(clientConfig.AuthenticationServiceName)
         ? clientConfig.AuthenticationServiceName.ToLower(CultureInfo.InvariantCulture)
         : AWSSDKUtils.DetermineService(clientConfig.DetermineServiceURL()).ToLower(CultureInfo.InvariantCulture));
 }
コード例 #9
0
 internal static Uri DetermineEndpoint(ClientConfig config, IRequest request)
 {
     return request.AlternateEndpoint != null
          ? new Uri(ClientConfig.GetUrl(request.AlternateEndpoint, config.RegionEndpointServiceName, config.UseHttp))
          : new Uri(config.DetermineServiceURL());
 }