public override ImmutableCredentials GetCredentials()
{
lock (this._refreshLock)
{
// If credentials are expired, update
if (ShouldUpdate)
{
_currentState = GenerateNewCredentials();
// Check if the new credentials are already expired
if (ShouldUpdate)
{
throw new AmazonClientException("The retrieved credentials have already expired");
}
// Offset the Expiration by PreemptExpiryTime
_currentState.Expiration -= PreemptExpiryTime;
if (ShouldUpdate)
{
// This could happen if the default value of PreemptExpiryTime is
// overriden and set too high such that ShouldUpdate returns true.
_logger.InfoFormat(
"The preempt expiry time is set too high: Current time = {0}, Credentials expiry time = {1}, Preempt expiry time = {2}.",
DateTime.Now,
_currentState.Expiration,
PreemptExpiryTime);
}
}
return _currentState.Credentials.Copy();
}
}