Beispiel #1
0
 internal MongoAWSAuthenticator(
     string username,
     IEnumerable <KeyValuePair <string, string> > properties,
     IRandomByteGenerator randomByteGenerator,
     IClock clock)
     : base(CreateMechanism(username, null, properties, randomByteGenerator, clock))
 {
 }
Beispiel #2
0
 internal MongoAWSAuthenticator(
     UsernamePasswordCredential credential,
     IEnumerable <KeyValuePair <string, string> > properties,
     IRandomByteGenerator randomByteGenerator,
     IClock clock)
     : base(CreateMechanism(credential, properties, randomByteGenerator, clock))
 {
 }
Beispiel #3
0
 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));
 }
Beispiel #4
0
        // 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));
        }
Beispiel #5
0
        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;
 }