protected override int GetSeedForSession(string sessionId)
{
Guard.NotNullOrEmpty(sessionId, "sessionId");
int seed;
string response;
Uri seedUri = MakeSeedUri(sessionId);
Log.InfoFormat("fetching seed from {0}", seedUri);
try
{
response = seedUri.GetResponseString(HttpMethod.Get);
}
catch(IOException exc)
{
Log.Error(exc);
throw Guard.LiveDecrypterFactory_FailedToFetchSessionSeed(exc);
}
if(response.Equals("invalid", StringComparison.OrdinalIgnoreCase))
{
Log.Error("failed to fetch the seed as the authentication token has been rejected");
throw Guard.LiveDecrypterFactory_AuthenticationTokenRejected();
}
if(!int.TryParse(response, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out seed))
{
Log.ErrorFormat("failed to parse seed from {0}", response);
throw Guard.LiveDecrypterFactory_UnableToParseSeed(response);
}
return seed;
}