protected override CredentialsRefreshState GenerateNewCredentials()
{
Validate();
CredentialsRefreshState newState = null;
var attempts = 0;
do
{
try
{
NetworkCredential userCredential = null;
if (!ProfileData.UseDefaultUserIdentity)
{
var callbackArgs = new CredentialCallbackArgs
{
UserIdentity = ProfileData.UserIdentity,
CustomState = CustomCallbackState,
PreviousAuthenticationFailed = attempts > 0
};
userCredential = RequestUserCredentialCallback(callbackArgs);
if (userCredential == null) // user declined to authenticate
throw new AuthenticationFailedException("No credentials supplied, credential refresh abandoned");
}
newState = Authenticate(userCredential, _credentialDuration);
}
catch (AuthenticationFailedException)
{
if (attempts < MaxAuthenticationRetries)
attempts++;
else
throw;
}
} while (newState == null && attempts < MaxAuthenticationRetries);
return newState;
}