private void AddRequiredParameters(IDictionary <string, string> parameters, string queueUrl) { string str2; if (string.IsNullOrEmpty(this.awsAccessKeyId)) { throw new AmazonSQSException("The AWS Access Key ID cannot be NULL or a Zero length string"); } parameters["AWSAccessKeyId"] = this.awsAccessKeyId; parameters["SignatureVersion"] = this.config.SignatureVersion; parameters["SignatureMethod"] = this.config.SignatureMethod; parameters["Timestamp"] = AWSSDKUtils.FormattedCurrentTimestampISO8601; parameters["Version"] = this.config.ServiceVersion; if (!this.config.SignatureVersion.Equals("2")) { throw new AmazonSQSException("Invalid Signature Version specified"); } string data = AWSSDKUtils.CalculateStringToSignV2(parameters, queueUrl); KeyedHashAlgorithm algorithm = KeyedHashAlgorithm.Create(this.config.SignatureMethod.ToUpper()); if (this.config.UseSecureStringForAwsSecretKey) { str2 = AWSSDKUtils.HMACSign(data, this.awsSecretAccessKey, algorithm); } else { str2 = AWSSDKUtils.HMACSign(data, this.clearAwsSecretAccessKey, algorithm); } parameters["Signature"] = str2; }
/** * Add authentication related and version parameters */ private void AddRequiredParameters(IDictionary <string, string> parameters) { if (String.IsNullOrEmpty(this.awsAccessKeyId)) { throw new AmazonAutoScalingException("The AWS Access Key ID cannot be NULL or a Zero length string"); } parameters["AWSAccessKeyId"] = this.awsAccessKeyId; parameters["SignatureVersion"] = config.SignatureVersion; parameters["SignatureMethod"] = config.SignatureMethod; parameters["Timestamp"] = AWSSDKUtils.FormattedCurrentTimestampISO8601; parameters["Version"] = config.ServiceVersion; if (!config.SignatureVersion.Equals("2")) { throw new AmazonAutoScalingException("Invalid Signature Version specified"); } string toSign = AWSSDKUtils.CalculateStringToSignV2(parameters, config.ServiceURL); KeyedHashAlgorithm algorithm = KeyedHashAlgorithm.Create(config.SignatureMethod.ToUpper()); string auth; if (config.UseSecureStringForAwsSecretKey) { auth = AWSSDKUtils.HMACSign(toSign, awsSecretAccessKey, algorithm); } else { auth = AWSSDKUtils.HMACSign(toSign, clearAwsSecretAccessKey, algorithm); } parameters["Signature"] = auth; }
/** * Add authentication related and version parameters */ private void addRequiredParameters(IDictionary <string, string> parameters) { if (String.IsNullOrEmpty(this.awsAccessKeyId)) { throw new AmazonSimpleDBException("The AWS Access Key ID cannot be NULL or a Zero length string"); } if (parameters.ContainsKey("Signature")) { parameters.Remove("Signature"); } parameters["AWSAccessKeyId"] = this.awsAccessKeyId; parameters["SignatureVersion"] = config.SignatureVersion; parameters["SignatureMethod"] = config.SignatureMethod; parameters["Timestamp"] = AmazonSimpleDBUtil.FormattedCurrentTimestamp; parameters["Version"] = config.ServiceVersion; if (!config.SignatureVersion.Equals("2")) { throw new AmazonSimpleDBException("Invalid Signature Version specified"); } string toSign = AWSSDKUtils.CalculateStringToSignV2(parameters, config.ServiceURL, "POST"); using (KeyedHashAlgorithm algorithm = new HMACSHA256()) { string auth = AWSSDKUtils.HMACSign(toSign, clearAwsSecretAccessKey, algorithm); parameters["Signature"] = auth; } }
/** * Add authentication related and version parameters */ private void AddRequiredParameters(IDictionary <string, string> parameters, string queueUrl) { using (ImmutableCredentials immutableCredentials = this.credentials.GetCredentials()) { if (immutableCredentials.UseToken) { parameters["SecurityToken"] = immutableCredentials.Token; } parameters["AWSAccessKeyId"] = immutableCredentials.AccessKey; parameters["SignatureVersion"] = config.SignatureVersion; parameters["SignatureMethod"] = config.SignatureMethod; parameters["Timestamp"] = AWSSDKUtils.FormattedCurrentTimestampISO8601; parameters["Version"] = config.ServiceVersion; if (!config.SignatureVersion.Equals("2")) { throw new AmazonSQSException("Invalid Signature Version specified"); } string toSign = AWSSDKUtils.CalculateStringToSignV2(parameters, queueUrl); KeyedHashAlgorithm algorithm = KeyedHashAlgorithm.Create(config.SignatureMethod.ToUpper()); string auth; if (immutableCredentials.UseSecureStringForSecretKey) { auth = AWSSDKUtils.HMACSign(toSign, immutableCredentials.SecureSecretKey, algorithm); } else { auth = AWSSDKUtils.HMACSign(toSign, immutableCredentials.ClearSecretKey, algorithm); } parameters["Signature"] = auth; } }
/** * Add authentication related and version parameters */ private void AddRequiredParameters(IDictionary <string, string> parameters) { using (ImmutableCredentials immutableCredentials = this.credentials.GetCredentials()) { if (String.IsNullOrEmpty(immutableCredentials.AccessKey)) { throw new AmazonSimpleNotificationServiceException("The AWS Access Key ID cannot be NULL or a Zero length string"); } if (immutableCredentials.UseToken) { parameters["SecurityToken"] = immutableCredentials.Token; } parameters["AWSAccessKeyId"] = immutableCredentials.AccessKey; parameters["SignatureVersion"] = config.SignatureVersion; parameters["SignatureMethod"] = config.SignatureMethod; parameters["Timestamp"] = AWSSDKUtils.FormattedCurrentTimestampISO8601; parameters["Version"] = config.ServiceVersion; if (!config.SignatureVersion.Equals("2")) { throw new AmazonSimpleNotificationServiceException("Invalid Signature Version specified"); } string url; if (config.RegionEndpoint != null) { url = "https://" + config.RegionEndpoint.GetEndpointForService(config.RegionEndpointServiceName).Hostname; } else { url = config.ServiceURL; } string toSign = AWSSDKUtils.CalculateStringToSignV2(parameters, url); KeyedHashAlgorithm algorithm = KeyedHashAlgorithm.Create(config.SignatureMethod.ToUpper()); string auth; if (immutableCredentials.UseSecureStringForSecretKey) { auth = AWSSDKUtils.HMACSign(toSign, immutableCredentials.SecureSecretKey, algorithm); } else { auth = AWSSDKUtils.HMACSign(toSign, immutableCredentials.ClearSecretKey, algorithm); } parameters["Signature"] = auth; } }
/// <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.ServiceURL); string auth = ComputeHash(toSign, awsSecretAccessKey, secureKey, clientConfig.SignatureMethod); request.Parameters["Signature"] = auth; }
public override void Sign(IRequest request, IClientConfig clientConfig, RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey) { if (string.IsNullOrEmpty(awsAccessKeyId)) { throw new ArgumentOutOfRangeException("awsAccessKeyId", "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; request.Parameters.Remove("Signature"); string text = AWSSDKUtils.CalculateStringToSignV2(request.Parameters, request.Endpoint.AbsoluteUri); metrics.AddProperty(Metric.StringToSign, text); string value = AbstractAWSSigner.ComputeHash(text, awsSecretAccessKey, clientConfig.SignatureMethod); request.Parameters["Signature"] = value; }
/// <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="metrics">Request metrics</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> /// <exception cref="Amazon.Runtime.SignatureException">If any problems are encountered while signing the request</exception> public override void Sign(IRequest request, ClientConfig clientConfig, RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey) { if (String.IsNullOrEmpty(awsAccessKeyId)) { throw new ArgumentOutOfRangeException("awsAccessKeyId", "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()); metrics.AddProperty(Metric.StringToSign, toSign); string auth = ComputeHash(toSign, awsSecretAccessKey, clientConfig.SignatureMethod); request.Parameters["Signature"] = auth; }
/// <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="metrics">Request metrics</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> /// <exception cref="Amazon.Runtime.SignatureException">If any problems are encountered while signing the request</exception> public override void Sign(IRequest request, IClientConfig clientConfig, RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey) { if (String.IsNullOrEmpty(awsAccessKeyId)) { throw new ArgumentOutOfRangeException("awsAccessKeyId", "The AWS Access Key ID cannot be NULL or a Zero length string"); } request.Parameters["AWSAccessKeyId"] = awsAccessKeyId; request.Parameters["SignatureVersion"] = SignatureVersion2; request.Parameters["SignatureMethod"] = clientConfig.SignatureMethod.ToString(); request.Parameters["Timestamp"] = AWSSDKUtils.GetFormattedTimestampISO8601(clientConfig); // remove Signature parameter, in case this is a retry request.Parameters.Remove("Signature"); string toSign = AWSSDKUtils.CalculateStringToSignV2(request.ParameterCollection, request.Endpoint.AbsoluteUri); metrics.AddProperty(Metric.StringToSign, toSign); string auth = ComputeHash(toSign, awsSecretAccessKey, clientConfig.SignatureMethod); request.Parameters["Signature"] = auth; }