internal AmazonWebServiceClient(AWSCredentials credentials, ClientConfig config, bool ownCredentials, AuthenticationTypes authenticationType)
        {
            if (config.DisableLogging)
            {
                this.logger = Logger.EmptyLogger;
            }
            else
            {
                this.logger = Logger.GetLogger(this.GetType());
            }

            this.config             = config;
            this.ownCredentials     = ownCredentials;
            this.authenticationType = authenticationType;

            // Lookup cached version of refreshing credentials to reduce calls to STS.
            if (credentials is RefreshingSessionAWSCredentials)
            {
                RefreshingSessionAWSCredentials refreshCredentials = credentials as RefreshingSessionAWSCredentials;

                if (string.IsNullOrEmpty(refreshCredentials.UniqueIdentifier))
                {
                    this.credentials = credentials;
                }
                else
                {
                    this.ownCredentials = false;
                    lock (cachedRefreshingCredentialsLock)
                    {
                        if (cachedRefreshingCredentials.ContainsKey(refreshCredentials.UniqueIdentifier))
                        {
                            this.credentials = cachedRefreshingCredentials[refreshCredentials.UniqueIdentifier];
                        }
                        else
                        {
                            this.credentials = refreshCredentials;
                            cachedRefreshingCredentials[refreshCredentials.UniqueIdentifier] = refreshCredentials;
                        }
                    }
                }
            }
            else
            {
                this.credentials = credentials;
            }

            Initialize();
        }
Beispiel #2
0
 public void SetupClient(Hashtable State)
 {
     //Creating AmazonSecurityTokenServiceClient, using Access and Secret keys from web.config
     AmazonSecurityTokenServiceClient stsClient = new AmazonSecurityTokenServiceClient();
     //Creating RefreshingSessionAWSCredentials and initializing AmazonDynamoDBClient
     RefreshingSessionAWSCredentials sessionCredentials = new RefreshingSessionAWSCredentials(stsClient);
     State["DynamoDBClient"] = new AmazonDynamoDBClient(sessionCredentials);
 }