internal MongoAWSAuthenticator( string username, IEnumerable <KeyValuePair <string, string> > properties, IRandomByteGenerator randomByteGenerator, IClock clock) : base(CreateMechanism(username, null, properties, randomByteGenerator, clock)) { }
internal MongoAWSAuthenticator( UsernamePasswordCredential credential, IEnumerable <KeyValuePair <string, string> > properties, IRandomByteGenerator randomByteGenerator, IClock clock) : base(CreateMechanism(credential, properties, randomByteGenerator, clock)) { }
public MongoAWSMechanism( AwsCredentials awsCredentials, IRandomByteGenerator randomByteGenerator, IClock clock) { _awsCredentials = Ensure.IsNotNull(awsCredentials, nameof(awsCredentials)); _randomByteGenerator = Ensure.IsNotNull(randomByteGenerator, nameof(randomByteGenerator)); _clock = Ensure.IsNotNull(clock, nameof(clock)); }
// private static methods private static MongoAWSMechanism CreateMechanism( UsernamePasswordCredential credential, IEnumerable <KeyValuePair <string, string> > properties, IRandomByteGenerator randomByteGenerator, IClock clock) { if (credential.Source != "$external") { throw new ArgumentException("MONGODB-AWS authentication may only use the $external source.", nameof(credential)); } return(CreateMechanism(credential.Username, credential.Password, properties, randomByteGenerator, clock)); }
private static MongoAWSMechanism CreateMechanism( string username, SecureString password, IEnumerable <KeyValuePair <string, string> > properties, IRandomByteGenerator randomByteGenerator, IClock clock) { var awsCredentials = CreateAwsCredentialsFromMongoCredentials(username, password, properties) ?? CreateAwsCredentialsFromEnvironmentVariables() ?? CreateAwsCredentialsFromEcsResponse() ?? CreateAwsCredentialsFromEc2Response(); if (awsCredentials == null) { throw new InvalidOperationException("Unable to find credentials for MONGODB-AWS authentication."); } return(new MongoAWSMechanism(awsCredentials, randomByteGenerator, clock)); }
/// <summary> /// Initializes a new instance of the <see cref="WebUtility"/> class. /// </summary> /// <param name="randomByteGenerator">The random byte generator.</param> public WebUtility(IRandomByteGenerator randomByteGenerator) { this.randomByteGenerator = randomByteGenerator; }