/// <summary> /// Initializes a new instance of the AwsHttpConnection class with the specified AccessKey, SecretKey and Token. /// </summary> /// <param name="awsSettings">AWS specific settings required for signing requests.</param> public AwsHttpConnection(AwsSettings awsSettings) { if (awsSettings == null) { throw new ArgumentNullException("awsSettings"); } if (string.IsNullOrWhiteSpace(awsSettings.Region)) { throw new ArgumentException("awsSettings.Region is invalid.", "awsSettings"); } _region = awsSettings.Region.ToLowerInvariant(); var key = GetAccessKey(awsSettings); var secret = GetSecretKey(awsSettings); if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(secret)) { _credentials = new Credentials { AccessKey = key, SecretKey = secret, }; _authType = AuthType.AccessKey; } else { _authType = AuthType.InstanceProfile; } }
private static string GetSecretKey(AwsSettings awsSettings) { var key = awsSettings.SecretKey; if (!string.IsNullOrWhiteSpace(key)) return key; #if NET45 key = System.Configuration.ConfigurationManager.AppSettings["AWSSecretKey"]; if (!string.IsNullOrWhiteSpace(key)) return key; #endif return Environment.GetEnvironmentVariable("AWS_SECRET_ACCESS_KEY"); }
/// <summary> /// Initializes a new instance of the AwsHttpConnection class. /// </summary> /// <param name="settings">The NEST/Elasticsearch.Net settings.</param> /// <param name="awsSettings">AWS specific settings required for signing requests.</param> public AwsHttpConnection(IConnectionConfigurationValues settings, AwsSettings awsSettings) : base(settings) { if (awsSettings == null) throw new ArgumentNullException("awsSettings"); if (string.IsNullOrWhiteSpace(awsSettings.SecretKey)) throw new ArgumentException("awsSettings.SecretKey is invalid.", "awsSettings"); if (string.IsNullOrWhiteSpace(awsSettings.Region)) throw new ArgumentException("awsSettings.Region is invalid.", "awsSettings"); _accessKey = awsSettings.AccessKey; _secretKey = awsSettings.SecretKey; _region = awsSettings.Region.ToLowerInvariant(); }
private static string GetSecretKey(AwsSettings awsSettings) { var key = awsSettings.SecretKey; if (!string.IsNullOrWhiteSpace(key)) { return(key); } key = ConfigurationManager.AppSettings["AWSSecretKey"]; if (!string.IsNullOrWhiteSpace(key)) { return(key); } return(Environment.GetEnvironmentVariable("AWS_SECRET_ACCESS_KEY")); }
private static string GetAccessKey(AwsSettings awsSettings) { var key = awsSettings.AccessKey; if (!string.IsNullOrWhiteSpace(key)) { return(key); } #if NET45 key = System.Configuration.ConfigurationManager.AppSettings["AWSAccessKey"]; if (!string.IsNullOrWhiteSpace(key)) { return(key); } #endif return(Environment.GetEnvironmentVariable("AWS_ACCESS_KEY_ID")); }
public AwsHttpConnection(AwsSettings awsSettings) { if (awsSettings == null) { throw new ArgumentNullException(nameof(awsSettings)); } if (string.IsNullOrWhiteSpace(awsSettings.Region)) { throw new ArgumentException("awsSettings.Region is invalid.", nameof(awsSettings)); } _region = awsSettings.Region.ToLowerInvariant(); if (!string.IsNullOrWhiteSpace(awsSettings.AccessKey) && !string.IsNullOrWhiteSpace(awsSettings.SecretKey)) { _credentialsProvider = new StaticCredentialsProvider(awsSettings); } else { _credentialsProvider = CredentialChainProvider.Default; } }
/// <summary> /// Initializes a new instance of the AwsHttpConnection class with the specified AccessKey, SecretKey and Token. /// </summary> /// <param name="awsSettings">AWS specific settings required for signing requests.</param> public AwsHttpConnection(AwsSettings awsSettings) { if (awsSettings == null) throw new ArgumentNullException("awsSettings"); if (string.IsNullOrWhiteSpace(awsSettings.Region)) throw new ArgumentException("awsSettings.Region is invalid.", "awsSettings"); _region = awsSettings.Region.ToLowerInvariant(); var key = GetAccessKey(awsSettings); var secret = GetSecretKey(awsSettings); if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(secret)) { _credentials = new Credentials { AccessKey = key, SecretKey = secret, Token = awsSettings.Token }; _authType = AuthType.AccessKey; } else { _authType = AuthType.InstanceProfile; } }